title: Alert Dialog - how to implement Cancel and Okay button
body: <p>I have got this Alert Dialog which has these two buttons (Ok and Cancel). I want to know how I go about implementing it.</p>
  
  <p>So When you click on the cancel button it should close the alert dialog and return back to the fragment I am currently on. And if I click on the Ok button it should replace the current alert dialog and place it with another one. </p>
  
  <p>this is my code below for the confimration. java file;</p>
  
  <pre><code>public class confirmation extends DialogFragment {
  
  @Override
  public Dialog onCreateDialog(Bundle savedInstanceState) {
  
      final AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
      LayoutInflater inf = getActivity().getLayoutInflater();
      final View theDIalog = inf.inflate(R.layout.example_xml, null);
      builder.setView(theDIalog);
  
  AlertDialog dialog = builder.create();
  
  
  
      theDIalog.findViewById(R.id.makeaTransferOk).setOnClickListener(new View.OnClickListener() {
          @Override
          public void onClick(View v) {
              Toast.makeText(getActivity(), "Okay button is clicked", Toast.LENGTH_SHORT).show();
          }
      });
  
  
      theDIalog.findViewById(R.id.makeaTransferCancel).setOnClickListener(new View.OnClickListener() {
          @Override
          public void onClick(View v) {
              dialog.dismiss();
          }
      });
  
      return dialog;
  }
  }
  </code></pre>
  
  <p>this is my code for the example_xml;</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
  android:orientation="vertical" android:layout_width="match_parent"
  android:layout_height="wrap_content"
  android:background="#ffc0c0c0"&gt;
  
  &lt;Button
                  android:layout_width="wrap_content"
                  android:layout_height="wrap_content"
                  android:text="Cancel"
                  android:id="@+id/makeaTransferCancel"/&gt;
  
  &lt;Button
                  android:layout_width="wrap_content"
                  android:layout_height="wrap_content"
                  android:text="OK"
                  android:id="@+id/makeaTransferOk"/&gt;
  
  &lt;/RelativeLayout&gt;
  </code></pre>
  
  <p>Please could someone help me </p>