Skip to content
Advertisement

How to disable clicks on DotView?

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?

Advertisement

Answer

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.

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement