开发者

Emulate back button in multi-view TabActivity

I have a TabActivity with several tabs. Each tab corresponds to a specific view, and those views may further switch to other views. For example, one of my tabs displays RSS feed list, after user clicks one of the RSS feed, it will switch to a view displaying a list of articles, and after user clicks one of the titles, a full article view will be displayed.

I'm going to add support for "back" button in my application. For instance, in a full article view, after user presses the "back" button, it should switch back to the article list view. And if user presses it the "back" button again, my application should switch back to the feed list view.

My idea is to maintain a Stack<View> during navigation, and every time user presses the "back" button, the program will开发者_如何转开发 pop a View out of the stack, and set it as the current view. But I would like to know how to set current view in TabHost. Many thanks.


To only answer your question:

You need one of this two methods

http://developer.android.com/reference/android/widget/TabHost.html#setCurrentTab(int)

http://developer.android.com/reference/android/widget/TabHost.html#setCurrentTabByTag(java.lang.String)

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜