How to use ViewBinder in SimpleAdapter with contacts?

318 views Asked by At

I want to setup a ViewBinder in a SimpleAdapter and put contact photo in it. Can someone show me how? In this code I'm putting the name and number from contacts in ListView, but I don't now how to put photo.

ArrayList<HashMap<String, String>> mapa = new ArrayList<HashMap<String, String>>();

            ContentResolver cr = getContentResolver();
            Cursor cur = cr.query(ContactsContract.Contacts.CONTENT_URI, null, null, null, null);


            if(cur.getCount() > 0){
                while(cur.moveToNext()){
                    id = cur.getString(cur.getColumnIndex(ContactsContract.Contacts._ID));

                    if(Integer.parseInt(cur.getString(cur.getColumnIndex(ContactsContract.Contacts.HAS_PHONE_NUMBER))) > 0){

                        final Cursor numCur = cr.query(ContactsContract.CommonDataKinds.Phone.CONTENT_URI, null, ContactsContract.CommonDataKinds.Phone.CONTACT_ID + "  = ?", new String[]{id}, null);


                        for(numCur.moveToFirst(); !numCur.isAfterLast(); numCur.moveToNext()){

                            brTel = numCur.getString(numCur.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER));
                            ime = cur.getString(cur.getColumnIndex(ContactsContract.Contacts.DISPLAY_NAME));

                            tmpIme = new String[] {ime};


                            for(int i = 0; i < tmpIme.length; i++){

                                HashMap<String, String> imeMapa = new HashMap<String, String>();
                                imeMapa.put("imeLista", ime);
                                imeMapa.put("photo", "");
                                imeMapa.put("Mobilni", brTel);
                                mapa.add(imeMapa);

                            }

                        }
                        numCur.close();

                    }

                } // While
            }

SimpleAdapter sa = new SimpleAdapter(getApplicationContext(), mapa, R.layout.imenik, new String[] {"imeLista", "photo", "Mobilni"}, new int[] {R.id.tvImeImenik, R.id.cbOznaci, R.id.tvSamoProba});
            lImenik.setAdapter(sa);
0

There are 0 answers