Android에서 만든 뷰에 OnTouchListener를 설정하려고했습니다. Activity를 확장하는 MainActivity 클래스와 View를 확장하는 drawView 클래스가 필요합니다.OnTouchListener를 자신이 만든 뷰로 설정하십시오.
내 주 활동은 OnTouchListener를 구현하고 drawView를 인스턴스화했습니다. 그것은 잘 동작하지만 drawView.setOnTouchListener(MainActivity.this)
효과가 없습니다. 내 drawView
에 OnTouchListener
을 구현하고 DrawView.this.setOnTouchListener(this)
을 설정하면 정상적으로 작동하지만 내 MainActivity에 있어야합니다. 내 MainActivity에서
일부 코드 :
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
requestWindowFeature(Window.FEATURE_NO_TITLE);
Display display = getWindowManager().getDefaultDisplay();
drawView = new DrawView(this);
setContentView(R.layout.canvas);
drawView.setOnTouchListener(this);
일부 코드 내 canvas.xml에서 :
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<package.DrawView android:id="@+id/drawView" android:layout_width="fill_parent" android:layout_height="fill_parent" />
</LinearLayout>
아이디어가 사람을 했습니까?
최고의 소원 파비안