模拟多视图 TabActivity 中的后退按钮

发布于 2024-09-04 00:11:04 字数 371 浏览 3 评论 0原文

我有一个带有多个选项卡的 TabActivity。每个选项卡对应一个特定视图,并且这些视图可以进一步切换到其他视图。例如,我的一个选项卡显示RSS提要列表,当用户单击其中一个RSS提要后,它将切换到显示文章列表的视图,当用户单击其中一个标题后,将显示完整的文章视图。

我将在我的应用程序中添加对“后退”按钮的支持。例如,在完整文章视图中,用户按下“后退”按钮后,应该切换回文章列表视图。如果用户再次按下“后退”按钮,我的应用程序应该切换回提要列表视图。

我的想法是在导航过程中维护一个Stack,每次用户按下“后退”按钮时,程序都会从​​堆栈中弹出一个View,并将其设置为当前视图。但我想知道如何在 TabHost 中设置当前视图。非常感谢。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文