I want to draw the android widgets like edittext, progressbar or a textview in onDraw() method.
My Test activity sets a view by setContentView(xxx). The xxx class extends View class and it has a onDraw(Canvas canvas) method. So basically when i set, setContentView(xxx) this xxx-->onDraw() method should be invoked. Which is rightly happened and all i did in the onDraw() method is shown below.
Using java Syntax Highlighting
- ProgressBar progress;
- protected void onDraw(Canvas canvas)
- {
- int scrW = getWidth();
- int scrH = getHeight();
- if(progress == null)
- {
- progress = new ProgressBar(test, null, android.R.attr.progressBarStyleHorizontal);
- progress.setLayoutParams(new AbsoluteLayout.LayoutParams(scrW, scrH, 0, 0));
- progress.setProgress(50);
- progress.setVisibility(View.VISIBLE);
- }
- //not only for progessbar also this case is applicable to edittext, textview and all type of widgets as well
- progress.draw(canvas);
- }
Parsed in 0.032 seconds, using GeSHi 1.0.8.4
What i expect to see is this above progress.draw(canvas) should invoke the ProgressBar.onDraw(canvas) method which they will be using to draw the progressbar. But it does not work as expected.
Can anyone help me to resolve this issue?
Thanks!





