-2

I am using a custom view from here. I want to disable user interactions with the view pager 2 using this:

binding.viewPager2.setUserInputEnabled(false);

But, it moves when I click on a dot of that view. I tried to disable that using this:

binding.dotsView.setEnabled(false);

But, that does not seem to work.

Then how can we disable clicks on it?

Sambhav Khandelwal
  • 3,585
  • 2
  • 7
  • 38

2 Answers2

1

Library uses setOnClickListener internally to enables the click listener. Use below line.

binding.dotsView.setOnClickListener(null)

So, a null click listener can be set to disable future clicks. After setting the view to a null click listener.

Umesh P
  • 228
  • 2
  • 7
0

I found it. I had to give many properties and then it got disabled:

binding.dots.setDotsClickable(false);
binding.dots.setOnClickListener(null);
binding.dots.setEnabled(false);
binding.dots.setClickable(false);
Sambhav Khandelwal
  • 3,585
  • 2
  • 7
  • 38