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]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to