[android-beginners] Re: onDraw is never called...

2009-03-09 Thread mcmc

Thanks for your responses.

I think I have set the view in the content view (although I'm not
entirely sure what that means...). But I don't think I made it
"visible"... how do I do that?

This is what I have:


public class TestDraw extends Activity {

/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(new DemoView(this));
}

private class DemoView extends View{

public DemoView(Context context){
super(context);
}

@Override protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
canvas.drawColor(Color.WHITE);
}

public void drawTest() {

// do something

// i want onDraw to be called here

// do something

}
}
}


On Mar 7, 7:59 am, MrSnowflake  wrote:
> onDraw() will only be called when the view is in the content view of
> the Activity and visible!
>
> On 5 mrt, 20:25, mcmc  wrote:
>
> > I cannot get the onDraw function to be called. Here is the what my
> > basic code looks like. What triggers the onDraw to be called?
>
> >         private class DemoView extends View{
>
> >                 public DemoView(Context context){
> >                         super(context);
> >                 }
>
> >                 @Override protected void onDraw(Canvas canvas) {
> >                         super.onDraw(canvas);
> >                         canvas.drawColor(Color.WHITE);
> >                 }
>
> >                 public void drawTest() {
>
> >                         // do something
>
> >                         // i want onDraw to be called here
>
> >                         // do something
>
> >                 }
> >         }
>
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Android Beginners" group.
To post to this group, send email to android-beginners@googlegroups.com
To unsubscribe from this group, send email to
android-beginners-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en
-~--~~~~--~~--~--~---



[android-beginners] Re: onDraw is never called...

2009-03-07 Thread MrSnowflake

onDraw() will only be called when the view is in the content view of
the Activity and visible!

On 5 mrt, 20:25, mcmc  wrote:
> I cannot get the onDraw function to be called. Here is the what my
> basic code looks like. What triggers the onDraw to be called?
>
>         private class DemoView extends View{
>
>                 public DemoView(Context context){
>                         super(context);
>                 }
>
>                 @Override protected void onDraw(Canvas canvas) {
>                         super.onDraw(canvas);
>                         canvas.drawColor(Color.WHITE);
>                 }
>
>                 public void drawTest() {
>
>                         // do something
>
>                         // i want onDraw to be called here
>
>                         // do something
>
>                 }
>         }
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Android Beginners" group.
To post to this group, send email to android-beginners@googlegroups.com
To unsubscribe from this group, send email to
android-beginners-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en
-~--~~~~--~~--~--~---