arjoan
arjoan

Reputation: 1849

Providing clickAction to viewPager

I have used the android v4 viewPager widget. I want to go to a different page when i click on the current page of the viewpager. I tried using setOnClickListener. But this action is not being listened. When i use setOnTouchListener, this works but the swipe action disappears!The page is being inflated with a relative layout with textviews Please see the code snippet:

    mInfoPager = (ViewPager)findViewById(R.id.info_pager);
    mInfoPager.setClickable(true);
    mInfoPager = new InfoPagerAdapter(InfoScreen.this,5);
    mInfoPager.setAdapter(mInfoPagerAdapter);

..

    mInfoPager.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {

            //Not coming here??

        }
    });

Upvotes: 1

Views: 1047

Answers (1)

Andreas
Andreas

Reputation: 1617

i suggest you to put the OnClickListener to the Views you put in the ViewPager and call a function in the ViewPager so it can scroll left/right - this may works ;)

Upvotes: 2

Related Questions