程序一直崩溃,问题出在那?
public class MainActivity extends ActionBarActivity {
private ListView lv;
private ArrayAdapter<String> arr_adp;
private SimpleAdapter sim_adp;
private List<Map<String,Object>> list;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.sactivity);
String[] str={"lt1","lt2","lt3","lt4","lt5"};
//lv=(ListView)findViewById(R.id.listView1);
arr_adp=new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, str);
//lv.setAdapter(arr_adp);
lv=(ListView)findViewById(R.id.textView1);
list=new ArrayList<Map<String,Object>>();
sim_adp=new SimpleAdapter(this, getData(), R.layout.sactivity, new String[]{"imageView1","textView1"}, new int[]{R.id.imageView1,R.id.textView1});
lv.setAdapter(sim_adp);
}
private List<Map<String,Object>> getData(){
for(int i=0;i<20;i++){
Map<String, Object> map=new HashMap<String, Object>();
map.put("imageView1",R.drawable.ic_launcher);
map.put("textView1", "LT帅炸天"+i);
list.add(map);
}
return list;
}
}