How to make this logic for view pager?

I made a application where I used view pager to create 4 tabs.And use inbuilt floating button to copy tags.but now I want to make a logic for floating button to enable only in a particular tab.And also different on-click logic for floating button

I mean When Tab 1 open copy(floating button) should enable/visible but when Tab3/Tab4 open that time floating button should disable.

Tags tab

Description tab

One way is to detect the page selected by Page Selected event of view pager and then toggle the visibility of FAB based on page selected.

Like for example, when Tab 1 is selected set visibility of FAB to true and when tab3/4 are selected set FAB’s visibility to false


sorry but I can not understand how to make that logic

if(position == 1){
} else if(position == 3 || position == 4){ 

Thanks for help


Hi @pavelalam401
Please mark @Vaibhav 's reply as solution.
I have just simplified his answer.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.