如何在每个建议行旁边创建带有图标的自定义AutoMLETextView-Android

如何在每个建议行旁边创建带有图标的自定义AutoMLETextView-Android,android,autocompletetextview,Android,Autocompletetextview,我想创建一个自定义的AutoCompleteTextView,在每个建议行的textView旁边有一个图标。我该怎么做呢?我有一个类可以从数据库中读取联系人数据 public class SimpleContactAdapter extends SimpleCursorAdapter implements Filterable { /** The context. */ private Context context;

我想创建一个自定义的
AutoCompleteTextView
,在每个建议行的
textView
旁边有一个图标。我该怎么做呢?

我有一个类可以从数据库中读取联系人数据

 public class SimpleContactAdapter extends SimpleCursorAdapter implements
            Filterable {

        /** The context. */
        private Context context;

        public HashMap<Integer,Long> hm;
        private int postionCounter;

        /** The layout. */
        private int layout;

        /** The TAG. */
        String TAG = "Logs: ";

        private ImageView mProfileImgView;

        private Bitmap mBitmap;

        /**
         * Instantiates a new simple contact adapter.
         * 
         * @param context
         *            the context
         * @param layout
         *            the layout
         * @param c
         *            the c
         * @param from
         *            the from
         * @param to
         *            the to
         */
        public SimpleContactAdapter(Context context, int layout, Cursor c,
                String[] from, int[] to,ImageView profileImgView,Bitmap bitmap) {
            super(context, layout, c, from, to);
            this.context = context;
            this.layout = layout;
            this.mProfileImgView = profileImgView;
            this.mBitmap = bitmap;
            this.hm = new HashMap<Integer,Long>();
        }

        public void bindView(View v, Context context, Cursor c) {

            int nameCol = c.getColumnIndex(ContactsContract.Data.DISPLAY_NAME);
            int photoId = c.getColumnIndex(ContactsContract.Data.RAW_CONTACT_ID);

            String name = c.getString(nameCol);

            /**
             * Next set the name of the entry.
             */
            TextView name_text = (TextView) v.findViewById(R.id.name_entry);
            if (name_text != null) {
                name_text.setText(name);
            }

            ImageView profile = (ImageView) v.findViewById(R.id.profile_pic);
            if (profile != null) {
                try {
                    mBitmap = loadContactPhoto(this.context
                            .getContentResolver(),c.getLong(photoId));
                    profile.setImageBitmap(mBitmap);
                    hm.put(new Integer(postionCounter),c.getLong(photoId));
                    postionCounter++;

                } catch (Exception ex) {
                    Logger.printMsg("Image not found for contact" + ex.getMessage());
                }

            }

        }

        public static Bitmap loadContactPhoto(ContentResolver cr, long id) {
            Uri uri = ContentUris.withAppendedId(
                    ContactsContract.Contacts.CONTENT_URI, id);
            InputStream input = ContactsContract.Contacts
                    .openContactPhotoInputStream(cr, uri);
            if (input == null) {
                Logger.printMsg("Image not found");
                return null;
            }
            return BitmapFactory.decodeStream(input);
        }

        @Override
        public Cursor runQueryOnBackgroundThread(CharSequence constraint) {
            if (getFilterQueryProvider() != null) {
                return getFilterQueryProvider().runQuery(constraint);
            }

            StringBuilder buffer = null;
            String[] args = null;
            if (constraint != null) {
                buffer = new StringBuilder();
                buffer.append("UPPER(");
                buffer.append(ContactsContract.Data.DISPLAY_NAME);
                buffer.append(") GLOB ?");
                args = new String[] { constraint.toString().toUpperCase() + "*" };
            }
            hm.clear();
            postionCounter=0;
            return context.getContentResolver().query(
                    ContactsContract.CommonDataKinds.Phone.CONTENT_URI, null,
                    buffer == null ? null : buffer.toString(), args,
                    ContactsContract.Data.DISPLAY_NAME + " ASC");
        }

        @Override
        public CharSequence convertToString(Cursor cursor) {
            int nameCol = cursor.getColumnIndex(ContactsContract.Data.DISPLAY_NAME);
            return cursor.getString(nameCol);
        }

    }

对于这样一个懒惰的问题,这是一个很好的答案,但仍然不是一个公认的答案。好的,先生,请接受我的投票。
//query for the people in your address book
        cursor = getContentResolver().query(Uri.parse(""+ ContactsContract.CommonDataKinds.Phone.CONTENT_URI), null, null, null,null);
        startManagingCursor(cursor);

        //bind the name and the number fields
        String[] columns = new String[] { ContactsContract.Data.DISPLAY_NAME,ContactsContract.CommonDataKinds.Photo._ID};
        int[] to = new int[] { R.id.name_entry, R.id.profile_pic };
        mAdapter = new SimpleContactAdapter(this, R.layout.list_entry, cursor, columns, to,mProfileImgIv,mThumbnail);


mProfileNameAuto.setAdapter(mAdapter);