Get scroll value of a ListView

Put problem concerning Views, Layouts and other XML-Resources (like AndroidManifest) here.

Get scroll value of a ListView

Postby tikimove » Tue Nov 17, 2009 5:39 pm

Hi all,

I'm trying to make a new ListView by extending the existing one => MyListView.java, which is supposed to play a sound when the user scrolls it up and down.

Unfortunately, I am not able to get the scroll value : getScrollY() always returns 0. Any idea ?

Thanks for your help

Code :
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. public boolean onTouchEvent(final MotionEvent pEvent) {
  2.  
  3.                 Log.d("SUPPR", "onTouch" + getScrollY()); // ALWAYS 0
  4.  
  5.  
  6.  
  7.                 if (pEvent.getAction() == MotionEvent.ACTION_MOVE) {
  8.  
  9.                         int yScroll = getScrollY();
  10.  
  11.  
  12.  
  13.                         if (this.yPrev != Integer.MAX_VALUE) {
  14.  
  15.                                 int yDiff = Math.abs(this.yPrev - yScroll);
  16.  
  17.                        
  18.  
  19.                                 if (yDiff != 0) {
  20.  
  21.                                         // PLAY SOUND
  22.  
  23.                                 }
  24.  
  25.                         }
  26.  
  27.  
  28.  
  29.                         this.yPrev = yScroll;
  30.  
  31.                 }
  32.  
  33.                 return super.onTouchEvent(pEvent);
  34.  
  35.         }
Parsed in 0.033 seconds, using GeSHi 1.0.8.4
tikimove
Developer
Developer
 
Posts: 30
Joined: Tue Jan 13, 2009 2:59 pm

Top

Postby tikimove » Thu Nov 26, 2009 11:54 am

any help here ?
tikimove
Developer
Developer
 
Posts: 30
Joined: Tue Jan 13, 2009 2:59 pm

Top

Return to View, Layout & Resource Problems

Who is online

Users browsing this forum: No registered users and 8 guests