문제

In my TabActivity the user may be asked to switch to browser activity for OAuth phase, and if the phase takes too much time, my activity will be killed. After the user switches back to my activity, its onCreate() method is invoked again and tabs are recreated.

So I would like to know if there is any simple way to switch back to previous tab, and keep the tab as what it was. For example, one of the tab views contains a ViewSwitcher child, and I want to switch back to the switched view after recreating the activity.

도움이 되었습니까?

해결책

Step #1: In onSaveInstanceState(), save the state of your tabs, flippers, etc., so you know where you were

Step #2: In onRestoreInstanceState(), call appropriate methods to restore your state (e.g., setCurrentTab()).

다른 팁

You can use intent in TabHost to set content of that tab.

tabHost .setContent(new Intent(this, XYZ.class)));

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top