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

Reply via email to