title: how to handle checkbox in listview android?
body: <p>I am using checkbox with ListView.Code is working fine. I strucked to get all the list checked Items. I used below code for getting checked items. But it is giving result of focused area of list.</p>
  
  <pre><code>int firstPosition = list.getFirstVisiblePosition();
  
          for(int i = firstPosition; i &lt; list.getCount(); i++){
              View v = list.getChildAt(i);
              if(v != null){
                  cbx = (CheckBox)v.findViewById(R.id.c_checkbox);
                  if(cbx.isChecked()){
                                          //adding this check box to one sub list
                  }
              }
          }
  </code></pre>
  
  <p>But it is giving only focusable list items result only.Depending on sublist I want to populate my menu that's why I am using this code in onPrepareOptionsMen() method and clicking on menu item delete this list from database.
  I found another solution that is</p>
  
  <pre><code>long checkedPos[] =list.getCheckedItemIds();
  </code></pre>
  
  <p>But it is giving</p>
  
  <blockquote>
    <p>01-31 12:07:16.042:
    WARN/dalvikvm(294): VFY: unable to
    resolve virtual method 808:
    Landroid/widget/ListView;.getCheckedItemIds
    ()[J 01-31 12:07:16.042:
    WARN/dalvikvm(294): VFY:  rejecting
    opcode 0x6e at 0x0024</p>
  </blockquote>
  
  <p>This error. After searching on Google I found another solution that is</p>
  
  <p><a href="http://groups.google.com/group/android-developers/browse_thread/thread/368d0bae027aab63/1c61f007e821ed2a?q=%22Getting+the+state+of+a+checkbox+inside+of+a+listview%22+%22Romain+Guy%22#1c61f007e821ed2a" rel="nofollow">http://groups.google.com/group/android-developers/browse_thread/thread/368d0bae027aab63/1c61f007e821ed2a?q=%22Getting+the+state+of+a+checkbox+inside+of+a+listview%22+%22Romain+Guy%22#1c61f007e821ed2a</a></p>
  
  <p>but I want to use SparseBooleanArray  into my activity onPrepareOptionMenu().How to get back this result into my activity from my adapter.Please give me advice?</p>
  
  <p>At last i used SparseBooleanArray.Now it is working fine.
  Regards,
  Android developer</p>