切换回previously选择的标签的活动后重建 [英] Switch back to previously selected tab after the activity is recreated

查看:257
本文介绍了切换回previously选择的标签的活动后重建的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我TabActivity用户可能会被要求转换为OAuth的阶段浏览器活动,如果该阶段需要太多的时间,我的活动就会被杀死。用户切换回我的活动后,其onCreate()方法是再次调用和标签被重新创建。

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.

所以,我想知道是否有切换回previous选项卡,并保持选项卡,这是什么什么简单的办法。例如,标签视图之一包含ViewSwitcher孩子,我想重新创建活动后,切换回切换视图。

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.

推荐答案

步骤1:在的onSaveInstanceState(),保存的状态,你的标签,脚蹼等。 ,所以你知道你在哪里。

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

第二步:在 onRestoreInstanceState(),调用适当的方法来恢复你的状态(例如, setCurrentTab())。

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

这篇关于切换回previously选择的标签的活动后重建的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆