title: how to change state of checkbox in listview?
body: <p>i have listview which contain checkbox and imageview. the problem is when i click listView right checkbox is not checked but checked differnt checkbox randomly and also checked mulptiple checkbox..</p>
  
  <p>cell.xml  </p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:layout_width="match_parent" android:layout_height="match_parent"&gt;
      &lt;ImageView android:layout_width="wrap_content" android:src="@drawable/icon"
          android:id="@+id/imageView1" android:layout_height="wrap_content"/&gt;
      &lt;CheckBox android:id="@+id/checkBox1"
          android:layout_width="match_parent" android:layout_height="wrap_content"
          android:textSize="30dp" android:padding="2dp"
          android:button="@null"
          android:drawableRight="@android:drawable/btn_radio"
          android:focusable="false"
          &gt;&lt;/CheckBox&gt;
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>list.xml</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="match_parent"&gt;
      &lt;Button android:id="@+id/imageView"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:onClick="saveSetting"
      android:text="Save"/&gt; 
    &lt;ListView android:id="@+id/list"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:choiceMode="multipleChoice"
      /&gt;
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>MainActivity.java  </p>
  
  <pre><code>import java.util.ArrayList;
  import java.util.List;
  import android.app.Activity;
  import android.content.Context;
  import android.os.Bundle;
  import android.view.LayoutInflater;
  import android.view.View;
  import android.view.ViewGroup;
  import android.widget.AdapterView;
  import android.widget.AdapterView.OnItemClickListener;
  import android.widget.BaseAdapter;
  import android.widget.CheckBox;
  import android.widget.CompoundButton;
  import android.widget.ImageView;
  import android.widget.ListView;
  import android.widget.Toast;
  
  public class MainActivity extends Activity {
      String[] string = { "First", "Second", "third", "Forth", "Fifth", "Sixth",
              "Seven", "Eight" };
  
      public void onCreate(Bundle b) {
          super.onCreate(b);
          setContentView(R.layout.list);
          List&lt;String&gt; arrayList = new ArrayList&lt;String&gt;();
          for (String s : string) {
              arrayList.add(s);
          }
          ListView listview = (ListView) findViewById(R.id.list);
          final CustomAdapter ada = new CustomAdapter(arrayList, this);
          listview.setAdapter(ada);
          // listview.setItemsCanFocus(true);
          listview.setChoiceMode(0);
          listview.setOnItemClickListener(new OnItemClickListener() {
  
              @Override
              public void onItemClick(AdapterView&lt;?&gt; arg0, View arg1, int arg2,
                      long arg3) {
                  ada.setPosition(arg2);
              }
          });
      }
  
      class CustomAdapter extends BaseAdapter {
          private List&lt;String&gt; items;
          private LayoutInflater inflater;
          int selectedPos = -1;
  
          public CustomAdapter(List&lt;String&gt; list, Context context) {
              super();
              this.items = list;
              this.inflater = LayoutInflater.from(context);
          }
  
          @Override
          public int getCount() {
              // TODO Auto-generated method stub
              return items.size();
          }
  
          public void setPosition(int position) {
              selectedPos = position;
              notifyDataSetChanged();
          }
  
          public int getPosition() {
              return selectedPos;
          }
  
          @Override
          public Object getItem(int position) {
              // TODO Auto-generated method stub
              return items.get(position);
          }
  
          @Override
          public long getItemId(int position) {
              // TODO Auto-generated method stub
              return position;
          }
  
          @Override
          public View getView(final int position, View convertView,
                  ViewGroup parent) {
              final ViewHolder holder;
              if (convertView == null) {
                  convertView = inflater.inflate(R.layout.cell, null);
                  holder = new ViewHolder();
                  holder.cBox = (CheckBox) convertView
                          .findViewById(R.id.checkBox1);
                  holder.iView = (ImageView) convertView
                          .findViewById(R.id.imageView1);
                  convertView.setTag(holder);
              } else
                  holder = (ViewHolder) convertView.getTag();
              holder.iView.setImageResource(R.drawable.icon);
              holder.cBox.setText(items.get(position));
              if (selectedPos == position) {
                  holder.cBox.setChecked(!holder.cBox.isChecked());
  
              }
              final String c=(String) holder.cBox.getText();
              holder.cBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
  
                  @Override
                  public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                      // TODO Auto-generated method stub
                      Toast.makeText(getApplicationContext(),c , Toast.LENGTH_LONG).show();
                  }
              });
              return convertView;
  
          }
  
          class ViewHolder {
              ImageView iView;
              CheckBox cBox;
          }
  
      }
  
      public void saveSetting(View view) {
      }
  
  }
  </code></pre>
  
  <p>may i know what wrong with my code<br>
  thank in advance</p>