如何去除背堆栈片段的焦点? [英] How to remove the focus of the back stack fragment?

查看:175
本文介绍了如何去除背堆栈片段的焦点?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在应用程序中使用片段。我有一个包含 EditText 和一些 Dialogfragment 的片段。

当我点击一个特定的小部件时,它会移动到下一个片段。我需要在后台的第一个片段,所以我也添加了addToBackStack方法。

第二个片段不包含任何 EditText 。现在的问题是,当我们触摸或按第二个片段时,第一个片段中的 EditText 获得焦点,对话框即将到来。



我得到了下面的代码:

$ get $()。setFocusableInTouchMode真正);
getView()。requestFocus();

我将它放在 onResume()中。但是 onResume()不会根据一些android文档被调用。我该怎么办?这是显示问题的第二个活动的图片


解决方案

解决方案我的问题是,而不是添加片段只是使用替换和一件事情,我们可以避免通过点击布局还


I am using fragments in my application.I have a fragment that contains EditText and some Dialogfragment.

When i click one particular widget it will move to next fragment. I need the first fragment in the backstack,so i added addToBackStack method also.

The second fragment doesn't contain any EditText. Now the problem is, when we touch or press the second fragment, EditText in the first fragment get the focus and the dialogs are coming.

I got the following code

getView().setFocusableInTouchMode(true);
getView().requestFocus();

I placed this in onResume(). But onResume() will not be called according to some android documents. What I should I do? This is the picture of the second activity that shows the problem

解决方案

Solution to my question is instead of adding the fragment just use replace and one more thing we can avoid that by giving click to the layout also

这篇关于如何去除背堆栈片段的焦点?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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