Basically the question above, you don't need to read the lot below, just additional info on how i want to use it.
I Have an activity (which extends tab activity) with two tabs. My tabs don't have different intentss, they're both filled within the same activity. Within each of these i have a list i'm filling from a Database.
The two tabs are "income" and "outcome" and I've been trying to set it up so that depending on the open tab a different query will be run and a different list is displayed.
The right data is displayed but whatever tab opens first is the only one that has anything in it, i realised this was because it wasn't re-querying the database (my getBudgetAmount method) and showing the list (showBudgetCategories method) when the tab changed and figured i'd have to test for that change but i haven't found a way to do that yet that works.. then i thought maybe there's a listener i could use instead? If anyone could point me the right way i'd really appreciate it!
Here's my activity:
EDIT, formatting keeps going funny, you'll find it easier to read here-http://codeviewer.org/view/code:1501
Have your Budget class implement OnTabChangeListener
, then in the onCreate() method,
add this line:
mTabHost.setOnTabChangedListener(this);
Then have your Budget class implement onTabChanged
:
public void onTabChanged(String tabName) {
if(tabName.equals("tab1")) {
//do something
}
else if(tabName.equals("tab2")) {
//do something
}
}