为什么后退按钮穆蒂标签活动未检测? [英] Why Back button is not detecting in muti tab activities?

查看:155
本文介绍了为什么后退按钮穆蒂标签活动未检测?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我主要活动。这有4个标签( TabHost )。我已重写 onBack $ P $(PSS)在MainActvity,以及所有4活动。此按钮显示用户对话框和出口的结构
当应用程序启动。这表明第一个标签。然后,如果我preSS回到它正常工作。但是如果我去未来3选项卡,然后preSS回来,该应用程序停止。 的OnDestroy()主要的被调用。但没有对user.Even指出对话打印日志猫。我已经写在 onBack pressed()方法从5活动,包括 MainActivity

I have Main Activity. That has 4 tabs(TabHost). I have overridden onBackPress() in MainActvity , as well As All 4 activities. This button show user a dialog box and for conformation of Exit When app start. It show 1st tab. Then if I press back it work fine. But if I go for next 3 tab and then press back, The app stop. OnDestroy() of Main is called. But there is not dialogue for the user.Even noting is print in log cat. That I have written in onBackPressed() method From and of 5 activities including MainActivity.

我也尝试的onkeydown()为返回键,但结果是一样的吗?有任何一个经历一样吗?请帮我。

I have also try onKeyDown() for back key but result is same? Have any one experience the same? Please help me.

推荐答案

我才知道那是困难的,当我使用TabHost打开previous标签里面新的活动。我谷歌一下,发现GroupActivity针对此问题的最佳解决方案。
GroupActvity例
但GroupActivity有同样的问题时,在previous标签中打开新的活动。后退按钮不是新活动正常工作。搜索后,我发现,是由于重点是alwasys于父活动。我必须做出

I come to know it was difficult to open new activity inside the previous tabs when I am using TabHost. I google it and found GroupActivity is the best solution for this problem. GroupActvity Example But GroupActivity have the same problem when open new activity in the previous tab. the back button not work properly for new activity. After search I found that was due to the focus was alwasys on parent activity. I have to make

setFocusable(真);
  requestFocus()方法;

setFocusable(true); requestFocus();

在我的新活性成分以获得重点。

on my new activity component to gain focus.

我现在用GroupActivity定制的TabBar和activities.As我也マ维护父活动活动ID的堆栈,这样我可以弹出最近的活动时,用户preSS后退按钮。

I am now using GroupActivity for customizing Tabbar and activities.As I ma also maintaining stack of activity ids in parent activity so that I can pop out the recent activity when user press back button.

否则,如果你不打算执行活动的重点则应该保持在父母)堆栈时preSS后退按钮就会启动父onBack pressed(;并且可以调用子onBack pressed()功能中的链接进行讨论。

else if you are NOT going to implement Activity focus then you should maintain stack in parent and when press the back button it will initiate parent onBackPressed(); and you can call the child onBackPressed() functionality as discussed in the link.

<一个href=\"http://stackoverflow.com/questions/6289906/onback$p$pssed-not-working-inside-activitygroup\">onBack$p$pssed()里面的ActivityGroup

这篇关于为什么后退按钮穆蒂标签活动未检测?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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