Skip to content

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

Description

@yudikarma

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();

}

}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions