Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fragment 由于 使用了 getView().setClickable(true) 引出的问题。 #766

Closed
trycatchx opened this issue Feb 2, 2018 · 6 comments
Closed

Comments

@trycatchx
Copy link

由于 getView().setClickable(true) ,我的 getLayoutId 里面的布局的控件并没有设置点击的 监听。但是在点击屏幕的时候,控件的 state_pressed 仍然被响应。这是为什么呢?

@trycatchx
Copy link
Author

我把 在 initData 做了 getView().setClickable(false); 处理,就正常了。不过这样子就有 点击事件穿透问题?这个要怎么破?

 @Override
    public void initData(Bundle savedInstanceState) {

        getView().setClickable(false);  
initViews();
        getP().getExtNetWorkConfig();
    }

@YoKeyword
Copy link
Owner

state_pressed 被响应后导致了什么副作用?

你可以在确保上个Fragment被hide后再setClickable(false),这样就可以解决所有问题

@trycatchx
Copy link
Author

我看到 SupportFragment 在 onActivityCreated 进行 setClickable(true) ,然后并没有在上一个fragment hide 的时候再进行 setClickable(false)回来。

@YoKeyword
Copy link
Owner

@zhangchaojiong setClickable(true)的目的是防止加载下一个Fragment动画中的穿透问题,所以理论上在动画结束时,再把setClickable(原值)即可, 之前尝试过这么做,后来忘记什么原因放弃了,下一版会尝试把clickable恢复

@YoKeyword YoKeyword added the todo label Feb 26, 2018
@trycatchx
Copy link
Author

OK

@YoKeyword
Copy link
Owner

v1.3.0

@YoKeyword YoKeyword removed the todo label Apr 14, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants