I am currently trying to use different identifiers for each widget, but if I used the same identifier for some widgets in different layout XML files, what would happen to my findViewById calls? Will it be confusing and return the widget from the wrong layout file?
I ask because I was thinking about turning on the view (with several buttons) in some other views, then each of these screen classes would have to assign a slightly different behavior to each button of the included view. But for this, they will call findViewById on the same identifier. For example, currently I like this in every file:
final ImageButton homeButton = (ImageButton)this.findViewById(R.id.rshome_button); homeButton.setOnClickListener(new BottomButtonClickListener()); final ImageButton hotButton = (ImageButton)this.findViewById(R.id.rshotlist_button); hotButton.setOnClickListener(new BottomButtonClickListener()); final ImageButton locButton = (ImageButton)this.findViewById(R.id.rsbot_map); locButton.setOnClickListener(new BottomButtonClickListener()); final ImageButton sendButton = (ImageButton)this.findViewById(R.id.rssend_button); sendButton.setOnClickListener(new BottomButtonClickListener());
But I modify R.id in each file to indicate a widget in each approved layout. it would be nice if I could use one R.id for everyone, so I donβt need to customize every layout file and every screen class.
thanks
android layout
lost baby
source share