BUG日志:
UncaughtHandler: TinkerUncaughtHandler catch exception:java.lang.IllegalStateException: The application's PagerAdapter changed the adapter's contents without calling PagerAdapter#notifyDataSetChanged! Expected adapter item count: 5, found: 1 Pager id: com.ddd.app:id/moduleViewpager Pager class: class com.ddd.app.util.MyViewPager Problematic adapter: class com.ddd.app.widget.adapter.TabAdapter
at android.support.v4.view.ViewPager.populate(ViewPager.java:1137)
at android.support.v4.view.ViewPager.populate(ViewPager.java:1086)
at android.support.v4.view.ViewPager.onMeasure(ViewPager.java:1616)
at com.xy0.app.util.MyViewPager.onMeasure(MyViewPager.java:34)
at android.view.View.layout(View.java:20915)
at android.view.ViewGroup.layout(ViewGroup.java:6276)
at android.support.constraint.ConstraintLayout.onLayout(ConstraintLayout.java:1915)
at android.view.View.layout(View.java:20928)
at android.view.ViewGroup.layout(ViewGroup.java:6276)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:325)
at android.widget.FrameLayout.onLayout(FrameLayout.java:261)
at android.widget.ScrollView.onLayout(ScrollView.java:1595)
at android.view.View.layout(View.java:20928)
at android.view.ViewGroup.layout(ViewGroup.java:6276)
at com.scwang.smartrefresh.layout.impl.RefreshContentWrapper.layout(RefreshContentWrapper.java:182)
at com.scwang.smartrefresh.layout.SmartRefreshLayout.onLayout(SmartRefreshLayout.java:722)
at android.view.View.layout(View.java:20928)
at android.view.ViewGroup.layout(ViewGroup.java:6276)
at android.support.constraint.ConstraintLayout.onLayout(ConstraintLayout.java:1915)
at android.view.View.layout(View.java:20928)
at android.view.ViewGroup.layout(ViewGroup.java:6276)
at android.support.v4.view.ViewPager.onLayout(ViewPager.java:1769)
at android.view.View.layout(View.java:20928)
at android.view.ViewGroup.layout(ViewGroup.java:6276)
at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1842)
at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1686)
at android.widget.LinearLayout.onLayout(LinearLayout.java:1595)
at android.view.View.layout(View.java:20928)
at android.view.ViewGroup.layout(ViewGroup.java:6276)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:325)
at android.widget.FrameLayout.onLayout(FrameLayout.java:261)
at android.view.View.layout(View.java:20928)
at android.view.ViewGroup.layout(ViewGroup.java:6276)
at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1842)
at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1686)
at android.widget.LinearLayout.onLayout(LinearLayout.java:1595)
at android.view.View.layout(View.java:20928)
at android.view.ViewGroup.layout(ViewGroup.java:6276)
TinkerUncaughtHandler catch exception:java.lang.IllegalStateException: The application's PagerAdapter changed the adapter's contents without calling PagerAdapter#notifyDataSetChanged! Expected adapter item count: 1, found: 5 Pager id: com.ddd.app:id/moduleFourViewpager Pager class: class com.dd.libcommon.widget.NoScrollViewPager Problematic adapter: class com.ddd.app.widget.adapter.OrderTabAdapter
解决办法:
以前的代码
mFragments.add(HomeFourFragment.instance(JSON.toJSONString(themeBean)));
moduleFourViewpager.setAdapter(new OrderTabAdapter(getFragmentManager(), mFragments, null));
moduleFourViewpager.setOffscreenPageLimit(1);
解决办法: 在下拉刷新的时候,调用下面的代码,清掉数据
private void clearDisplay() {
mFragments.clear();
moduleViewpager.setAdapter(new TabAdapter(getChildFragmentManager(), mFragments, null));
moduleViewpager.setVisibility(View.GONE);
moduleFourViewpager.setAdapter(new OrderTabAdapter(getFragmentManager(), mFragments, null));
moduleFourViewpager.setVisibility(View.GONE);
llMenu.setVisibility(View.GONE);
ll_four_top.setVisibility(View.GONE);
llFourMenu.setVisibility(View.GONE);
ll_three_module.setVisibility(View.GONE);
tabLayout.setVisibility(View.GONE);
ll_two.setVisibility(View.VISIBLE);
rl_favoritr.setVisibility(View.VISIBLE);
ivNotice.setImageResource(R.mipmap.ddddddd);
}