I have a tabhost with two tabs. Each tab has his own activity. My goal is to execute a method in one of the tabs if the tab was changed. I have set up this OnTabChangedListener:
tabHost.setOnTabChangedListener(new OnTabChangeListener () {
@Override
public void onTabChanged(String tabID) {
Log.d("DEB", "Tab changed:" + tabID);
}});
This part works fine, everytime I change the tab a log entry is created.
Now I would like to call this method in the newly chosen tab:
public void refreshContent() {
setContentView(R.layout.listartists);
ArrayList<Song> searchResults = GetSearchResults();
final ListView lv1 = (ListView) findViewById(R.id.ListView02);
lv1.setAdapter(new MyCustomBaseAdapter2(this, searchResults));
Log.d("DEB", "ArtistView: Content refreshed.");
}
Is there anyone who can explain a possible solution for this?
Thank you in Advance!
Greetings from Germany!
Sebastian
try to put this code in onResume of the activity you want to execute this code when tab is changed because when the tab is clicked onResume is called for that activity