android - Why does my app show the content from the wrong tab? -
i have got problem tabs of app. have got 3 tabs , set second tab 1 shown whenever app started code:
getactionbar().setselectednavigationitem(1);
after used command app started tab wanted, showed me content of first tab (so content was: tab 2 + overlay content tab1)
after manually switched problematic tab tab whoms content shown , content normal again.
has idea how fix this?
public class tablistener <t extends fragment> implements actionbar.tablistener{ private final activity myactivity; private final string mytag; private final class myclass; public tablistener(activity activity, string tag, class<t> cls) { myactivity = activity; mytag = tag; myclass = cls; } @override public void ontabselected(actionbar.tab tab, fragmenttransaction ft) { fragment myfragment = myactivity.getfragmentmanager().findfragmentbytag(mytag); if (myfragment == null) { myfragment = fragment.instantiate(myactivity, myclass.getname()); ft.add(android.r.id.content, myfragment, mytag); } else { ft.attach(myfragment); } } @override public void ontabunselected(actionbar.tab tab, fragmenttransaction ft) { fragment myfragment = myactivity.getfragmentmanager().findfragmentbytag(mytag); if (myfragment != null) { ft.detach(myfragment); } } @override public void ontabreselected(actionbar.tab tab, fragmenttransaction ft) { // todo auto-generated method stub } }
Comments
Post a Comment