title: How to remove selected items from listview when click remove button in android
body: <p>am displaying names in list view, with check boxes,here i have button if i click that button that  time i need to remove selected items and from list view, remain items only i need to show in list view,using below i code i can find what are the items i selected but i dont know how to remove those, can you any one suggest me</p>
  
  <pre><code>MainActivity.class: 
     public class MainActivity extends Activity {
  
   private ListView listview;  
   ArrayList&lt;String&gt; items = new ArrayList&lt;String&gt;();  
   private int count;  
   private boolean[] thumbnailsselection;  
   @Override  
   protected void onCreate(Bundle savedInstanceState) {  
        super.onCreate(savedInstanceState);  
        setContentView(R.layout.activity_main);  
        fillarray();  
        count = items.size();  
        thumbnailsselection = new boolean[count];  
        listview = (ListView) findViewById(R.id.listView1);  
        listview.setAdapter(new ImageAdapter(MainActivity.this));  
   }  
   private void fillarray() {  
        // TODO Auto-generated method stub  
        items.clear();  
        items.add("Android alpha");  
        items.add("Android beta");  
        items.add("1.5 Cupcake (API level 3)");  
        items.add("1.6 Donut (API level 4)");  
        items.add("2.0 Eclair (API level 5)");  
        items.add("2.0.1 Eclair (API level 6)");  
  
   }  
   @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;  
   }  
   public class ImageAdapter extends BaseAdapter {  
        private LayoutInflater mInflater;  
        private Context mContext;  
        public ImageAdapter(Context context) {  
             mContext = context;  
        }  
        public int getCount() {  
             return count;  
        }  
        public Object getItem(int position) {  
             return position;  
        }  
        public long getItemId(int position) {  
             return position;  
        }  
        public View getView(int position, View convertView, ViewGroup parent) {  
             ViewHolder holder;  
             if (convertView == null) {  
                  holder = new ViewHolder();  
                  convertView = LayoutInflater.from(mContext).inflate(  
                            R.layout.row_photo, null);  
                  holder.textview = (TextView) convertView  
                            .findViewById(R.id.thumbImage);  
                  holder.checkbox = (CheckBox) convertView  
                            .findViewById(R.id.itemCheckBox);  
                  convertView.setTag(holder);  
             } else {  
                  holder = (ViewHolder) convertView.getTag();  
             }  
             holder.checkbox.setId(position);  
             holder.textview.setId(position);  
             holder.checkbox.setOnClickListener(new OnClickListener() {  
                  public void onClick(View v) {  
                       // TODO Auto-generated method stub  
                       CheckBox cb = (CheckBox) v;  
                       int id = cb.getId();  
                       if (thumbnailsselection[id]) {  
                            cb.setChecked(false);  
                            thumbnailsselection[id] = false;  
                       } else {  
                            cb.setChecked(true);  
                            thumbnailsselection[id] = true;  
                       }  
                  }  
             });  
             holder.textview.setOnClickListener(new OnClickListener() {  
                  public void onClick(View v) {  
                       // TODO Auto-generated method stub  
                       int id = v.getId();  
                  }  
             });  
             holder.textview.setText(items.get(position));  
             holder.checkbox.setChecked(thumbnailsselection[position]);  
             holder.id = position;  
             return convertView;  
        }  
  
      public void removeItems()
        {
            notifyDataSetChanged();
        }
   }  
   class ViewHolder {  
        TextView textview;  
        CheckBox checkbox;  
        int id;  
   }  
   public void click(View v) {  
        if (v.getId() == R.id.button1) {  
  
             boolean noSelect = false;  
  
             for (int i = 0; i &lt; thumbnailsselection.length; i++) {  
                if (thumbnailsselection[i] == true) {  
                     noSelect = true;  
  
                         items.remove(i);
  
                  }  
  
  
           }  
            thumbnailsselection = new boolean[items.size()];
           adapter.removeItems(); 
        }  
   }  
  }
  </code></pre>