为什么图片不显示?
package com.example.listviewTest;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import android.app.Activity;
import android.os.Bundle;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.SimpleAdapter;
public class MainActivity extends Activity {
private ListView listview;
private ArrayAdapter<String> arr_adapter;
private SimpleAdapter simp_adapter;
private List<Map<String,Object>> datalist;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
listview = (ListView) findViewById(R.id.listView);
//1\建立数据源
//2\新建一个适配器
//3\引入数据源
String[] str = {"我爱你!","我爱你!","我爱你!","我爱你!","我爱你!","我爱你!","我爱你!","我爱你!","我爱你!","我爱你!"};
datalist = new ArrayList<Map<String,Object>>();
arr_adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, str);
simp_adapter = new SimpleAdapter(this, getData(), R.layout.item, new String[] {"pic", "text"}, new int[]{R.id.image, R.id.text});
//listview.setAdapter(arr_adapter);
listview.setAdapter(simp_adapter);
}
private List<Map<String,Object>> getData(){
for(int i=0;i<20;i++){
Map<String, Object> map = new HashMap<String, Object>();
map.put("image", R.drawable.ic_launcher);
map.put("text", "刘艺霖"+i+"岁啦!");
datalist.add(map);
}
return datalist;
}
}