How to Handle Switch Button When build on Actionbar Android Studio

66 Views Asked by At

Some items of the action bar item were to be shown in the some fragment (which is the switch button), if Switch Button state is changed, the same layout then goes forward and then comes back then it comes to its initial state.enter image description here

1

There are 1 best solutions below

0
Javad A salehi On

You can use the sharedpreferences for save state of switch button and then checked it value as the fragment page has changed.

https://developer.android.com/reference/android/content/SharedPreferences

https://www.journaldev.com/9412/android-shared-preferences-example-tutorial