日志没有记录ACTION_UP或ACTION_MOVE(我在代码示例中删除了它们以缩短长度)。
以下是我简化后的代码:
public class ProfileBadgeView extends LinearLayout {
Activity act;
public ProfileBadgeView(Context context) {
super(context);
}
public ProfileBadgeView(Context context, AttributeSet attrs) {
this(context, attrs, 0);
}
public ProfileBadgeView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
}
public void initView(Activity act) {
//..init
}
@Override
public boolean onInterceptTouchEvent(MotionEvent ev) {
if (ev.getAction() == MotionEvent.ACTION_DOWN) {
logIntercept("ACTION DOWN");
} else if (ev.getAction() == MotionEvent.ACTION_UP) {
logIntercept("ACTION_UP");
}
return false;
}
@Override
public boolean onTouchEvent(MotionEvent ev) {
return true;
}
private void logIntercept(Object obj) {
Log.i(this.getClass().getSimpleName() + " INTERCEPT :", obj.toString());
}
}