0

I had implemented a custom Gallery with custom Adapter. My Requirement is that however fast or slow does the user operates fling on the gallery only one item should change in the gallery. I tried to override the Gallery's onFling method

@Override
public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX,
    float velocityY) {
//Log.e("VELOCITY ORIGINAL", ""+velocityX);
if (velocityX > 500) {//moving left
    velocityX = 500.0f;
}else if(velocityX < -500){//moving right
    velocityX = -500.0f;
}
//Log.e("VELOCITY MODIFIED", ""+velocityX);
return super.onFling(e1, e2, velocityX, velocityY);
}

But this did not produce desired results as sometimes it would flick one item and some times it won't.

Then I tried

@Override
public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
    return false;
}

But this completely disabled fling operation.

What could be the solution?

Mohammed Azharuddin Shaikh
  • 41,633
  • 14
  • 96
  • 115
Ankit
  • 4,426
  • 7
  • 45
  • 62

1 Answers1

0

For that you have to override the onFling method in the Gallery class Try this and just Use ExtendedGallery instead of Gallery

Mohammed Azharuddin Shaikh
  • 41,633
  • 14
  • 96
  • 115
KK_07k11A0585
  • 2,381
  • 3
  • 26
  • 33
  • @hotveryspicy what is OP ??? and what's wrong in suggeting an idea to extend Gallery ? – KK_07k11A0585 Jun 19 '12 at 11:52
  • OP refer to `original poster`, Here custom Gallery is same what you referring and OP itself overriding `onFLing()` you can see in question, he mention that "Then I tried..." – Mohammed Azharuddin Shaikh Jun 19 '12 at 11:54
  • @hotveryspicy I understood that. he is returning **false** ....that's y fling is disabled comlpetely . Instead of that we have to check one condition ... that is what i have posted in the paste bin .. I don't understand what is the mistake in suggesting him that . – KK_07k11A0585 Jun 19 '12 at 11:57
  • OK, I am rolling back but let OP decide whether your condition will do his job or not, but I think it will not. – Mohammed Azharuddin Shaikh Jun 19 '12 at 12:01
  • @hotveryspicy i already done this all he want's is to stop the fling i mean to fling one item at a time. Who knows may be you are right in another case if he wants to fling as per user operation, then it will not work. Let's see whether he got what he wanted or not ... :) – KK_07k11A0585 Jun 19 '12 at 12:04