android 怎么让一个父视图屏蔽其所有子视图的焦点
android 如何让一个父视图屏蔽其所有子视图的焦点
如一个LinearLayout内包含一个button 一个 listview
如何点击或者touch事件时 屏蔽button 点击事件 listview点击事件和滑动事件
------解决方案--------------------
不知道重写public boolean dispatchTouchEvent (MotionEvent ev)方法行不行。
------解决方案--------------------
这是layout的ontouch函数返回true应该就可以了。
------解决方案--------------------
自己定义一个LinearLayout,重写onInterceptTouchEvent(MotionEvent ev),返回true
------解决方案--------------------
可以参考下如下的连接,分发处理的流程 通过图片说明 比较详细
http://www.cnblogs.com/kingcent/archive/2011/03/08/1977064.html
如一个LinearLayout内包含一个button 一个 listview
如何点击或者touch事件时 屏蔽button 点击事件 listview点击事件和滑动事件
Android
------解决方案--------------------
不知道重写public boolean dispatchTouchEvent (MotionEvent ev)方法行不行。
------解决方案--------------------
这是layout的ontouch函数返回true应该就可以了。
------解决方案--------------------
自己定义一个LinearLayout,重写onInterceptTouchEvent(MotionEvent ev),返回true
package com.example.switcherbutton;
import android.content.Context;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.widget.LinearLayout;
public class MyLinearLayout extends LinearLayout {
public MyLinearLayout(Context context) {
super(context);
}
public MyLinearLayout(Context context, AttributeSet attrs) {
super(context, attrs);
}
/**
* 重写这个方法,返回true就行了
*/
@Override
public boolean onInterceptTouchEvent(MotionEvent ev) {
// TODO Auto-generated method stub
return true;
}
}
------解决方案--------------------
可以参考下如下的连接,分发处理的流程 通过图片说明 比较详细
http://www.cnblogs.com/kingcent/archive/2011/03/08/1977064.html