Dar*_*hak 12 android listview scroll scrollview android-activity
我这样做在Android 1.6和2.2 ...
我在Activity中有一个ScrollView(ScrollView中的所有内容)......
第二个是活动中的一个ListView ....
当我滚动ListView时,那时ScrollView正在滚动,但ListView的Scroll无效 ...
我提供了我所遇到的问题 ......
如果有人有此解决方案,请分享...
kyo*_*ogs 33
这里parentScroll =您的主滚动视图和childScroll =您的列表视图
parentScroll.setOnTouchListener(new View.OnTouchListener() {
public boolean onTouch(View v, MotionEvent event) {
Log.v("PARENT", "PARENT TOUCH");
findViewById(R.id.child_scroll).getParent()
.requestDisallowInterceptTouchEvent(false);
return false;
}
});
childScroll.setOnTouchListener(new View.OnTouchListener() {
public boolean onTouch(View v, MotionEvent event) {
Log.v("CHILD", "CHILD TOUCH");
// Disallow the touch request for parent scroll on touch of
// child view
v.getParent().requestDisallowInterceptTouchEvent(true);
return false;
}
});
Run Code Online (Sandbox Code Playgroud)
svView.setOnTouchListener(new 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;
}
});
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
7232 次 |
最近记录: |