我的导航抽屉有不同的碎片,下图给出了视觉描述。我遇到的问题是当我访问另一个视图,如个人资料视图并返回仪表板视图,仪表板'主页选项卡显示为空,直到我访问其中一个选项卡并返回到它,然后它显示其中的项目。请看第二张图片。我进入监视器的所有内容都是"E/RecyclerView: No adapter attached; skipping layout"
错误。
以下是我的仪表板主页选项卡的代码
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
{
View x = inflater.inflate(R.layout.tablayout, null);
tabLayout = (TabLayout) x.findViewById(R.id.tabs);
viewPager = (ViewPager) x.findViewById(R.id.viewpager);
fragmentList = new ArrayList<>();
prepareDataResource();
titleList();
topLevel rta = new topLevel(getFragmentManager(),fragmentList,titleList);
viewPager.setAdapter(rta);
tabLayout.setupWithViewPager(viewPager);
setTabIcons();
return x;
}
*包含家庭,PTA,事件标签的仪表板片段的代码
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
{
View x = inflater.inflate(R.layout.tablayout, null);
tabLayout = (TabLayout) x.findViewById(R.id.tabs);
viewPager = (ViewPager) x.findViewById(R.id.viewpager);
fragmentList = new ArrayList<>();
prepareDataResource();
titleList();
topLevel rta = new topLevel(getFragmentManager(),fragmentList,titleList);
viewPager.setAdapter(rta);
tabLayout.setupWithViewPager(viewPager);
setTabIcons();
return x;
}