Android 当用户持有项目时,在recyclerview中展开和折叠项目
我有个问题 我试图在循环视图中创建一个元素,当您单击并按住某个项目时,该元素将展开该元素并显示一些数据 我使用onLongClickListener来实现这一点,但是当用户停止触摸按钮时,元素会进一步扩展Android 当用户持有项目时,在recyclerview中展开和折叠项目,android,android-recyclerview,Android,Android Recyclerview,我有个问题 我试图在循环视图中创建一个元素,当您单击并按住某个项目时,该元素将展开该元素并显示一些数据 我使用onLongClickListener来实现这一点,但是当用户停止触摸按钮时,元素会进一步扩展 当用户停止握住某个项目时,我必须如何折叠该项目?onTouchEvent执行您想要的操作: public boolean onTouchEvent(MotionEvent event) { int eventAction = event.getAction(); // you may ne
当用户停止握住某个项目时,我必须如何折叠该项目?
onTouchEvent
执行您想要的操作:
public boolean onTouchEvent(MotionEvent event) {
int eventAction = event.getAction();
// you may need the x/y location
int x = (int)event.getX();
int y = (int)event.getY();
// put your code in here to handle the event
switch (eventAction) {
case MotionEvent.ACTION_DOWN:
break;
case MotionEvent.ACTION_UP:
break;
case MotionEvent.ACTION_MOVE:
break;
}
// tell the View to redraw the Canvas
invalidate();
// tell the View that we handled the event
return true;
}
如果你想阅读更多,你可以检查和链接