Hardik Gajjar
Hardik Gajjar

Reputation: 5058

How to reload the Tab activity when the tab changes?

how to reload the activity when tab is select again? please give me a example code..when i press the tab it give me old output but i want to reload that activity for new updated output so please help me Thanks a lot.

Upvotes: 7

Views: 8731

Answers (2)

Inco Mob
Inco Mob

Reputation: 594

You can use onWindowFocusChanged method also if you need to do 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);

}

Upvotes: 1

Tanmay Mandal
Tanmay Mandal

Reputation: 40168

Just use .addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP) to your tab class

Example

 tabHost.addTab(tabHost.newTabSpec("Your Tab")
        .setIndicator("tab indicator")
        .setContent(new Intent(this, TabClass.class)
        .addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)));

Upvotes: 29

Related Questions