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 및 사용자 정의보기에 추가합니다.
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에서 터치 이벤트를받을 수 없습니다. 무엇이 부족한가요?
을 setonclicklisener하려고 내 CustomView의 이벤트, AFAIK, 터치 이벤트 리스너가 클릭 리스너보다 먼저 작동합니다! 너는 아무 것도 바뀌지 않을 것이다. 감사합니다 ... –
당신의 터치 이벤트와 함께 사실대로 클릭 가능하도록 설정하려고했습니다. –
시도했지만 아무 것도 변경하지 않았습니다. –