I would like to display a drawable on the left side of text in a
CheckedTextView. The whole thing looks like this:

AlertDialog
 ListView (set with setSingleChoiceItems)
  ListAdaper
    items
     CheckedTextView
     ...
     CheckedTextView

In onPrepareDialog() I do the following:

        @Override
        protected void onPrepareDialog (int id, Dialog dialog) {
                switch (id) {
                        case Constants.DIALOG_SELECT_SOMETHING : {
                                ListView lv = 
(ListView)((AlertDialog)dialog).getListView();
                                ListAdapter la = lv.getAdapter();
                                Drawable[] icons = GET A BUNCH OF DRAWABLES;
                                int count = la.getCount();
                                if (count == icons.length) {
                                        for (int i = 0; i < count; i++) {
                                                CheckedTextView ctv = 
(CheckedTextView)la.getView(i, null,
null);
                                                Drawable icon = icons[i];
                                                icon.setBounds(0, 0, 
icon.getIntrinsicWidth(),
icon.getIntrinsicHeight());
                                                
ctv.setCompoundDrawablesWithIntrinsicBounds(icon, null, null,
null);
                                                Drawable[] ds = 
ctv.getCompoundDrawables();
                                        }
                                }
                                break;
                        }

When the dialog is displayed the drawable is not displayed though it
appears in the ds array. Does anybody know what's missing?

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to