monkey: android viewpager.offset on a null object reference
来源:互联网 发布:淘宝网钻石展位 编辑:程序博客网 时间:2024/05/18 02:08
这个是跑全模块 monkey , android 原生日历出现的一个问题
错误定位到这里, 意思是 viewpager.offset 为null? 看了代码 offset 只是一个int,为了标示当前第几页的
然后又细细对整体代码,生命周期分析
fragment 生命周期( 专门写一个 fragment的详细文章备忘)
onAttach
onCreate
onCreateView
onActivityCreated
onStart
onResume
基本控制的 初始化 都是在 onCreateView
但是在他的 fragment 中, 他在 onAttach 中调用了一些方法(这些方法 会调用 控件做一些事情)
如果是在正常情况下, 这个生命周期,前面都是很快的,直接到 onCreateView
但是在 内存消耗及大,线程占用率高时, 系统反应速度就会慢,
在 onAttach 做一些事情,关系到 viewpager 的时候,此时 viewpager 还为null (未进入到onCreateView findviewbyid— 初始化)
导致空指针,
修改原声方案, 将 onAttach 中左的事情, 移到 onCreateView 加载完成布局后
规避方案, 判断是否 为null
阅读全文
0 0
- monkey: android viewpager.offset on a null object reference
- android.content.Context.getContentResolver()' on a null object reference错误
- ApplicationThread android.app.ActivityThread.getApplicationThread()' 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 错误
- Object android.content.Context.getSystemService(java.lang.String)' on a null object reference
- [Android] android.app.Activity.findViewById(int) on a null object reference
- android.widget.LinearLayout.addView(android.view.View)' on a null object reference
- oid android.widget.ListView.setAdapter(android.widget.ListAdapter)' on a null object reference的解决
- Android SearchView android.graphics.drawable..Drawable.setState(int[])' on a null object reference
- android.view.View android.view.View.findViewById(int)' on a null object reference
- Attempt to read from field 'int android.view.View.mViewFlags' on a null object reference
- field 'int android.view.View.mViewFlags' on a null object reference
- Attempt to read from field 'int android.view.View.mViewFlags' on a null object reference
- Attempt to invoke virtual method 'void android.app.ActionBar.hide()' on a null object reference
- Attempt to read from field 'int android.view.View.mViewFlags' on a null object reference
- void android.widget.TextView.setText(java.lang.CharSequence)' on a null object reference
- Ironic Key Technologies--PXE网络引导
- Android通过JDBC连接MySql数据库
- Android 通过iptables修改到指定主机的路由信息
- Oracle分页
- Android Support兼容包(兼容问题总结)
- monkey: android viewpager.offset on a null object reference
- MYBATIS- 入门实例
- Kotlin笔记(九)——语法拾遗
- 飞行器制导控制课程设计
- BDFF 2017大数据金融论坛8月23-24日上海举行!
- 轻量级框架Spring的管理代码耦合之道
- 自响应式企业网站源码MVC源码
- 键、索引、约束及其区别
- POJ