I have a TextView inside the same RelativeLayout as a chunk of ImageView derived custom classes. I'd like to be able to write to the TextView from inside these other Views. How do I do this since I am unable to use findViewById due to it not being a child?
+1
A:
I'd like to be able to write to the TextView from inside these other Views.
That is not a good design. Views
should not interact with other random Views
. Communication between those should be handled by the Activity
, or possibly by making the RelativeLayout
be a custom View
and having it mediate the communication.
CommonsWare
2010-08-08 10:58:47
Well the Activity currently has a method for logging into the TextView. Can I call that somehow?
Zulaxia
2010-08-08 11:32:02
@Zulaxia: I have no idea what "logging into the TextView" means. Your activity should register some sort of listener to the ImageView(s). Your ImageViews should notify that listener when events occur. The activity should take action upon those events, such as updating the TextView.
CommonsWare
2010-08-08 12:20:27
@CommonsWare : Sorry, that read as complete rubbish. Was on my phone and predictive text butchered it without me noticing.Thanks for the reply, seems obvious now that you mention listeners. Thanks for pointing me back in the right direction.
Zulaxia
2010-08-08 15:55:05