How can I get reference to the TextViews, for example, if I didn’t set layout as a content view?
I’m using TabHost to switch between Activities:
public class TimerResultsActivity extends TabActivity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
initTabs();
TextView resultsText = (TextView)findViewById(R.id.textView1);
resultsText.setText("test");
}
...
“textView1” has added to one of tabs, but hasn’t declared in the main.xml.
How can I change a text on it?
You’ll need a reference to the base of the layout that it is declared in. Then you can use the
findViewById()method of theViewGroupit belongs to.