Error汇总之Android学习篇(持续更新)

1、cannot resolve symbol R

resolved: a)包名com.halcyon.Calculator在修改为小写,即com.halcyon.calculator时,拼写错误

                    b)如果确定没有错误,执行File-->Invalidate caches/Restart  ,一般可以解决。

 

2、 java.lang.NullPointerException at onCreateView()

       android.view.InflateException

       cannot resolve method findById(int)

resolved:    a)在Fragment中使用,源码为(Button)findViewById(R.id.btn),报错,后改为(Button)view.findViewById(R.id.btn)后,无编译错误


3、libpng err: Read Error

resolved:   a)如果图片是非png图片是通过直接修改后缀强行变为png图片的,改用转换工具把非png转成png

                      b)检查图片的分辨率,是否跟文件夹(drawable、mipmap)对应的分辨率一致


4、使用substring 出现 IndexOutOfBoundException  异常   

resolved: 首先,在API中的描述如下:public String substring(int start,int end)   Returns a new string containing the characters from start to end - 1。
Throws indexOutOfBoundsException  if start<0,strat >end or  end > length()。
所以,应检查程序运行中是否会出现以上起始标签start为小于零,或者大于终止标签,同时,终止标签不能大于String的长度。

5、Your content must have a ListView whose id attribute is 'android.R.id.list' 

resolved:可能是因为我们要实现对ListView中setOnItemClick的事件监听而去继承了LiseActivity,但是却没有ListView的标签,只要在布局文件中添加定制Layout的代码,
即将ListView的id设置为“@android:id/list”或android:id="@id/android:list",这时可以用getListView来获取ListView的对象了。

6、java.lang.NullPointerException
resolved:在使用一个声明的变量前,请确保它已经被初始化,且值不是null。
 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值