0

I am working with Android app to swipe an image from list view. 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.

halfer
  • 19,824
  • 17
  • 99
  • 186
Jincy
  • 115
  • 1
  • 1
  • 13

2 Answers2

0

Use RecyclerView instead of listView because onTouchlistener will work more properly in recyclerview rather than listview.additionally listview have issue with adapting item position

Harmantj
  • 182
  • 2
  • 11
  • Do you animate image from top to bottom??I am unable to understand this part of your question – Harmantj Jan 23 '17 at 06:58
  • no. I got images from my server in a recycler view and also i use on item click listener. it also working i need to see previous image or next image using swipe – Jincy Jan 23 '17 at 07:04
  • http://stackoverflow.com/questions/4139288/android-how-to-handle-right-to-left-swipe-gestures – Harmantj Jan 23 '17 at 07:20
0

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

Harmantj
  • 182
  • 2
  • 11