Save and Restore state of Selected list of RecycleView in fragment on TabLayout or ViewPager

Add This Line To viewPager:-

viewPager = (ViewPager) findViewById(;

Here 4 is the Number of Tabs.
If you have 3 tabs change to :-

viewPager = (ViewPager) findViewById(;


Popular posts from this blog

Android Studio 3.5 or above usb device not detected in Android Studio or Unable to detect adb version, exit value: 0xc0000135. ADB depends on the Windows Universal C Runtime, which is usually installed by default via Windows Update. You may need to manually fetch and install the runtime package here:

Lint found fatal errors while assembling a release target.

ViewModelProviders.of(this) is deprecated what to use instead ViewModelProviders.of(this) OR if you don't want to use ViewmodelFactory OR ViewModelProviders error.