Open maoxiandemeng opened 8 years ago
具体的异常信息。。哪行代码。。
继承你写的那个Fragment重写一个方法,得到的view一直是空,不知道啥情况,愣是没看出来
java.lang.NullPointerException: You should call ScrollableHelper.setCurrentScrollableContainer() to set ScrollableContainer. at com.lzy.widget.HeaderScrollHelper.isTop(HeaderScrollHelper.java:55) at com.lzy.widget.HeaderViewPager.computeScroll(HeaderViewPager.java:227) at android.view.View.updateDisplayListIfDirty(View.java:14174) at android.view.View.getDisplayList(View.java:14209) at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3390) at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3369) at android.view.View.updateDisplayListIfDirty(View.java:14147) at android.view.View.getDisplayList(View.java:14209) at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3390) at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3369) at android.view.View.updateDisplayListIfDirty(View.java:14147) at android.view.View.getDisplayList(View.java:14209) at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3390) at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3369) 应该和我的异常时一样,就是demo报的这个错,偶现
@jeasonlzy0216
@xiaqiuming 同这位兄弟一模一样的问题,偶发性~
这个问题是因为activity回收了之后,fragment重建了。 if (savedInstanceState != null) { HomeFragment = (NewsFragment) getSupportFragmentManager().findFragmentByTag(MyFragmentPagerAdapter.makeFragmentName(viewPager.getId(), 0)); } else { HomeFragment = new NewsFragment(); } 这里的MyFragmentPagerAdapter是拷贝的PagerAdapter的源码,只是为了把makeFragmentName(),这个方法变为public的 这样做避免重复的建framgment,也可以重写onSaveInstanceState,不保存状态,就不用去找fragment了 @Override protected void onSaveInstanceState(Bundle outState) { // super.onSaveInstanceState(outState); } @maxlzw12 @maoxiandemeng
这个问题解决了吗,我也是这个问题。更新tabs和fragments就会出现这个问题
fragment里面嵌套fragment 外面的fragment销毁了,里面的也随之销毁,这个时候滑动,就会报空指针异常,接口类里面只只能了getView ,应该加一个setView
You should call ScrollableHelper.setCurrentScrollableContainer() to set ScrollableContainer. 按照你说的写的 我设置了这个属性,还报这个错误