title: Delete a custom item when the button in it get clicked
body: <p>I have a <code>ListView</code> with custom list items having following layout:</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="horizontal"
        android:layout_width="match_parent" 
        android:layout_height="wrap_content"&gt;
  
            &lt;TextView android:id="@+id/itemNumberText" 
                 android:text="1." android:textSize="16sp"
                 android:textStyle="bold" 
                 android:layout_height="match_parent"
                 android:layout_width="33dp" 
                 android:gravity="center_vertical|center_horizontal"/&gt;
  
          &lt;ImageView android:src="@drawable/item"
                 android:id="@+id/imageView1" 
                 android:layout_height="match_parent"
                 android:layout_width="47dp"/&gt;
  
          &lt;LinearLayout android:id="@+id/linearLayout1"
                 android:orientation="vertical"
                 android:layout_height="wrap_content"
                 android:layout_width="143dp"&gt;
  
                &lt;TextView android:text="name" 
                          android:id="@+id/text1" 
                          android:layout_width="wrap_content" 
                          android:layout_height="wrap_content" 
                          android:textSize="16sp" android:textStyle="bold"  
                          android:textColor="#f5cd10"&gt;&lt;/TextView&gt;
  
               &lt;LinearLayout android:id="@+id/linearLayout2" 
                      android:layout_height="wrap_content"
                      android:layout_width="match_parent"&gt;
  
                      &lt;TextView android:id="@+id/text2"
                                android:layout_height="wrap_content" 
                                android:text="amount" 
                                android:textColor="#ffffff"
                                android:layout_width="wrap_content"/&gt;
  
                      &lt;TextView android:text=" unit" 
                                android:id="@+id/text4"
                                android:layout_width="wrap_content"
                                android:layout_height="wrap_content"/&gt;
              &lt;/LinearLayout&gt;
  
              &lt;TextView android:text="price"
                        android:id="@+id/text3"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"/&gt;
  
          &lt;/LinearLayout&gt;
          &lt;RelativeLayout android:layout_height="match_parent" 
                          android:id="@+id/relativeLayout1"
                          android:layout_width="match_parent"&gt;
  
              &lt;Button android:layout_width="wrap_content" 
                      android:layout_height="wrap_content"  
                      android:onClick="itemDeleteButtonClicked" 
                      android:background="@drawable/item_button_style_selector" 
                      android:text="Delete Item" android:id="@+id/list_button" 
                      android:layout_alignParentRight="true" 
                      android:layout_alignParentBottom="true"/&gt;
  
         &lt;/RelativeLayout&gt;
  
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>As its seen from above I mentioned a method for Button, typing </p>
  
  <pre><code>android:onClick="itemDeleteButtonClicked" 
  </code></pre>
  
  <p>Here's the code for method:</p>
  
  <pre><code> public void itemDeleteButtonClicked(View v)
   {
      int index;
      index=itemsListView.getSelectedItemPosition();//itemsListView is the listview
      list.remove(index);//list is the list of data to be shown in listview
      adapter.notifyDataSetChanged();
   }
  </code></pre>
  
  <p>I have used a <code>SimpleAdapter</code> and it's not customized. Here it is: </p>
  
  <pre><code>//create base adapter for listview 
  adapter= new SimpleAdapter( 
               this, list, R.layout.detailed_info_list_item, 
                 new String[] {"number","item","amount","price","unit"}, 
                 new int[] {R.id.itemNumberText,R.id.text1,R.id.text2, R.id.text3,R.id.text4} 
               ); 
  setListAdapter(adapter);
  </code></pre>
  
  <p>But it's not working. That is it's not deleting the clicked item. Would you please give me some suggestions.</p>