开发者社区> 问答> 正文

代码没有报错但是程序一运行就崩溃

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);
   }
}

这段代码没有报错但是运行时程序崩溃了

展开
收起
爵霸 2016-06-07 14:35:26 2378 0
1 条回答
写回答
取消 提交回答
  • 可以把crash log贴上来看看。
    粗看下来,price和imageIds是直接把数组放进去了,和上面的代码不一致。

    2019-07-17 19:30:06
    赞同 展开评论 打赏
问答分类:
问答地址:
问答排行榜
最热
最新

相关电子书

更多
15分钟打造你自己的小程序 立即下载
小程序 大世界 立即下载
《15分钟打造你自己的小程序》 立即下载