[英]Swipe with Image list view in on item click listener
I am working with Android app to swipe an image from list view. 我正在使用Android应用程序从列表视图中滑动图像。 But I don't know the answer.
但是我不知道答案。 I got values in list view and where clicking an image with item click listener it shown in another intent, I want without going back, show image from top to bottom in list view using swipe method.
我在列表视图中获得了值,并且在单击带有项目单击侦听器的图像时以另一种意图显示了它,我希望不回头,使用滑动方法在列表视图中从上到下显示图像。
请使用RecyclerView而不是listView,因为onTouchlistener在recyclerview而不是listview中会更正确地工作。另外,listview在调整项目位置方面存在问题
add images in array. 在数组中添加图像。
int count=0;
int arr[count];
imageView.setOnTouchListener(new OnSwipeTouchListener(MyActivity.this) {
public void onSwipeRight() {
count++;
img.setResource(arr[count]);
if(count>arr.length-1)
{
count=0;
}
Toast.makeText(MyActivity.this, "right", Toast.LENGTH_SHORT).show();
}
public void onSwipeLeft() {
count--;
img.setResource(arr[count]);
if(count<0)
{
count=arr.length-1;
}
Toast.makeText(MyActivity.this, "left", Toast.LENGTH_SHORT).show();
}
}
});
hope you got the answer 希望你得到答案
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.