title: Clickable Options in AlertDialog after ListView long click
body: <p>I am trying to set up a listView with an OnItemLongClickListener(), that will open up a alert dialog with a custom layout. I then want the layout to have two buttons, one to open up another activity to edit the entry in the SQLite DB, and one to delete the entry. My onItemLongClickListener() works, and I can open a custom layout, but I cant figure out how to make the dialog close after I click the button, or execute the methods I want it to.</p>
  
  <p>My ListViewItemLongClick():</p>
  
  <pre><code>private void listViewItemLongClick(){
      final ListView myList = (ListView) findViewById(R.id.resourcesList);
      myList.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
          @Override
          public boolean onItemLongClick(AdapterView&lt;?&gt; parent, View view, int position, long id) {
               Id = id;
  
  
              AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(MainActivity.this);
              // ...Irrelevant code for customizing the buttons and title
              LayoutInflater inflater = getLayoutInflater();
              View dialogView = inflater.inflate(R.layout.alert_layout, null);
              dialogBuilder.setView(dialogView);
  
              AlertDialog alertDialog = dialogBuilder.create();
              alertDialog.show();
  
  
  
              return true;
          }
      });
  
  }
  </code></pre>
  
  <p>My custom alert 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="vertical" android:layout_width="match_parent"
      android:layout_height="match_parent"&gt;
  
      &lt;Button
          android:id="@+id/Edit"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:onClick="edit"
          android:text="Edit" /&gt;
  
      &lt;Button
          android:id="@+id/delete"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:onClick="delete"
          android:text="Delete" /&gt;
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>Any help would be much appreciated, Im still very new to android programming.</p>
  
  <p>Cheers!</p>