I have a view , my view contains gallery and two button.Here i want to scroll gallery when we click on buttons (just one position),for that i used following code,
this code for next position,
mBtnGalleryNext.setOnTouchListener(new OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
// TODO Auto-generated method stub
mGallery.scrollTo(180, 0);
return false;
}
});
this code for previous position,
mBtnGalleryPrevious.setOnTouchListener(new OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
// TODO Auto-generated method stub
mGallery.scrollTo(0, 180);
return false;
}
});
it is not working properly . please help me.
Instead of using the
scrollTo()method, usesetSelection().If you call it like so:
It will scroll to the next position.