开发者

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.


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


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

}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜