基本按照老师编写,虽然没出错,但是就是显示不出来???
public class MainActivity extends Activity {
ListView lv;
SimpleAdapter sa;
List<Map<String, Object>> list;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
lv=(ListView) findViewById(R.id.listView1);
lv.setAdapter(sa);
list=new ArrayList<Map<String,Object>>();
sa=new SimpleAdapter(this, getData(), R.layout.main,
new String[]{"imageView1","textView1"},
new int[]{R.id.imageView1,R.id.textView1});
}
public List<Map<String, Object>> getData(){
for(int i=0;i<11;i++){
Map<String, Object> map=new HashMap<String, Object>();
map.put("imageView1", R.drawable.ic_launcher);
map.put("textView1", "hao"+i);
list.add(map);
}
return list;
}
}