Android 中的后退按钮退出应用程序

发布于 2024-11-06 02:53:29 字数 800 浏览 3 评论 0原文

我有点困惑,我有一个应用程序,在 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技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

大海や 2024-11-13 02:53:29

看来你的堆栈没有正确管理或清理。
检查您为新活动传递的堆栈选项。

Seems Your stack not managed properly or clearing up .
check what stack option you are passing with intent for new activity .

苏辞 2024-11-13 02:53:29

您需要捕获后退按钮,并调出您想要的活动。就系统而言,我认为它将您的 TabActivity 视为唯一有 BACK 操作的 Activity。

public boolean onKeyDown(int keyCode, KeyEvent event) 
{
    if ((keyCode == KeyEvent.KEYCODE_BACK))
        // goto parent screen
}

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.

public boolean onKeyDown(int keyCode, KeyEvent event) 
{
    if ((keyCode == KeyEvent.KEYCODE_BACK))
        // goto parent screen
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文