Tested on Nexus One running 2.2.1.
Keep no change on the MultiTouchView.java in "Detect Multi touch on custom View".
Modify main.xml to include two MultiTouchView.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<com.exercise.AndroidTouch.MultiTouchView
android:id="@+id/mtv1"
android:layout_width="fill_parent"
android:layout_height="200dp"
/>
<com.exercise.AndroidTouch.MultiTouchView
android:id="@+id/mtv2"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
/>
</LinearLayout>
Modify AndroidTouch.java to set them in different background color.
package com.exercise.AndroidTouch;
import android.app.Activity;
import android.graphics.Color;
import android.os.Bundle;
public class AndroidTouch extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
MultiTouchView multiTouchView1 = (MultiTouchView)findViewById(R.id.mtv1);
MultiTouchView multiTouchView2 = (MultiTouchView)findViewById(R.id.mtv2);
multiTouchView1.setBackgroundColor(Color.WHITE);
multiTouchView2.setBackgroundColor(Color.GRAY);
}
}
Download the files.
No comments:
Post a Comment