My linear layout has two views:
- Custom View that display dynamic stuff
- One button
I’d like to use the button to invalidate the custom view so that it can be redrawn by Android. I’ve implemented the onClickListener() inside the Activity where all the views are located. But the OnClickListener() doesn’t seem to have access to other viewers other than the view which the listener is bound to. How to call invalidate() on a different view from the button’s OnClickListener()?
You can retrieve the other view via
Activity.findViewById(id). You must cast the returned object to the desired type if you have declared your custom view in an XML layout and have assigned it anandroid:id. Otherwise if you instantiate your View by hand (ie by calling its constructor) simply keep a reference to the object in the form of an instance variable