Attempt to invoke virtual method 'void com.loopj.android.image.SmartImageView.setImageUrl(java.l
曾无好事来相访,赖尔高文一起予。这篇文章主要讲述Attempt to invoke virtual method '
void com.loopj.android.image.SmartImageView.setImageUrl(java.l相关的知识,希望能为你提供帮助。
使用ListView的适配器时报错:
java.lang.NullPointerException: Attempt to invoke virtual method ‘void com.loopj.android.image.SmartImageView.setImageUrl(java.lang.String, java.lang.Integer, java.lang.Integer)‘ on a null object reference
出错代码:
1 View view1 = View.inflate(MainActivity.this, R.layout.news_item, null); 2 SmartImageView siv_icon = findViewById(R.id.siv_icon); 3 TextView tv_title = findViewById(R.id.tv_title); 4 TextView tv_description = findViewById(R.id.tv_description); 5 TextView tv_type = findViewById(R.id.tv_type);
正确代码:
1 View view1 = View.inflate(MainActivity.this, R.layout.news_item, null); 2 SmartImageView siv_icon = view1.findViewById(R.id.siv_icon); 3 TextView tv_title = view1.findViewById(R.id.tv_title); 4 TextView tv_description = view1.findViewById(R.id.tv_description); 5 TextView tv_type = view1.findViewById(R.id.tv_type); 6
【Attempt to invoke virtual method ' void com.loopj.android.image.SmartImageView.setImageUrl(java.l】虽然第一种代码在编译器里并不会报错,但是在app开启时就会发生闪退
推荐阅读
- Android Studio 使用真机调试——打开手机开发者模式
- 基于mui的H5套壳APP开发web框架
- 安卓四级级联下拉框效果实现
- 团队冲刺第四天-KeepRunningAPP
- C#----Automatic question application
- 3. 动态代理Mapper实现类(官方推荐方式)
- 摩拜单车app解锁测试点分析
- uniapp位操作
- uni-app同步缓存值 设置 读取删除