title: How to get position of checkbox in listview
body: <p>how to get id or position of a checkbox inside listview?
  I need to update database when isChecked = true or false, but I need position...
  maybe I could just do same things as in OnItemClick method?</p>
  
  <pre><code>@Override
  public void onItemClick(AdapterView&lt;?&gt; parent, View itemClicked, int position, long id){
  
  
      CheckBox cbx = (CheckBox)itemClicked.findViewById(R.id.cbxList);
      cbx.setOnCheckedChangeListener(new OnCheckedChangeListener() {
  
          @Override
          public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
  
          }
      });
  
      if(cbx.getVisibility() == View.VISIBLE){
          ContentValues cv = new ContentValues();
          if(cbx.isChecked()){
              cbx.setChecked(false);
              int cbxID = 0;
              cv.put(DB.CBX, cbxID);
              mDB.updateCbx(cv, id);
              Log.d(LOG, " updated with id = " + id + " and cbxID is " + cbxID);
          }else{
              cbx.setChecked(true);
              int cbxID = 1;
              cv.put(DB.CBX, cbxID);
              mDB.updateCbx(cv, id);
              Log.d(LOG, " updated with id = " + id + " and cbxID is " + cbxID);
          }
  
      }else{
          Intent intentContactView = new Intent(this, ContactView.class);
          intentContactView.putExtra("id", id);
          startActivity(intentContactView);
      }       
  }   
  </code></pre>
  
  <p>The method getView() from class with SimpleCursorAdapter... same question, how to get the position or id of chosen checkbox?</p>
  
  <pre><code>@Override
  public View getView(int position, View convertView, ViewGroup parent) {
      if (convertView == null) {
          convertView = mLayoutInflater.inflate(R.layout.item, parent, false);
          view = super.getView(position, convertView, parent);
  
          CheckBox cbx = (CheckBox)convertView.findViewById(R.id.cbxList);
  
  
      }
  
      return view;
  }
  </code></pre>
  
  <p>and my Xml file with listview's items. Here said checkboxes are invisible, but they appears, when I call them (just for understanding.</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="wrap_content"
      android:layout_margin="@dimen/margin"
      android:orientation="horizontal" &gt;
  
      &lt;LinearLayout
          android:layout_width="0dp"
          android:layout_height="wrap_content"
          android:layout_margin="@dimen/margin"
          android:layout_weight="0.5"
          android:orientation="horizontal" &gt;
  
          &lt;LinearLayout
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:layout_margin="@dimen/margin"
              android:orientation="vertical" &gt;
  
              &lt;ImageView
                  android:id="@+id/ivPhoto"
                  android:layout_width="@dimen/imageWidth"
                  android:layout_height="@dimen/imageHeight"
                  android:layout_gravity="center_vertical"
                  android:contentDescription="@string/photoDescription"
                  android:src="@drawable/default_contact" /&gt;
          &lt;/LinearLayout&gt;
  
          &lt;TextView
              android:id="@+id/tvName"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:layout_gravity="center_vertical"
              android:layout_marginLeft="@dimen/margin"
              android:text=""
              android:textSize="@dimen/textSize" /&gt;
  
          &lt;TextView
              android:id="@+id/tvSurname"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:layout_gravity="center_vertical"
              android:layout_marginLeft="@dimen/margin"
              android:text=""
              android:textSize="@dimen/textSize" /&gt;
      &lt;/LinearLayout&gt;
  
      &lt;CheckBox
          android:id="@+id/cbxList"
          android:layout_width="0dp"
          android:layout_height="wrap_content"
          android:layout_gravity="center"
          android:layout_marginLeft="@dimen/margin"
          android:layout_weight="0.2"
          android:focusable="false"
          android:visibility="invisible" /&gt;
  
  &lt;/LinearLayout&gt;
  </code></pre>