how to add a listener to subview
<p>I want to add a listener event to the rotate subview,the code is below, but I really don't know how to do it.
I hope someone can help me about this ,thanks very much.
this is my code:</p>

<pre><code>package com.tony.viewpager;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;

import android.app.Activity;
import android.os.Bundle;
import android.os.Handler;
import android.os.Parcelable;
import android.support.v4.view.PagerAdapter;
import android.support.v4.view.ViewPager;
import android.support.v4.view.ViewPager.OnPageChangeListener;
import android.util.Log;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.View.OnTouchListener;
import android.widget.ImageView;
import android.widget.ImageView.ScaleType;
import android.widget.TextView;

/**
* picture sliding
* 
*/
public class MyViewPagerActivity extends Activity {
private ViewPager viewPager; 
private List imageViews; 

private String[] titles; // image title
private int[] imageResId; 
private List&lt;View&gt; dots; // Picture title text of the point

private TextView tv_title;
private int currentItem = 0; // 

// An ExecutorService that can schedule commands to run after a given delay,
// or to execute periodically.
private ScheduledExecutorService scheduledExecutorService;

// Switch the current display pictures
private Handler handler = new Handler() {
    public void handleMessage(android.os.Message msg) {
        viewPager.setCurrentItem(currentItem);
    };
};

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    imageResId = new int[] { R.drawable.a, R.drawable.b, R.drawable.c, R.drawable.d, R.drawable.e };
    titles = new String[imageResId.length];
    titles[0] = "flower";
    titles[1] = "song";
    titles[2] = "sun";
    titles[3] = "star";
    titles[4] = "moon";

    imageViews = new ArrayList&lt;ImageView&gt;();

    // Initialization image resources
    for (int i = 0; i &lt; imageResId.length; i++) {
        ImageView imageView = new ImageView(this);
        imageView.setImageResource(imageResId[i]);
        imageView.setScaleType(ScaleType.CENTER_CROP);
        imageViews.add(imageView);
    }


    dots = new ArrayList&lt;View&gt;();
    dots.add(findViewById(R.id.v_dot0));
    dots.add(findViewById(R.id.v_dot1));
    dots.add(findViewById(R.id.v_dot2));
    dots.add(findViewById(R.id.v_dot3));
    dots.add(findViewById(R.id.v_dot4));

    tv_title = (TextView) findViewById(R.id.tv_title);
    tv_title.setText(titles[0]);//

    viewPager = (ViewPager) findViewById(R.id.vp);
    viewPager.setAdapter(new MyAdapter());
    // when change the viewPager call the listener
    viewPager.setOnPageChangeListener(new MyPageChangeListener());


}

@Override
protected void onStart() {
    scheduledExecutorService = Executors.newSingleThreadScheduledExecutor();
    // switch pictures every two second
    scheduledExecutorService.scheduleAtFixedRate(new ScrollTask(), 1, 2, TimeUnit.SECONDS);
    super.onStart();
}

@Override
protected void onStop() {
    // stop switch when activity invisible
    scheduledExecutorService.shutdown();
    super.onStop();
}

/**
 * switch task
 * 
 * @author Administrator
 * 
 */
private class ScrollTask implements Runnable {

    public void run() {
        synchronized (viewPager) {
            System.out.println("currentItem: " + currentItem);
            currentItem = (currentItem + 1) % imageViews.size();
            handler.obtainMessage().sendToTarget(); // use Handler switch pictures
        }
    }

}

/**
 * call when the ViewPager state change
 * 
 * @author Administrator
 * 
 */
private class MyPageChangeListener implements OnPageChangeListener {
    private int oldPosition = 0;

    /**
     * This method will be invoked when a new page becomes selected.
     * position: Position index of the new selected page.
     */
    public void onPageSelected(int position) {
        currentItem = position;
        tv_title.setText(titles[position]);
        dots.get(oldPosition).setBackgroundResource(R.drawable.dot_normal);
        dots.get(position).setBackgroundResource(R.drawable.dot_focused);
        oldPosition = position;
    }

    public void onPageScrollStateChanged(int arg0) {
        ;
    }

    public void onPageScrolled(int arg0, float arg1, int arg2) {

    }
}

/**
 * ViewPager adapter
 * 
 * @author Administrator
 * 
 */
private class MyAdapter extends PagerAdapter {

    @Override
    public int getCount() {
        return imageResId.length;
    }

    @Override
    public Object instantiateItem(View arg0, int arg1) {
        ((ViewPager) arg0).addView(imageViews.get(arg1));
        return imageViews.get(arg1);
    }

    @Override
    public void destroyItem(View arg0, int arg1, Object arg2) {
        ((ViewPager) arg0).removeView((View) arg2);
    }

    @Override
    public boolean isViewFromObject(View arg0, Object arg1) {
        return arg0 == arg1;
    }

    @Override
    public void restoreState(Parcelable arg0, ClassLoader arg1) {

    }

    @Override
    public Parcelable saveState() {
        return null;
    }

    @Override
    public void startUpdate(View arg0) {

    }

    @Override
    public void finishUpdate(View arg0) {

    }
}
}

&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;RelativeLayout
    android:layout_width="fill_parent"
    android:layout_height="40dip"
    android:background="@drawable/title_bk" &gt;

    &lt;ImageButton
        android:id="@+id/btn_back"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:background="@drawable/btn_back_selector"
        android:src="@drawable/btn_back" /&gt;

    &lt;View
        android:id="@+id/line0"
        android:layout_width="1px"
        android:layout_height="fill_parent"
        android:layout_toRightOf="@id/btn_back"
        android:background="#aa11264f" /&gt;

    &lt;View
        android:layout_width="1px"
        android:layout_height="fill_parent"
        android:layout_toRightOf="@id/line0"
        android:background="#009ad6" /&gt;

    &lt;TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerInParent="true"
        android:text="client"
        android:textColor="#FFFFFF"
        android:textSize="20sp" /&gt;
&lt;/RelativeLayout&gt;

&lt;FrameLayout
    android:layout_width="fill_parent"
    android:layout_height="140dip" &gt;

    &lt;android.support.v4.view.ViewPager
        android:id="@+id/vp"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent" /&gt;

    &lt;LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="35dip"
        android:layout_gravity="bottom"
        android:background="#33000000"
        android:gravity="center"
        android:orientation="vertical" &gt;

        &lt;TextView
            android:id="@+id/tv_title"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="show name"
            android:textColor="#ffffff" /&gt;

        &lt;LinearLayout
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="3dip"
            android:gravity="center" &gt;

            &lt;View
                android:id="@+id/v_dot0"
                style="@style/dot_style"
                android:background="@drawable/dot_focused" /&gt;

            &lt;View
                android:id="@+id/v_dot1"
                style="@style/dot_style" /&gt;

            &lt;View
                android:id="@+id/v_dot2"
                style="@style/dot_style" /&gt;

            &lt;View
                android:id="@+id/v_dot3"
                style="@style/dot_style" /&gt;

            &lt;View
                android:id="@+id/v_dot4"
                style="@style/dot_style" /&gt;
        &lt;/LinearLayout&gt;
    &lt;/LinearLayout&gt;
&lt;/FrameLayout&gt;
</code></pre>

<p>any help will be appreciated:D</p>
