title: Custom Listview with CheckBox single selection
body: <p>Here I am creating custom listview with checkbox / RadioButton. I got this but I need the single selection for that.</p>
  
  <p>I try using this <code>lstvw.setChoiceMode(ListView.CHOICE_MODE_SINGLE);</code> but it not works for me.  Is there any other solutions for that then please let me know.</p>
  
  <p>main.java</p>
  
  <pre><code>  private ImageAdapter  adapter; 
  
  private static String month[] = {"January","February","March","April","May",  
      "June","July","August","September",  
      "October","November","December"};  
  
  
  /** Called when the activity is first created. */
  @Override
  public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.main);
  
      ListView lstvw = (ListView) findViewById(R.id.listView);
  
       adapter = new ImageAdapter(this, month);  
       lstvw.setAdapter(adapter);  
        lstvw.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
  
       lstvw.setOnItemClickListener(this);
  }
  </code></pre>
  
  <p>I have no idea for the how to add code for the checkbox into the adapter class.please check the adapter class as below.</p>
  
  <p>ImageAdapter.class</p>
  
  <pre><code>public class ImageAdapter extends BaseAdapter{
  
  public String title[];  
  public String description[];  
  public Activity context;  
  public LayoutInflater inflater;
  
  public ImageAdapter(Activity context,String[] title) {  
      super();  
  
      this.context = context;  
      this.title = title;  
  
      this.inflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);  
  }  
  
  @Override  
  public int getCount() {  
      // TODO Auto-generated method stub  
      return title.length;  
  }  
  
  @Override  
  public Object getItem(int position) {  
      // TODO Auto-generated method stub  
      return null;  
  }  
  
  @Override  
  public long getItemId(int position) {  
      // TODO Auto-generated method stub  
      return 0;  
  }  
  
  public static class ViewHolder  
  {  
  
      TextView txtViewTitle;  
  
  }  
  
  @Override  
  public View getView(int position, View convertView, ViewGroup parent) {  
      // TODO Auto-generated method stub  
  
      ViewHolder holder;  
      if(convertView==null)  
      {  
          holder = new ViewHolder();  
          convertView = inflater.inflate(R.layout.listitem, null);  
  
          holder.txtViewTitle = (TextView) convertView.findViewById(R.id.lstvw_textView);  
          convertView.setTag(holder);  
      }  
      else  
          holder=(ViewHolder)convertView.getTag();  
  
      holder.txtViewTitle.setText(title[position]);  
  
      return convertView;  
  }   
  
  }
  </code></pre>
  
  <p><strong>EDIT:</strong></p>
  
  <p>Listitem.xml</p>
  
  <pre><code> &lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="fill_parent"
  android:layout_height="fill_parent"
  android:orientation="horizontal" &gt;
  
  &lt;TextView
      android:id="@+id/lstvw_textView"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_alignParentLeft="true"
      android:layout_toLeftOf="@+id/itemCheckBox"
      android:padding="8dp"
      android:text="hello world" /&gt;
  
  
  
  &lt;CheckBox
      android:id="@+id/itemCheckBox"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_alignParentRight="true"
      android:gravity="right" /&gt;
  </code></pre>
  
  <p></p>