Note that there are some explanatory texts on larger screens.

plurals
  1. PORadio buttons doesn't show up when I use setSingleChoiceItems of AlertDialog.Builder with listadapter
    text
    copied!<p>Radio buttons doesn't show up when I use setSingleChoiceItems of AlertDialog.Builder with listadapter. Radio buttons show up if i use Charsequence[] array. Please take a look at the code I am using. Thanks in Advance!!</p> <p>public class ExampleApp extends Activity {</p> <pre><code>Context mContext; ListAdapter myListAdapter; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mContext = this; myListAdapter = new myListAdapter(mContext); AlertDialog.Builder alt_bld = new AlertDialog.Builder(this); alt_bld.setTitle("Select any icon"); alt_bld.setSingleChoiceItems(myListAdapter, -1, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int item) { Toast.makeText(getApplicationContext(), "Selected icon = "+imageName[item], Toast.LENGTH_SHORT).show(); } }); AlertDialog alert = alt_bld.create(); alert.show(); } private class myListAdapter extends BaseAdapter{ public myListAdapter(Context mContext){ } @Override public int getCount() { // TODO Auto-generated method stub return imageName.length; } @Override public Object getItem(int position) { // TODO Auto-generated method stub return position; } @Override public long getItemId(int position) { // TODO Auto-generated method stub return position; } @Override public View getView(int position, View convertView, ViewGroup parent) { // TODO Auto-generated method stub ViewHolder myViewHolder; if(convertView == null){ convertView = LayoutInflater.from(mContext).inflate(R.layout.listadapterview, null); myViewHolder = new ViewHolder(); myViewHolder.txt_icon_name = (CheckedTextView) convertView.findViewById(R.id.CheckedTextView01); convertView.setTag(myViewHolder); } else{ myViewHolder = (ViewHolder) convertView.getTag(); } myViewHolder.txt_icon_name.setText(imageName[position]); return convertView; } class ViewHolder { CheckedTextView txt_icon_name; } } String[] imageName = {"icon1", "icon2", "icon3"}; </code></pre> <p>} //XML for listadapter view </p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload