I have a simple app where the main activity has a FrameLayout that I use to load fragments in to. All fragments all loaded at the same time and I use hide/show to select what fragment to view.
However, when I add a chart to one of the fragments, then it loads fine initially, but if I hide it and then show it again, the app just stops. There isn’t any errors, it just stops responding.
If I remove the graph, everything works fine. Any ideas?
private void addAllFragments()
{
getSupportFragmentManager().beginTransaction()
.add(R.id.mainView, mainScreen, "MainScreen")
.add(R.id.mainView, alarmScreen, "AlarmsScreen")
.hide(alarmScreen)
.commit();
}
private void loadFragment(String id)
{
FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
for(Fragment f : getSupportFragmentManager().getFragments())
{
if(f.getTag() != id)
{
ft.hide(f);
}
else
{
ft.show(f);
}
}
ft.commit();
}
private void loadMainScreen() {
loadFragment("MainScreen");
}
private void loadAlarmsScreen() {
loadFragment("AlarmsScreen");
}
- Thomas Heimann asked 5 years ago
-
Hi Thomas. Can you provide an entire project which reproduces this issue? It would be really helpful.
- You must login to post comments
Please login first to submit.