I have a TabView with multiple layouts in each view. I thought I could just copy my layout XML file (foo.xml), rename it (bar.xml), and use the new layout (bar.xml) in a new Class. eg: Tab1 is foo.java which does a setContentView (R.layout.foo) and Tab2 is bar.java doing a setContentView (R.layout.bar).
This seems to be a problem though, because when I change the text of a button in Tab1, it seems to change it in Tab2 as well. I was expecting each class to be limited to only the widgets contained in the xml implemented in setContentView(). Is the scope of the widget ID really this broad?
No the scope isn’t that broad. If you have an element with id “fizz” in foo.xml you cannot get a handle to the element fizz from your activity unless you’re setting the contentview to foo.xml in that same activity.
When creating the TabView, are you sure you’re not adding Tab1 twice?