0
我在我的相对布局中有自定义视图和EditText元素,我无法在自定义视图中接收触摸事件,如何将触摸事件传播到我的自定义视图中;EditText事件传播
我的布局看起来像;
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/white" >
<com.test.ui.CustomView
android:id="@+id/noteView"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<EditText
android:id="@+id/etPageInput"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="top" />
</RelativeLayout>
我添加触摸侦听器到我的EditText和Custom视图,就像;
EditText pageInput = (EditText) findViewById(R.id.etPageInput);
pageInput.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
return false;
}
});
CustomView pageView = (CustomView) findViewById(R.id.noteView);
pageView.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
System.out.println("Touch event received by custom view !!!")
return true;
}
});
我不能够接收触摸事件在我的CustomView,任何想法,我失去了什么?
我猜你没明白我的意思,我不关心点击事件我只需要接收触摸我的CustomView上的事件,也是AFAIK,触摸事件侦听器比单击侦听器更有效!你的建议不会改变任何事情。谢谢... – 2014-11-24 18:13:59
你尝试设置点击为真正与您的触摸事件 – 2014-11-24 18:19:33
我试过了,它没有改变任何东西。 – 2014-11-24 18:20:32