Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/215.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/selenium/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 当用户持有项目时,在recyclerview中展开和折叠项目_Android_Android Recyclerview - Fatal编程技术网

Android 当用户持有项目时,在recyclerview中展开和折叠项目

Android 当用户持有项目时,在recyclerview中展开和折叠项目,android,android-recyclerview,Android,Android Recyclerview,我有个问题 我试图在循环视图中创建一个元素,当您单击并按住某个项目时,该元素将展开该元素并显示一些数据 我使用onLongClickListener来实现这一点,但是当用户停止触摸按钮时,元素会进一步扩展 当用户停止握住某个项目时,我必须如何折叠该项目?onTouchEvent执行您想要的操作: public boolean onTouchEvent(MotionEvent event) { int eventAction = event.getAction(); // you may ne

我有个问题

我试图在循环视图中创建一个元素,当您单击并按住某个项目时,该元素将展开该元素并显示一些数据

我使用onLongClickListener来实现这一点,但是当用户停止触摸按钮时,元素会进一步扩展


当用户停止握住某个项目时,我必须如何折叠该项目?

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;
}

如果你想阅读更多,你可以检查和链接