码迷,mamicode.com
首页 > 其他好文 > 详细

SimpleAdapter用法

时间:2017-02-02 22:54:47      阅读:218      评论:0      收藏:0      [点我收藏+]

标签:get   oncreate   log   sts   test   hot   http   add   turn   

SimpleAdapter用法

  

public class TestSimpleAdapter extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.testsimpleadapter);
        mListView = (ListView) findViewById(R.id.mySimpleList);
        mAdapter = new SimpleAdapter(this, getData(), R.layout.simpleitem, new String[]{"image", "title", "info"}, new int[]{R.id.img, R.id.title, R.id.info});
        mListView.setAdapter(mAdapter);
    }
    
    private List<HashMap<String, Object>> getData() {
        mHashMaps = new ArrayList<HashMap<String,Object>>();
        map = new HashMap<String, Object>();
        map.put("image", R.drawable.gallery_photo_1);
        map.put("title", "G1");
        map.put("info", "google 1");
        mHashMaps.add(map);
        
        map = new HashMap<String, Object>();
        map.put("image", R.drawable.gallery_photo_2);
        map.put("title", "G2");
        map.put("info", "google 2");
        mHashMaps.add(map);
        
        map = new HashMap<String, Object>();
        map.put("image", R.drawable.gallery_photo_3);
        map.put("title", "G3");
        map.put("info", "google 3");
        
        mHashMaps.add(map);
        return mHashMaps;
    }
}

 

参考:http://www.cnblogs.com/shang53880/archive/2011/03/15/1985062.html

SimpleAdapter用法

标签:get   oncreate   log   sts   test   hot   http   add   turn   

原文地址:http://www.cnblogs.com/tekkaman/p/6361782.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!