Gulfam,

Thanks for the suggestion !! It worked.

But similarly with android.R.layout.simple_list_item_2,  in this case the
same situation was there that radio button was not displayed. Now as per
your solution the layout is there for single line
item(android.R.layout.simple_list_item_single_choice).

There is no android.R.layout.simple_list_item_single_choice for double line
list item(layout.simple_list_item_2)

Do i need to make my own layout and handle the logic for single choice to be
selected for radio button???

Thanks & Regards,
Amit

On Tue, Dec 14, 2010 at 3:55 PM, Gulfam <[email protected]> wrote:

>
> Try to use this layout
> (android.R.layout.simple_list_item_single_choice) instead of
> (android.R.layout.simple_list_item_1).
> I hope this will help you.
>
> Gulfam
>
> On Dec 14, 12:03 pm, Sudeep Sharma <[email protected]> wrote:
> > Hi,
> >       I am using the API of Alert Dialog builder
> >
> > 1.  public Builder setSingleChoiceItems(R.array.select_dialog_items2, int
> > checkedItem, final OnClickListener listener)
> > 2.  public Builder setSingleChoiceItems(ListAdapter adapter, int
> > checkedItem, final OnClickListener listener)
> >
> > The problem is that if i use a android.R.layout.simple_list_item_1 and
> above
> > api using adapter for populating the contents in array adapter, i get the
> > dialog as shown in snapshot1 where i *do not* see a radio button at the
> > right hand side of the item. Please see snapshot1.png
> >
> > But if i use the first api of (R.array.select_dialog_items2 ==>
> > DIALOG_SINGLE_CHOICE of Api demo's), then i get the snapshot2.png.
> >
> > This is little strange for me. I expected the radio button in previous
> case
> > also.
> >
> *********************************************************************************************************************************************************
> > code snippet :
> >
> > private ArrayAdapter<String> setAdapter1() { // this function will return
> > the adapter which will be passed in the *setSingleChoiceItems*
> >         final Context dialogContext = new ContextThemeWrapper(this,
> > android.R.style.Theme_Light);
> >         final LayoutInflater dialogInflater =
> >
> (LayoutInflater)dialogContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
> >         final String[] titles = getResources().getStringArray(
> >                 R.array.select_dialog_items2);
> >        final ArrayAdapter<String> adapter = new
> ArrayAdapter<String>(this,
> > android.R.layout.simple_list_item_1,
> >                 titles) {
> >              @Override
> >                  public View getView(int position, View convertView,
> > ViewGroup parent) {
> >                         if (convertView == null) {
> >                             convertView =
> > dialogInflater.inflate(android.R.layout.simple_list_item_1,
> >                 parent, false);
> >                         }
> >
> >                         TextView title = (TextView)
> > convertView.findViewById(android.R.id.text1);
> >                         title.setText(titles[position]);
> >                         return convertView;
> >                  }
> >        };
> >
> >         return adapter;
> >     }
> >
> *********************************************************************************************************************************************************
> >
> > Can anybody suggest something why the difference?
> >
> > Thanks & Regards,
> > Amit
> >
> >  snapshot1.png
> > 22KViewDownload
> >
> >  snapshot2.png
> > 26KViewDownload
>
> --
> You received this message because you are subscribed to the Google
> Groups "Android Developers" group.
> To post to this group, send email to [email protected]
> To unsubscribe from this group, send email to
> [email protected]<android-developers%[email protected]>
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en

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

Reply via email to