title: How to delete item from listView using alertDialog
body: <p>I have a ListView showing the names of different profiles, when the user holds the click on an item the activity shows an alertDialog, if the user press the confirm button I want to remove the element from my listView, from my ArrayAdapter and from my ArrayList.
  I know that arg2 in the onItemLongClick method represent the index of the selected item but I want to be able to access it inside the onClick method of the positive button.
  Any advice?
  My ArrayList is called "ListaUtentiStringa", the ArrayAdapter is "profilesAdapter" and the listView is called listview.
  Sorry for my bad english.   </p>
  
  <pre><code>listview.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
  
  public boolean onItemLongClick(AdapterView&lt;?&gt; arg0, View arg1, int arg2, long arg3) {
  
  
          AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
          builder.setCancelable(true);
          builder.setTitle("Vuoi davvero cancellare il profilo?");
          builder.setPositiveButton("Si", new DialogInterface.OnClickListener() {
  
                              public void onClick(DialogInterface dialog, int which) {
                                            // How to remove the selected item?
                              }
  
                          });
  
  builder.setNegativeButton("Annulla", new DialogInterface.OnClickListener() {
  
          public void onClick(DialogInterface dialog, int which) {
  
          }
  
          });
  
          AlertDialog alert = builder.create();
          alert.show();
          profilesAdapter.notifyDataSetChanged();
  
  
      return true;
      }
      }); 
  </code></pre>