android.widget.SimpleAdapter.ViewBinder Java Examples

The following examples show how to use android.widget.SimpleAdapter.ViewBinder. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: HCActivity.java    From styT with Apache License 2.0 6 votes vote down vote up
public void initAdapter() {
    items = new ArrayList<Map<String, Object>>();
    //实例化一个适配器
    adapter = new SimpleAdapter(HCActivity.this, items,
            R.layout.hc_list_item,
            new String[]{"imageItem", "fileName", "delay", "filePath"},
            new int[]{R.id.image_item, R.id.hc_tv_filename, R.id.tv_delay}
    );

    list.setAdapter(adapter);
    adapter.setViewBinder(new ViewBinder() {

        @Override
        public boolean setViewValue(View p1, Object p2, String p3) {
            if (p1 instanceof ImageView && p2 instanceof Bitmap) {
                ImageView iv = (ImageView) p1;
                iv.setImageBitmap((Bitmap) p2);
                return true;
            } else
                return false;

        }
    });
}
 
Example #2
Source File: HCActivity.java    From stynico with MIT License 5 votes vote down vote up
public void initAdapter()
   {
items = new ArrayList<Map<String,Object>>(); 
//实例化一个适配器  
adapter = new SimpleAdapter(HCActivity.this, items,
			    R.layout.hc_list_item,
			    new String[]{"imageItem", "fileName","delay","filePath"},
			    new int[]{R.id.image_item, R.id.hc_tv_filename,R.id.tv_delay}
			    );  

list.setAdapter(adapter);  
adapter.setViewBinder(new ViewBinder(){

	@Override
	public boolean setViewValue(View p1, Object p2, String p3)
	{
	    if (p1 instanceof ImageView && p2 instanceof Bitmap)
	    {
		ImageView iv = (ImageView) p1;
		iv.setImageBitmap((Bitmap) p2);
		return true;
	    }
	    else
		return false;

	}
    });
   }
 
Example #3
Source File: CodecsFragment.java    From CSipSimple with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    prefsWrapper = new PreferencesWrapper(getActivity());
    useCodecsPerSpeed  = SipConfigManager.getPreferenceBooleanValue(getActivity(), SipConfigManager.CODECS_PER_BANDWIDTH);
    initDatas();
    setHasOptionsMenu(true);

    
    
    // Adapter
    mAdapter = new SimpleAdapter(getActivity(), codecsList, R.layout.codecs_list_item, new String[] {
            CODEC_NAME,
            CODEC_NAME,
            CODEC_PRIORITY
    }, new int[] {
            R.id.line1,
            R.id.AccCheckBoxActive,
            R.id.entiere_line
    });

    mAdapter.setViewBinder(new ViewBinder() {
        @Override
        public boolean setViewValue(View view, Object data, String textRepresentation) {
            if (view.getId() == R.id.entiere_line) {
                Log.d(THIS_FILE, "Entiere line is binded ");
                TextView tv = (TextView) view.findViewById(R.id.line1);
                ImageView grabber = (ImageView) view.findViewById(R.id.icon);
                CompoundButton checker = (CompoundButton) view.findViewById(R.id.AccCheckBoxActive);
                checker.setOnCheckedChangeListener(CodecsFragment.this);
                if ((Short) data == 0) {
                    tv.setTextColor(Color.GRAY);
                    grabber.setVisibility(View.GONE);
                    checker.setChecked(false);
                } else {
                    tv.setTextColor(Color.WHITE);
                    grabber.setVisibility(View.VISIBLE);
                    checker.setChecked(true);
                }
                return true;
            }else if(view.getId() == R.id.AccCheckBoxActive) {
                view.setTag(data);
                return true;
            }
            return false;
        }

    });

    setListAdapter(mAdapter);
    registerForContextMenu(getListView());
}
 
Example #4
Source File: MainActivity.java    From AppCrawler with Apache License 2.0 4 votes vote down vote up
private boolean refreshAppListView() {

        // Get installed packages
        ArrayList<HashMap<String, Object>> appList = new ArrayList<HashMap<String, Object>>();
        if (sPkgInfoList == null) {
            sPkgInfoList = mPkgMgr.getInstalledPackages(0);
        }

        for (PackageInfo pkg : sPkgInfoList) {

            // Skip Ourself
            if (pkg.packageName.equalsIgnoreCase(getPackageName()))
                continue;

            // Skip Android packages
            if (mCheckBoxHideAndroid.isChecked()) {
                if (pkg.packageName.contains(PKG_PREFIX_ANDROID))
                    continue;
            }

            // Skip Google packages
            if (mCheckBoxHideGoogle.isChecked()) {
                if (pkg.packageName.contains(PKG_PREFIX_GOOGLE))
                    continue;
            }

            HashMap<String, Object> mapApp = new HashMap<String, Object>();
            mapApp.put(APP_PKG, pkg.packageName);
            mapApp.put(APP_NAME, pkg.applicationInfo.loadLabel(mPkgMgr));
            mapApp.put(APP_ICON, pkg.applicationInfo.loadIcon(mPkgMgr));
            appList.add(mapApp);
        }

        // Bind ListView with content adapter
        SimpleAdapter appAdapter = new SimpleAdapter(this, appList, R.layout.app_list_item,
                new String[] {
                        APP_NAME, APP_PKG, APP_ICON
                },
                new int[] {
                        R.id.appName, R.id.appPackage, R.id.appIcon
                });

        appAdapter.setViewBinder(new ViewBinder() {
            public boolean setViewValue(View view, Object data, String textRepresentation) {
                if (view instanceof ImageView && data instanceof Drawable) {
                    ImageView iv = (ImageView) view;
                    iv.setImageDrawable((Drawable) data);
                    return true;
                }
                else
                    return false;
            }
        });

        mListView.setAdapter(appAdapter);

        return true;
    }