Android 中的后退按钮退出应用程序
我有点困惑,我有一个应用程序,在 tabHost 中有 5 个选项卡。每个选项卡都有一个 ActivityGroup,该 ActivityGroup 还具有父 Activity 和子 Activity。父活动包含标题列表,子活动包含这些标题的详细信息。现在,如果我从详细信息页面转到应用程序中的另一个选项卡,然后返回到我查看详细信息的同一选项卡,则会再次显示详细信息,而应显示父活动,或者如果我按后退按钮在这里它退出我的应用程序,而它应该转到它的父活动。
就像
Tab1 - ActivityGroup ; Tab2 - ActivityGroup
ParentActivity1 - ListActivity ParentActivity2 - ListActivity
ChildActivity1 - Activity ChildActivity2 - Activity
现在,当我从 ChildActivity1 转到 Tab2 - ParentActivity2 并返回 Tab1 时,我只能看到 ChildActivity1,如果我按后退按钮,则我的应用程序退出
请帮助
I'm a bit puzzeled, I have an application which has 5 tabs in tabHost. Each tab has an activityGroup, which further has a parent and a child activity. The parent activity contains list of titles and the child activity has the details of those titles. Now, if I move on to another tab in my application from details page and then come back to the same tab in which i was viewing the details, the details are again displayed whereas the parent activity should be shown or if i press back button from here it exits my application whereas it should go to it's parent activity.
It is like
Tab1 - ActivityGroup Tab2 - ActivityGroup
ParentActivity1 - ListActivity ParentActivity2 - ListActivity
ChildActivity1 - Activity ChildActivity2 - Activity
Now when i go from ChildActivity1 to Tab2 - ParentActivity2 and come back to Tab1 i get to see the ChildActivity1 only and if i press back button then my application exits
Please help
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
![扫码二维码加入Web技术交流群](/public/img/jiaqun_03.jpg)
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
看来你的堆栈没有正确管理或清理。
检查您为新活动传递的堆栈选项。
Seems Your stack not managed properly or clearing up .
check what stack option you are passing with intent for new activity .
您需要捕获后退按钮,并调出您想要的活动。就系统而言,我认为它将您的 TabActivity 视为唯一有 BACK 操作的 Activity。
You need to capture the back button, and bring up the activity you want. As far as the system is concerned, I think it treats your TabActivity as the only Activity to have BACK act upon.