SimpleAdapter

 

SimpleAdapter

public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        ListView lv = (ListView) findViewById(R.id.listView1);
        String[] from = { "Text", "Button" };
        int[] to = { R.id.text, R.id.button };
        List<Map<String, ?>> list = new ArrayList<Map<String, ?>>();
        for (int i = 0; i < 10; i++) {
            Map<String, String> m = new HashMap<String, String>();
            m.put("Text", "Text" + i);
            m.put("Button", "Button" + i);
            list.add(m);
        }
        SimpleAdapter adapter = new SimpleAdapter(this, list, R.layout.listitem, from, to);
        lv.setAdapter(adapter);
}

 

posted on 2015-05-21 16:04  rojas  阅读(151)  评论(0编辑  收藏  举报