DialogFragment行为不同,当通过动作条调用不同、行为、动作、DialogFragment

2023-09-12 22:04:01 作者:没有填写用户名

我遇到陌生,或许是特定版本的与我DialogFragment子类的行为测试下面的步骤时:

I'm experiencing strange, perhaps version-specific behavior with my DialogFragment subclass when testing the following steps:

(1)打开对话框 (2)离开与任Home键或最近的应用程序键应用程序 (3)返回到应用程序,和对话不再可见。它的似乎的简单,主要活动背后的半透明可见。 (4)旋转的装置,并在对话框再次出现。

(1) Open the dialog (2) Leave the app with either the Home key or the Recent Apps key (3) Return to the app, and the dialog is no longer visible. It seems to be briefly, translucently visible behind the main activity. (4) Rotate the device, and the dialog re-appears.

这个错误发生在运行Android 4.2.1我的华硕TF700T垫,而且它的没有的出现在我的摩托罗拉RAZR手机运行Android 4.1.2(其中有一个菜单键,而不是一个溢出按钮)。此外,它的只有的发生,如果通过溢出菜单打开的对话​​框 - 对话框通过动作条项目打开不会出现此问题!最后,这个问题并不重要,如果你做的方向发生变化的在的暂停活动。

This bug occurs on my Asus TF700T pad running Android 4.2.1, and it does not occur on my Motorola Razr phone running Android 4.1.2 (which has a menu key rather than an overflow button). Moreover, it only occurs if the dialog is opened via the overflow menu - dialogs opened via ActionBar items do not exhibit this issue! And finally, the issue does not occur if you do an orientation change before pausing the activity.

我已经找到了very 这类似的问题,包括去pressing的评论,如这显然是一个Android的错误。有相关错误报告。请说出来是不是这样?

I have found a very similar issue which includes depressing comments like "This is clearly an Android bug." There are associated bug reports. Please, say it ain't so...

我解决此问题在onResume():我查FragmentManager现有对话与findFragmentByTag;如果有任何不为空我解雇和重新显示它们。但我想明白什么是真正回事。

My workaround for this issue is in onResume(): I check the FragmentManager for existing dialogs with findFragmentByTag; if any are not null I dismiss and re-show them. But I'd like to understand what's really going on here.

推荐答案

我想,这个问题的答案是上面链接的谷歌错误报告。我改变了我的设计,避免了问题,所以我没有尝试过的解决办法某人那里已经发布。

I guess the answer to this question is the Google bug report linked above. I changed my design to avoid the problem, so I have not tried the workaround someone there has posted.