ViewPager和OnItemClickListener中的ListView [英] ViewPager and OnItemClickListener in ListView

查看:387
本文介绍了ViewPager和OnItemClickListener中的ListView的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在创造一个轻扫到解雇列表视图适配器。我的基本方法是包装列表项的看法,如在ViewPager第二种观点,并提供了ViewPager的项目更改侦听器所需的回调。通过多痛苦我已经得到了实现查看回收工作的打算,以及ViewHolder和ViewBinder模式。我甚至设法保持在ListView接管的触摸事件,而ViewPager被滚动而无需进行ListView控件的自定义子类(我可以从适配器做这一切)。

I'm working on creating a swipe-to-dismiss list view adapter. My basic methodology is to wrap the list item's view as the second view in a ViewPager and provide the necessary callbacks in the item change listener of the ViewPager. Through much pain I've got the View recycler working as intended, as well as ViewHolder and ViewBinder patterns implemented. I even managed to keep the ListView from taking over the touch events while the ViewPager is being scrolled without having to make a custom subclass of ListView (I can do it all from the Adapter).

在那里我遇到了麻烦越来越选择和 OnItemClickListener 工作。细算ListView的来源似乎是通过覆盖ViewPager的hasFocusable()方法总是返回false(后来我拉从孩子的视野这个值)这些事情应该被重新启用。不幸的是这不是这种情况。我已经试过了 setDecendantFocusability()的解决方法,我仍然坚持。

Where I'm running into trouble is getting the selector and the OnItemClickListener to work. After looking at ListView's source it seemed that by overriding the ViewPager's hasFocusable() method to always return false (later on I'll pull this value from the child view) these things should have been reenabled. Unfortunately this is not the case. I've tried the setDecendantFocusability() workaround and I'm still stuck.

我想,以避免延长的ListView如果可能的话,提供模块化的最大金额。出于类似的原因,我不想给选择添加到ViewPager的背景(如果dev的更改ListView的选择,这将不会被反射的)。基本上我正在寻找使ListView和子视图之间的ViewPager code透明。任何想法?

I'd like to avoid having to extend ListView if possible to provide the greatest amount of modularity. For similar reasons I don't want to add the selector to the ViewPager's background (if the dev changes the ListView's selector this wouldn't be reflected). Essentially I'm looking to make the ViewPager code transparent between the ListView and child View. Any ideas?

推荐答案

您是说您做每个项目视图寻呼机,这样就可以实现刷卡删除?如果是的话......不,不,这不是什么看法寻呼机的用途。第一抱歉它只是不旨在用作列表中的一个项目。其次它是视图之间切换,不刷卡删除。

You are saying that you are making each list item a view pager, so that you can implement swiping to delete? If so... no no, this is not what view pager is for. First sorry it is just not intended to be used as an item in a list. Second it is for switching between views, not swiping to delete.

不幸的是,我们没有一个样品code来说明如何做到这一点,但你可以看看该平台的实施通知窗格或近期应用程序来得到一些想法的。

Unfortunately we don't have a sample code to show how to do this, but you can look at the platform's implementation of the notification pane or recent apps to get some ideas.

这篇关于ViewPager和OnItemClickListener中的ListView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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