android.support.v4.app.FragmentHostCallback.getHandler()' on a null object reference
来源:互联网 发布:three.js 导入obj模型 编辑:程序博客网 时间:2024/06/05 04:23
1. Bug问题所在
- ViewPager为null或者TabLayout为null
2. Bug出现场景
- TabLayout+ViewPager包裹Fragment
- Fragment里面又嵌套了TabLaytou+ViewPager包裹Fragment
- 里层或者外层的Fragment的Adaper继承的是FragmentStatePagerAdaper
3. Bug解决办法
- 里层和外层的Fragment都使用FragmentPagerAdaper(个人测试OK)
- 在Fragment的Adapter中重写以下方法
@Overridepublic void finishUpdate(ViewGroup container) { try{ super.finishUpdate(container); } catch (NullPointerException nullPointerException){ System.out.println("Catch the NullPointerException in FragmentPagerAdapter.finishUpdate"); }}
阅读全文
0 0
- android.support.v4.app.FragmentHostCallback.getHandler()' on a null object reference
- android.support.v7.app.AppCompatActivity.getSupportActionBar()' on a null object reference
- Attempt to read from field 'int android.support.v4.app.Fragment.mContainerId' on a null object refer
- Android NullPointerException FragmentHostCallback.getHandler()
- Android NullPointerException FragmentHostCallback.getHandler()
- Android NullPointerException FragmentHostCallback.getHandler()
- ApplicationThread android.app.ActivityThread.getApplicationThread()' on a null object reference
- [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
- Attempt to invoke virtual method 'void android.app.ActionBar.hide()' on a null object reference
- Attempt to invoke virtual method 'void android.app.ActionBar.hide()' on a null object reference
- android.content.Context.getContentResolver()' on a null object reference错误
- monkey: android viewpager.offset on a null object reference
- 'int android.graphics.Bitmap.getWidth()' on a null object reference
- "on a null object reference"问题解决方案
- on a null object reference 错误
- Attempt to invoke virtual method 'void android.support.v7.app.ActionBar.hide()' on a null object re
- Object android.content.Context.getSystemService(java.lang.String)' on a null object reference
- CNN卷积实现
- [ 面试题 ] 常见面试题 (一)
- 好盈电调使用
- [LeetCode] Palindrome Number
- .ipynb文件的打开方法
- android.support.v4.app.FragmentHostCallback.getHandler()' on a null object reference
- 图文详解PDF与word、excel、ppt互转工具的下载、安装与注册激活
- 简易计算器
- DenseNet算法详解
- java反射
- pygame编写飞机大战(5)-子弹类
- 9月英语总结--日积月累
- 前端之bootstrap-常用类名
- 【模板】高精度阶乘