Created
June 13, 2014 19:51
-
-
Save BlaShadow/10da21d7b7b96005d31f to your computer and use it in GitHub Desktop.
Scroll list view into scrollview
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ListView lv = (ListView)findViewById(R.id.myListView); // your listview inside scrollview | |
lv.setOnTouchListener(new ListView.OnTouchListener() { | |
@Override | |
public boolean onTouch(View v, MotionEvent event) { | |
int action = event.getAction(); | |
switch (action) { | |
case MotionEvent.ACTION_DOWN: | |
// Disallow ScrollView to intercept touch events. | |
v.getParent().requestDisallowInterceptTouchEvent(true); | |
break; | |
case MotionEvent.ACTION_UP: | |
// Allow ScrollView to intercept touch events. | |
v.getParent().requestDisallowInterceptTouchEvent(false); | |
break; | |
} | |
// Handle ListView touch events. | |
v.onTouchEvent(event); | |
return true; | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment