Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to reload the Tab activity when the tab changes?

Tags:

android

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.

like image 934
Hardik Gajjar Avatar asked Apr 11 '11 11:04

Hardik Gajjar


2 Answers

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)));
like image 132
Tanmay Mandal Avatar answered Oct 26 '22 16:10

Tanmay Mandal


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);

}
like image 31
Inco Mob Avatar answered Oct 26 '22 16:10

Inco Mob