Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tablayout initialize error after click other fragment then back to tablayout fragment #36

Open
yudikarma opened this issue Oct 31, 2018 · 0 comments

Comments

@yudikarma
Copy link

10-31 23:09:14.749 14194-14194/com.example.alfattah.absensiproject E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.alfattah.absensiproject, PID: 14194
java.lang.IllegalArgumentException: You have 3 tabs.
at eu.long1.spacetablayout.SpaceTabLayout.initialize(SpaceTabLayout.java:266)

and this my code :

public class DashboardFragment extends Fragment {

public DashboardFragment() {
    // Required empty public constructor
}

SpaceTabLayout tabLayout;
List<Fragment> fragmentList = new ArrayList<>();
CheckinFragment checkinFragment = new CheckinFragment();
MapsFragment mapsFragment = new MapsFragment();
CheckOutFragment checkOutFragment = new CheckOutFragment();
ViewPager dashboardViewpager;

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    // Inflate the layout for this fragment
    View  view =  inflater.inflate(R.layout.fragment_dashboard, container, false);
    dashboardViewpager = view.findViewById(R.id.viewPagerdashboard);
    tabLayout = view.findViewById(R.id.spaceTabLayout);

    fragmentList.add(checkinFragment);
    fragmentList.add(mapsFragment);
    fragmentList.add(checkOutFragment);


    tabLayout.initialize(dashboardViewpager, getActivity().getSupportFragmentManager(), fragmentList, savedInstanceState);








    return view;
}

@Override
public void onSaveInstanceState(@NonNull Bundle outState) {
    tabLayout.saveState(outState);
    super.onSaveInstanceState(outState);

}

@Override
public void onStart() {
    super.onStart();

}

}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant