0
當我第一次打開應用程序時,我的標籤工作正常。當我回到片段頁面時,它會返回null。請幫幫我 !我究竟做錯了什麼?這是我的代碼。從活動和轉到標籤分檔返回時,Tabhost在android中返回null
public class TabsFragmentPagerAdapter extends FragmentPagerAdapter {
private ArrayList<ShareWinLeaderBoardTabModel> mShareWinLeaderBoardTabModelList;
public TabsFragmentPagerAdapter(FragmentManager fragmentManager, ArrayList<ShareWinLeaderBoardTabModel> shareWinLeaderBoardTabModelList) {
super(fragmentManager);
mShareWinLeaderBoardTabModelList = shareWinLeaderBoardTabModelList;
}
@Override
public Fragment getItem(int position) {
/*ShareWinLeaderBoardTabModel model = Once that is donemShareWinLeaderBoardTabModelList.get(position);
return new ShareWinLeaderBoardListFragment(model);*/
switch (position) {
case 0:
ShareWinLeaderBoardTabModel model = mShareWinLeaderBoardTabModelList.get(position);
return new ShareWinLeaderBoardListFragment(model);
case 1:
ShareWinLeaderBoardTabModel model1 = mShareWinLeaderBoardTabModelList.get(position);
return new ShareWinLeaderBoardListFragment(model1);
case 2:
ShareWinLeaderBoardTabModel model2 = mShareWinLeaderBoardTabModelList.get(position);
return new ShareWinLeaderBoardListFragment(model2);
case 3:
ShareWinLeaderBoardTabModel model3 = mShareWinLeaderBoardTabModelList.get(position);
return new ShareWinLeaderBoardListFragment(model3);
default:
return null;
}
}
@Override
public int getCount() {
return mShareWinLeaderBoardTabModelList.size();
}
}
當我按回來時,標籤主機有一些問題。標籤正常,但它們顯示空白碎片。任何幫助?
圖片: