i am using page view in android and i view in this page viewer an images.
so i want to make event for on click. however, i call the image from another class like root view and i want the response of event from main class openoptionmenu() so i is there any way to call the event from second class when click the image?

my code for mainactivity

public class ScreenSlideActivity extends FragmentActivity  {

    public static String Pac_name="";
    public static boolean me_r=false;

    private ViewPager mPager;

    private PagerAdapter mPagerAdapter;

    protected void onCreate(Bundle savedInstanceState) {

        // Instantiate a ViewPager and a PagerAdapter.
        mPager = (ViewPager) findViewById(R.id.pager);
        mPagerAdapter = new ScreenSlidePagerAdapter(getFragmentManager());

        if(cu_sura == 0)

        mPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
            public void onPageSelected(int position) {
                // When changing pages, reset the action bar actions since they are dependent
                // on which page is currently active. An alternative approach is to have each
                // fragment expose actions itself (rather than the activity exposing actions),
                // but for simplicity, the activity provides the actions in this sample.



        mPager.setOnTouchListener(new OnTouchListener() {

            public boolean onTouch(View arg0, MotionEvent arg1) {
                // TODO Auto-generated method stub
                return false;



in the place of ++++++ i want to call event of onclick for image in the second class

    public View onCreateView(LayoutInflater inflater, ViewGroup container,
            Bundle savedInstanceState) {
        // Inflate the layout containing a title and body text.
        ViewGroup rootView = (ViewGroup) inflater
                .inflate(R.layout.fragment_screen_slide_page, container, false);

        int num=(mPageNumber -605)*-1;
        String name="p"+num;

        int imgId = getResources().getIdentifier(name, "drawable",com.bilal.read_quran.ScreenSlideActivity.Pac_name );
      //    Bitmap b = BitmapFactory.decodeResource(getResources(), imgId);
        ((ImageView) rootView.findViewById(R.id.imageView1)).setImageResource(imgId);
        ((ImageView) rootView.findViewById(R.id.imageView1)).setOnClickListener(new OnClickListener() {
            public void onClick(View arg0) {
                // TODO Auto-generated method stub
                final Handler mHandler = new Handler();

        // Set the title view to show the page number.
      /*  ((TextView) rootView.findViewById(android.R.id.text1)).setText(
                getString(R.string.title_template_step, mPageNumber + 1));
        return rootView;
  • Create custom listener
  • Register listener with component to receive update info
  • Call listener on touch and pass data to be received by listeneing component
Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.20 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.