public class WareShow extends Activity {
private String[] bookname = new String[]{"从你的全世界路过","59秒的转动","心理罪","肖申克的救赎","疯狂Android讲义"};
private String[] penname = new String[]{"张嘉佳","周语","雷米","斯蒂芬","李刚"};
private String[] price = new String[]{"32¥","38¥","29¥","56¥","35¥"};
private int[] imageIds = new int[]{R.drawable.bg_01,
R.drawable.bg_04,
R.drawable.bg_02,
R.drawable.bg_05,
R.drawable.bg_03};
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.book);
List<Map<String,Object>> listItem = new ArrayList<Map<String,Object>>();
for (int i = 0; i < bookname.length; i++) {
Map<String, Object> listItem1 = new HashMap<String,Object>();
listItem1.put("book", bookname[i]);
listItem1.put("pen", penname[i]);
listItem1.put("money", price);
listItem1.put("image", imageIds);
}
SimpleAdapter simpleAdapter = new SimpleAdapter(this,listItem,R.layout.book,new String[]{"book","pen","money","image"},new int[]{R.id.imageIds,R.id.tv1,R.id.tv2,R.id.tv3});
ListView listView = (ListView) findViewById(R.id.lv1);
listView.setAdapter(simpleAdapter);
}
}
这段代码没有报错但是运行时程序崩溃了
可以把crash log贴上来看看。
粗看下来,price和imageIds是直接把数组放进去了,和上面的代码不一致。
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。