1 ListView中的Item内有button或chckable等,这时item焦点就会被抢去,解决方案:
在Item文件中,根目录设置:
android:descendantFocusability="blocksDescendants"
在item文件中,button按钮中设置:
android:focusable="false"
2 ListView与scroolView的滑动问题:解决方案:
自定义listView如MylistView去继承listview
在MylistView类中,添加如下方法:
public boolean onInterceptTouchEvent(MotionEvent ev) {
// TODO Auto-generated method stub
switch (ev.getAction()) {
case MotionEvent.ACTION_DOWN:
setParentScrollAble(false);// 当手指触到listview的时候,让父ScrollView交出ontouch权限,也就是让父scrollview
case MotionEvent.ACTION_MOVE:
break;
case MotionEvent.ACTION_UP:
case MotionEvent.ACTION_CANCEL:
setParentScrollAble(true);// 当手指松开时,让父ScrollView重新拿到onTouch权限
break;
default:
break;
}
return super.onInterceptTouchEvent(ev);
}
private void setParentScrollAble(boolean flag) {
view.requestDisallowInterceptTouchEvent(!flag);// 这里的parentScrollView就是listview外面的那个scrollview
}
public void setView(ScrollView view) {
this.view = view;
}