android.support.v4.app.FragmentHostCallback.getHandler()' on a null object reference
2017-09-24 09:38
579 查看
1. Bug问题所在
ViewPager为null或者TabLayout为null2. Bug出现场景
TabLayout+ViewPager包裹FragmentFragment里面又嵌套了TabLaytou+ViewPager包裹Fragment
里层或者外层的Fragment的Adaper继承的是FragmentStatePagerAdaper
3. Bug解决办法
里层和外层的Fragment都使用FragmentPagerAdaper(个人测试OK)在Fragment的Adapter中重写以下方法
@Override public void finishUpdate(ViewGroup container) { try{ super.finishUpdate(container); } catch (NullPointerException nullPointerException){ System.out.println("Catch the NullPointerException in FragmentPagerAdapter.finishUpdate"); } }
相关文章推荐
- Android NullPointerException FragmentHostCallback.getHandler()
- [Android] android.app.Activity.findViewById(int) on a null object reference
- Attempt to invoke virtual method 'void android.app.ActionBar.hide()' on a null object reference
- ApplicationThread android.app.ActivityThread.getApplicationThread()' on a null object reference
- Android NullPointerException FragmentHostCallback.getHandler()
- Android NullPointerException FragmentHostCallback.getHandler()
- Attempt to invoke virtual method 'void android.app.ActionBar.hide()' on a null object reference
- android.view.View android.view.View.findViewById(int)' on a null object reference
- void android.widget.TextView.setText(java.lang.CharSequence)' on a null object reference
- Android SearchView android.graphics.drawable..Drawable.setState(int[])' on a null object reference
- void android.widget.TextView.setText(java.lang.CharSequence)' on a null object reference
- oid android.widget.ListView.setAdapter(android.widget.ListAdapter)' on a null object reference的解决
- Attempt to read from field 'int android.graphics.Rect.bottom' on a null object reference
- Object android.content.Context.getSystemService(java.lang.String)' on a null object reference
- Android空引用问题的解决方法——on a null object reference
- 'int android.graphics.Bitmap.getWidth()' on a null object reference
- android fragment(android.support.v4.app.Fragment和android.app.Fragment区别)
- Attempt to read from field 'int android.view.View.mViewFlags' on a null object reference
- Attempt to invoke virtual method 'int java.lang.Object.hashCode()' on a null object reference(Fb)
- android fragment(android.support.v4.app.Fragment和android.app.Fragment区别)