long1eu / long1eu/SpaceTabLayout
tablayout initialize error after click other fragment then back to tablayout fragment
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 1.6k
- Forks
- 265
- PR merge metrics
- No merged PRs in 30d
Description
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 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();
}
}
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at SpaceTabLayout.java:266 and inspect how initialize handles the three fragments supplied by DashboardFragment. Reproduce the flow by opening another fragment and returning to the tab layout, then verify that initialization completes without the “You have 3 tabs” exception.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- android, java
- Domain
- mobile
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100