// 今天解决了一个BUG,找了几天终于知道问题的所在,特此记录,以作同学参考。
// 时间:2017年10月30日23:48:26

异常:
Android.content.res.Resources$NotFoundException:Resourece ID #0x7f0b0033 type #0x12 is not valid异常

出现异常:

注意这句:
Android.content.res.Resources$NotFoundException:Resourece ID #0x7f0b0033…
表明资源文件出现了错误,以后看到这个直接去看R文件对应的资源:

AS切换到Project视图,R文件一般位于:包名—build----generated—source—r---debug—R

发现是list_item这个资源为空,回到代码一看:

SimpleAdapter simpleAdapter = new SimpleAdapter(this,data,R.id.list_item,map_keys,listItem_ids);ListView listView = (ListView)findViewById(R.id.listView);listView.setAdapter(simpleAdapter);

其中SimpleAdapter的参数应该是:

SimpleAdapter simpleAdapter = new SimpleAdapter(Context context,List<? extends Map<String, ?>> data,int resource, String[] from, int[] to)

例如:SimpleAdapter adapter = new SimpleAdapter(this, data, R.layout.list_item, keys, ids);

坑爹的AS自动填充代码功能啊!!!!
原来resource这个参数填的是资源文件的R.layout的id,不是R.id.xxx啊!!!!
排查了几天的bug终于解决了,心中一疼!!!

初学安卓,出现资源文件找不到的异常,记录于此,给遭遇同个bug的同学一个参考。

更多相关文章

  1. mybatisplus的坑 insert标签insert into select无参数问题的解决
  2. NPM 和webpack 的基础使用
  3. Python技巧匿名函数、回调函数和高阶函数
  4. 【阿里云镜像】使用阿里巴巴DNS镜像源——DNS配置教程
  5. python list.sort()根据多个关键字排序的方法实现
  6. 读取android手机流量信息
  7. android 使用html5作布局文件: webview跟javascript交互
  8. Android(安卓)多媒体扫描过程(Android(安卓)Media Scanner Proces
  9. android“设置”里的版本号

随机推荐

  1. android 开发的步骤
  2. Android(安卓)自定义角标
  3. Android添加单元测试的方法与步骤
  4. android常遇错误
  5. Android(安卓)Studio第十三期 - RecycleV
  6. android CTS测试
  7. android命令行打包、签名+自动打包器
  8. android菜单
  9. Android(安卓)调用地图显示信息
  10. Android(安卓)SDK 在线更新镜像服务器资