Reloading tab activity onResume but don't want to reload on tab switch
I'm not sure if my title is clear so let me explain.
Tab A - contains a listview populated from a database Tab 开发者_开发百科B - search form
I need to update the contents of tab A after coming back from a search results screen. Using onResume() works great but this also reloads the Tab whenever I click back and forth through between tabs. Is there another method I could use here?
EDIT: I guess it's a bit more complex than this. The search form loads a new intent that displays the results in a listview. An item can be select which then loads a item info screen. From here the user can select from a few option, one being Add. This is the action that needs to reload the original listview in Tab A.
In tab A trigger the search activity with startIntentForResult()
and then in onActivityResult()
get your Adapter of the ListView
and set the new data of the ListView.
You can use onWindowFocusChanged method if you need to add some more process when getting the focus for a particular tab..
@Override
public void onWindowFocusChanged(boolean hasFocus) {
// TODO Auto-generated method stub
//You can add your own method to refresh data within the tab //(Ex: refreshData())
super.onWindowFocusChanged(hasFocus);
}
精彩评论