Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to disable/ lock one page in viewpager?

I want lock / disable one particular page(fragment) in viewpager. According to scenario for some people only able to access that page. How restrict swiping to that page.

enter image description here

I disabled tab click for Events page by using following code :

    LinearLayout tabStrip = ((LinearLayout)tabLayout.getChildAt(0));
if(!isAccess){
            tabStrip.getChildAt(3).setClickable(false);
            tabStrip.getChildAt(3).setEnabled(false);
}

But now I need to restrict swiping for that page in view pager. How to do this?

like image 756
Naveen Kumar M Avatar asked Mar 11 '23 23:03

Naveen Kumar M


1 Answers

I written this in pager adapter it works.

@Override
public int getCount() {
  if(!isAccess) {
    return 3;
  } else {
    return 4;
  }
}
like image 172
Naveen Kumar M Avatar answered Mar 21 '23 08:03

Naveen Kumar M