<div id="scid:9D7513F9-C04C-4721-824A-2B34F0212519:0c8ad334-6609-4c3f-91dd-00eda8ed4860" class="wlWriterEditableSmartContent" style="float: none; padding-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px"><pre class="brush: java; gutter: true; first-line: 1; tab-size: 4; toolbar: true; width: 640px; height: 511px;" style=" width: 640px; height: 511px;overflow: auto;">package com.example.toucheventtest;
import android.content.Context; import android.util.AttributeSet; import android.util.Log; import android.view.KeyEvent; import android.view.MotionEvent; import android.widget.LinearLayout;
public class TouchView extends LinearLayout{
public TouchView(Context context, AttributeSet attrs) {
super(context, attrs);
}
@Override
public boolean dispatchKeyEvent(KeyEvent event) {
Log.i("test","dispatchKeyEvent");
return super.dispatchKeyEvent(event);
}
@Override
public boolean dispatchTouchEvent(MotionEvent ev) {
Log.i("test","dispatchTouchEvent");
return super.dispatchTouchEvent(ev);
}
@Override
public boolean onInterceptTouchEvent(MotionEvent ev) {
Log.i("test","onInterceptTouchEvent");
return super.onInterceptTouchEvent(ev);
}
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
Log.i("test","onKeyDown");
return super.onKeyDown(keyCode, event);
}
@Override
public boolean onTouchEvent(MotionEvent event) {
Log.i("test","onTouchEvent");
return super.onTouchEvent(event);
}
} </pre><!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin. http://dunnhq.com --></div>
<p> <div id="scid:9D7513F9-C04C-4721-824A-2B34F0212519:3e11d691-9bba-40e3-88c4-6bc3c90022d5" class="wlWriterEditableSmartContent" style="float: none; padding-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px"><pre class="brush: java; gutter: true; first-line: 1; tab-size: 4; toolbar: true; width: 638px; height: 529px;" style=" width: 638px; height: 529px;overflow: auto;">package com.example.toucheventtest;
import android.content.Context; import android.util.AttributeSet; import android.util.Log; import android.view.KeyEvent; import android.view.MotionEvent; import android.widget.LinearLayout;
public class TouchViewSub extends LinearLayout{
public TouchViewSub(Context context, AttributeSet attrs) {
super(context, attrs);
}
@Override
public boolean dispatchKeyEvent(KeyEvent event) {
Log.i("test","dispatchKeyEvent TouchViewSub");
return super.dispatchKeyEvent(event);
}
@Override
public boolean dispatchTouchEvent(MotionEvent ev) {
Log.i("test","dispatchTouchEvent TouchViewSub");
return super.dispatchTouchEvent(ev);
}
@Override
public boolean onInterceptTouchEvent(MotionEvent ev) {
Log.i("test","onInterceptTouchEvent TouchViewSub");
return super.onInterceptTouchEvent(ev);
}
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
Log.i("test","onKeyDown TouchViewSub");
return super.onKeyDown(keyCode, event);
}
@Override
public boolean onTouchEvent(MotionEvent event) {
Log.i("test","onTouchEvent TouchViewSub");
return super.onTouchEvent(event);
}
} </pre><!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin. http://dunnhq.com --></div>
</p>
<p> </p>
<div id="scid:9D7513F9-C04C-4721-824A-2B34F0212519:2bd43dd7-f8f9-42a7-b7cd-a6e7fbad16b9" class="wlWriterEditableSmartContent" style="float: none; padding-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px"><pre class="brush: xml; gutter: true; first-line: 1; tab-size: 4; toolbar: true; width: 638px; height: 529px;" style=" width: 638px; height: 529px;overflow: auto;"><RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingBottom="@dimen/activity_vertical_margin" android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin" android:paddingTop="@dimen/activity_vertical_margin" tools:context=".MainActivity" >
<com.example.toucheventtest.TouchView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<com.example.toucheventtest.TouchViewSub
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="aaaaaaaaaaaaaaaaaaaa" />
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="aaaadddfdfdfdfdfddf" />
</com.example.toucheventtest.TouchViewSub>
</com.example.toucheventtest.TouchView>
</RelativeLayout></pre><!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin. http://dunnhq.com --></div>
<p><a href="http://static.oschina.net/uploads/img/201305/23103242_axQQ.png"><img title="截图1369276273" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; border-left: 0px; display: inline; padding-right: 0px" border="0" alt="截图1369276273" src="http://static.oschina.net/uploads/img/201305/23103242_wOoI.png" width="624" height="94" /></a></p>