Hello Kostya, I'm response to my previous question, I'll post how to solve it. It was quite easy, but I didn't realize it :P
Instead of setting the content view with: setContentView(new MyView(this)); I just instantiate the view with: myView = new MyView(this); setContentView(myView); Thus, I can access directly the methods from the View, like myView.invalidate(); Thanks! On 11 Apr., 12:52, Kostya Vasilyev <[email protected]> wrote: > Yes. The original code as posted was: > > @Override > protected void onCreate(Bundle savedInstanceState) { > super.onCreate(savedInstanceState); > setContentView(new MyView(this)); > [...] > > This can be changed to: > > *private MyView mMyView;* > > @Override > protected void onCreate(Bundle savedInstanceState) { > super.onCreate(savedInstanceState); > *mMyView = **new MyView(this);* > *setContentView(mMyView);* > [...] > > To make MyView redraw, you can just call mMyView.invalidate() from the > activity. For other tasks, you can add methods to MyView, and call them > from the activity. > > -- Kostya > > 11.04.2011 14:40, lbendlin ?????: > > > Kostya said you should keep a reference to the view, because there is > > no Android equivalent to findViewById(). > > You might also find it by walking the view hierarchy recursively but > > that might be too costly. > > -- > > You received this message because you are subscribed to the Google > > Groups "Android Developers" group. > > To post to this group, send email to [email protected] > > To unsubscribe from this group, send email to > > [email protected] > > For more options, visit this group at > >http://groups.google.com/group/android-developers?hl=en > > -- > Kostya Vasilyev --http://kmansoft.wordpress.com -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en

