Unable to decode stream: java.io.FileNotFoundException: 虎头:
来源:互联网 发布:网络推广都做些什么 编辑:程序博客网 时间:2024/04/30 08:10
今天学习ListView组件时,由于该组件需要搭配Adapter使用,当使用SimpleAdapter时,运行时提示错误“Unable to decode stream: java.io.FileNotFoundException: 虎头:”,网上的解决办法有重写Adapter类的,有重写SimpleAdapter类中的setViewImage方法的,试了下重写setViewImage方法,遗憾没成功(不知道什么原因)-----汗颜------。搁置一旁,改尝试另一个小案例,正巧该案例也是用到SimpleAdapter,而且运行时没提示错误。这才又仔细看了一遍先前的代码,发现原来是创建SimpleAdapter时的传入的‘组件ID’参数顺序有问题。
贴出代码:
public class MainActivity extends Activity {
private String[] name = new String[] { "虎头", "弄玉", "李清照", "小白" };
private String[] descs = new String[] { "可爱的小孩", "擅长音乐的女孩", "擅长文学的女性",
"浪漫主义诗人" };
private int[] imageIds = new int[] { R.drawable.btn1, R.drawable.btn2,
R.drawable.btn3, R.drawable.btn4 };
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
List<Map<String, Object>> listItems = new ArrayList<Map<String, Object>>();
for (int i = 0; i < name.length; i++) {
Map<String, Object> listitem = new HashMap<String, Object>();
listitem.put("header", imageIds[i]);
listitem.put("personame", name[i]);
listitem.put("desc", descs[i]);
listItems.add(listitem);
}
SimpleAdapter simpleAdapter = new SimpleAdapter(this, listItems,
R.layout.simple_item, new String[] { "header", "personame",
"desc" },
new int[] { R.id.name, R.id.header, R.id.desc});//这里R.id.name与R.id.header的顺序反了。
ListView list = (ListView) findViewById(R.id.lv);
list.setAdapter(simpleAdapter);
}
}
- Unable to decode stream: java.io.FileNotFoundException: 虎头:
- Unable to decode stream: java.io.FileNotFoundException: /android.graphics.Bitmap open failed: ENOEN
- java.io.FileNotFoundException翻译
- java.io.FileNotFoundException
- HessianRuntimeException: java.io.FileNotFoundException
- java.io.filenotfoundexception: ... .jar
- Struts2 java.io.FileNotFoundException
- java.io.FileNotFoundException
- java.io.FileNotFoundException
- 第一篇博客——BitmapFactory Unable to decode stream 问题解决
- 上传文件 时FileNotFoundException:java.io.FileNotFoundException
- java 读取excel 文件 Unable to recognize OLE stream 错误
- java 读取excel 文件 Unable to recognize OLE stream 错误
- java 读取excel 文件 Unable to recognize OLE stream 错误
- java 读取excel 文件 Unable to recognize OLE stream 错误 .
- java 读取excel 文件 Unable to recognize OLE stream 错误
- java 读取excel 文件 Unable to recognize OLE stream 错误
- java 读取excel 文件 Unable to recognize OLE stream 错误
- Android中JNI使用基本步骤
- python---格式化字符
- 边框border属性总结
- fullpage插件的使用
- iOS:GIF图片的预览以及生成
- Unable to decode stream: java.io.FileNotFoundException: 虎头:
- Mac 批量删除 .svn 文件
- 2016腾讯北京安全技术岗一面总结
- AngularJs 失去焦点事件
- 原来是传说中的2038问题
- Linux系统C语言读写文件总结 (一)
- 创建和管理表空间
- iOS中GIF的制作的简单版本记录
- centos7 mysql安装