-
Notifications
You must be signed in to change notification settings - Fork 48
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
遇到个bug #30
Comments
各自点击两次后就不能响应点击事件了??? 你是想说在 activity 监听的 livedata 无法接受到点击事件吧。 |
activity 包含两个fragment ,需要共享 activity 的 ViewModel 的,才可以进行通信,这部分内容详见 Google 文档: https://developer.android.com/topic/libraries/architecture/viewmodel?hl=zh-cn#sharing |
我在按钮的点击监听中断点,每个按钮就前两次响应了点击,后面就没反应了,两个fragment都是共享的activity的viewmodel。 然后就是我测试了下官方的使用方式,发现可以正常响应 |
方便贴一下 activity 和 fragment 点击相关的代码吗? |
Activity
ViewModel
Fragment 1
Fragment 2
}` 按钮
|
按照你的例子,我写了一个,我这边可以正常切换的, 以下写法 java 和 kotlin ViewBindActivity.kt
ViewBindFragment.kt
LoginFragment.kt
|
你这儿的addFragment(fragment)里面每次都是给的一个新的对象,不给新的对象就不行。 |
问题【点击两次后就不能响应点击事件了】 这里,为了方便,我这是根据demo 里面的代码改的,只要能接受到消息,执行显示隐藏就可以了,我这里点击了很多次,都是正常的 |
我看你的代码里面
如果只是切换显示的话,不用调用 replease, 调用 show 和 hide 即可 |
场景: 一个activity,监听viewmodel中的livedata,两个fragment,两个fragment中都有一个按钮,点击就会通过viewmodel切换显示。 发现各自点击两次后就不能响应点击事件了
The text was updated successfully, but these errors were encountered: