android - 将滑块解锁视图添加到列表视图
我试图将滑动视图(类似于储物柜屏幕上的“滑动解锁”)放入 listView 的所有项目中。 然而,尽管它本身工作得很好,但我遇到了两个问题:
1.有时,整行都变黑了。我认为这是一个选择问题,所以我使用了: this.setSelector(color.transparent); 对于 listView 本身,但它无助于修复它。
2.当将视图拖动到项目(包含它)之外时,除了“ACTION_CANCEL”之外,我无法捕获更多触摸事件,因此我唯一能做的就是在发生时将其返回到原始位置。我想做的是允许触摸事件甚至在视图之外发生。
这些错误发生在模拟器和真实设备上。
有人可以帮忙吗?
好的,我已经找到了答案:
对于 1:
为列表视图添加此行:
this.setCacheColorHint(0);
对于 2: 为列表视图添加这些行:
@Override
public boolean onInterceptTouchEvent(final MotionEvent ev)
{
return false;
}
i'm trying to put a sliding view (similar to the "slide-to-unlock" on locker screens) into all of a listView's items .
however , even though it worked fine on its own , i get 2 problems:
1.sometimes, the entire row is becoming black . i thought it was a selection issue , so i used:
this.setSelector(color.transparent);
for the listView itself, but it didn't help fixing it.
2.when dragging the view outside of the item (which contains it) , i can't capture any more touch events besides "ACTION_CANCEL" , so the only thing i can do is to return it to its original position right when it occurs . what i want to do is to allow touch events to occur even outside of the view .
those bugs occur on both the emulator and real devices.
can anyone please help?
ok, i've found out the answers:
for 1:
add this line for the listview:
this.setCacheColorHint(0);
for 2:
add those lines for the listview:
@Override
public boolean onInterceptTouchEvent(final MotionEvent ev)
{
return false;
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
第一个答案在 xml 的 listview 中设置为
First answer is set in listview in xml as