title: Removing muliple items from listview using Check box in Android
body: <p>Hi i am stuck with deleting multiple items from listview using checkbox. I am able to select multiple items from listview but only the first item that is selected, is getting deleted while other items are not being deleted. Here is my code. Thanks in Advance!</p>
  
  <pre><code>public class MainActivity extends Activity 
  {
      ListView lv;
      ArrayAdapter&lt;String&gt; adapter;
      Button delete;
      ArrayList&lt;String&gt; data = new ArrayList&lt;String&gt;();
      @Override
      protected void onCreate(Bundle savedInstanceState) 
      {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
          lv = (ListView)findViewById(R.id.listView1);
          delete = (Button)findViewById(R.id.button1);
          data.add("Windows");
          data.add("Android");
          data.add("Apple");
          data.add("Blackberry");
          adapter = new ArrayAdapter&lt;String&gt;(MainActivity.this, android.R.layout.simple_list_item_multiple_choice, data);
          lv.setAdapter(adapter);
  
          delete.setOnClickListener(new OnClickListener()
          {
              @Override
              public void onClick(View v)
              {
                  deleteCheckedItems();
                  adapter.notifyDataSetChanged();
              }
          });
  
  
      }
  
      @Override
      public boolean onCreateOptionsMenu(Menu menu) 
      {
          // Inflate the menu; this adds items to the action bar if it is present.
          getMenuInflater().inflate(R.menu.activity_main, menu);
          return true;
      }
      private void deleteCheckedItems() {
          int count = adapter.getCount();
  
          for (int i = 0; i &lt; count; i++) 
          {
              if (lv.isItemChecked(i))
              {
                 data.remove(i);
              }
          }
      }
  
  }
  </code></pre>