Temporary: Fix menu visibility when restoring state in the pager adapter
When restoring the state of the adapter, all the fragments' menu visibility were set to false, effectively disabling the menu from the user until he switched pages or another event that triggered the menu to be visible again happened. FragmentStatePagerAdapter is deprecated and should be replaced with its ViewPager2 counterpart, until then, this should do it.
This commit is contained in:
parent
c478a4ee4e
commit
2243d21605
2 changed files with 320 additions and 2 deletions
|
|
@ -16,7 +16,7 @@ import androidx.appcompat.app.ActionBar;
|
|||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.fragment.app.FragmentManager;
|
||||
import androidx.fragment.app.FragmentStatePagerAdapter;
|
||||
import androidx.fragment.app.FragmentStatePagerAdapterMenuWorkaround;
|
||||
import androidx.viewpager.widget.ViewPager;
|
||||
|
||||
import com.google.android.material.tabs.TabLayout;
|
||||
|
|
@ -185,7 +185,7 @@ public class MainFragment extends BaseFragment implements TabLayout.OnTabSelecte
|
|||
updateTitleForTab(tab.getPosition());
|
||||
}
|
||||
|
||||
private static class SelectedTabsPagerAdapter extends FragmentStatePagerAdapter {
|
||||
private static class SelectedTabsPagerAdapter extends FragmentStatePagerAdapterMenuWorkaround {
|
||||
private final Context context;
|
||||
private final List<Tab> internalTabsList;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue