• android在listview中放入从sdcard读取的bitmap


    重写viewbinder

    public class viewbinder_bookmark implements SimpleAdapter.ViewBinder{
        @Override
        public boolean setViewValue(View view, Object data, String textRepresentation){
            if(view instanceof ImageView && data instanceof Bitmap){
                ImageView imageview=(ImageView)view;
                Bitmap bitmap=(Bitmap)data;
                imageview.setImageBitmap(bitmap);
                return true;
            }
            return false;
        }
    }

    再给simpleadapter设置viewbinder

    List<Map<String,Object>> arraylist_bookmark=new ArrayList<Map<String,Object>>();
            Map<String,Object> item_bookmark=new HashMap<String,Object>();
            item_bookmark.put("bookmark_title","百度一下");
            item_bookmark.put("bookmark_favicon",bitmap);
            arraylist_bookmark.add(item_bookmark);
            SimpleAdapter simpleAdapter=new SimpleAdapter(MainActivity.this ,arraylist_bookmark,R.layout.layout_bookmark_item,new String[]{"bookmark_title","bookmark_favicon"},new int[]{R.id.bookmark_title,R.id.bookmark_favicon});
            simpleAdapter.setViewBinder(new viewbinder_bookmark());
            listview_bookmark=(ListView)findViewById(R.id.listview_bookmark);
            listview_bookmark.setAdapter(simpleAdapter);
  • 相关阅读:
    HUSTOJ:Transit Tree Path
    HUSTOJ:5500 && 洛谷:P1412:经营与开发
    hdu:2036.改革春风吹满地
    hdu:2030.汉字统计
    Leetcode:338. Bit位计数
    【学习笔记】圆方树(CF487E Tourists)
    BZOJ3238 [Ahoi2013]差异
    CF 187D BRT Contract
    CF 36E Two Paths
    CF 49E Common ancestor
  • 原文地址:https://www.cnblogs.com/zqxLonely/p/5461945.html
Copyright © 2020-2023  润新知