I'm trying to get the code here to work. It compiles fine. It will run. And it will load tab 1 (of 3). However, when I click on the 2nd or 3rd tab, I get this:
java.lang.NoSuchMethodError: android.app.FragmentTransaction.detach
this happens in the code here
public void onTabUnselected(Tab tab, FragmentTransaction ft) {
if (mFragment != null) {
//ft.detach(mFragment); //requires API Level 13
ft.remove(mFragment); //this does not do the same thing as detach
}
}
I found that detach is only available to API Level 13. I tried remove, but it doesn't do the same thing, obviously. Does anyone have any ideas about how to overcome this based on the code in the first link?
EDIT:
I guess the same goes for attach as that's also in the code, but doesn't get hit before the app crashes.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…