点击从内MergeAdapter项目的看法事件滚动后才解雇 [英] Click events from views inside MergeAdapter items only fired after scrolling

查看:278
本文介绍了点击从内MergeAdapter项目的看法事件滚动后才解雇的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前使用 CWAC合并在我的应用程序,我现在面临的一个问题

I'm currently using cwac-merge in my app and I'm facing an issue.

所以我有这样的ListView不同的部分。在第一批或静态视图添加到MergeAdapter。他们是直接添加,而不启用/禁用它们。

So I have this listview with different parts. The first ones or static views added to the MergeAdapter. They are directly added without activating/deactivating them.

然后我加入其他适配器到我的 MergeAdapter 和隐藏它们与 SETACTIVE直线距离()。这些都是前 listView.setAdapter异步充满倒是(适配器)。所以我这样做每个适配器:

Then I'm adding other adapters to my MergeAdapter and hiding them straight away with setActive(). These are filled asynchronously but added before listView.setAdapter(adapter). So I'm doing this for each adapter:


  1. 适配器添加到 MergeAdapter adapter.addAdapter(subAdapter)

  2. 隐藏它与 adapter.setActive(subAdapter,FALSE)

  3. 当数据提取,添加检索项目到subAdapter, subAdapter.addItems(项目),然后显示具有转接适配器。 SETACTIVE(subAdapter,真)

  1. add the adapter to the MergeAdapter with adapter.addAdapter(subAdapter)
  2. hide it with adapter.setActive(subAdapter, false)
  3. when the data is fetch, add the retrieved items to the subAdapter, subAdapter.addItems(items) and then show the adapter with adapter.setActive(subAdapter, true)

一切工作完美,但有一点我的看法是好看。我从 MergeAdapter 上方意见得到了几个按钮。点击行为是错误的。有时点击事件得到滚动的ListView 后才开火。我注意到,如果我与 SETACTIVE()功能发挥它才会发生。如果我评论每个 SETACTIVE()通话,这个问题不能再现。
如果我点击多次,然后滚动,因为很多点击被解雇了。

Everything is working perfectly and my view is looking good except one thing. I've got a few buttons in the top views from the MergeAdapter. The click behaviour is wrong. Sometimes the click events get only fired after scrolling the ListView. I've noticed it only happen if I play with the setActive() function. If I comment every setActive() calls, the issue can't be reproduced. If I click multiple times then scroll, as many clicks are fired.

下面是一些截图。静态视图图像,并与4个按钮的观点。然后动态的部分是后适配器(传记,上次播放的和最佳的轨道)

Here is some screenshots. The static views are the image and the view with the 4 buttons. Then the dynamic part is the adapters after (biography, last played on and best tracks)

更新:
我已经成功地(在某种程度上)通过激活他们每个人的呼叫后subAdapter.notifyDatasetChanged()修复它。它仍然哈克并不起作用每一次。

UPDATE: I've managed to (sort of) fix it by calling subAdapter.notifyDatasetChanged() after activating each of them. It's still hacky and doesn't work every time.

更新:
我想这应该由图书馆涵盖鉴于:

UPDATE: I think this should be covered by the library given that:

请注意,虽然,你可以修改基本适配器。因此对于
  例如,如果你的CursorAdapter添加到MergeAdapter,你
  重新查询()光标时,改变应该通过得到体现
  MergeAdapter到任何适配器视图的MergeAdapter连接。

Note, though, that you can modify the underlying adapters. So, for example, if you add a CursorAdapter to the MergeAdapter, and you requery() the Cursor, the changes should be reflected via the MergeAdapter to whatever AdapterView the MergeAdapter is connected to.


推荐答案

这个问题实际上是具体到我的项目。当内容物被取出并填充,我是显示包含在进度条隐藏内容的画面。当我展示的内容,当数据被检索进行碰撞的一个瞬间。技术上, setVisibility(可见)屏幕视图是在一个糟糕的时间发生的 mergeadapter.setActive()命令。

The issue was actually specific to my project. While the content was being fetched and filled, I was showing a screen containing a ProgressBar over the hidden content. The moment when I was showing the content and the one when the data was retrieved were colliding. Technically, the setVisibility(VISIBLE) on the screen view was happening at a bad time with the mergeadapter.setActive() command.

总之,美好的时光!由于@CommonsWare

Anyway, good times! Thanks @CommonsWare

这篇关于点击从内MergeAdapter项目的看法事件滚动后才解雇的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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