'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?
Solution 1:[1]
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);
Solution 2:[2]
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.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | |
| Solution 2 |
