title: How do I display a custom dialog box from a function?
body: <p>In my app, I have three menu options that call functions.  One of the three calls a function that is supposed to read some info from a file and then display it in a dialog box.  My problem is getting the dialog box to work. I am using <a href="http://www.helloandroid.com/tutorials/how-display-custom-dialog-your-android-application" rel="nofollow">http://www.helloandroid.com/tutorials/how-display-custom-dialog-your-android-application</a>
  as a reference, but the methods they used do not work for me.       </p>
  
  <p>The part between the lines of asterisks is where I am getting an error.  The method setOnClickListener(View.OnClickListener) in the type View is not applicable for the arguments (new DialogInterface.OnClickListener(){})" It goes on to list suggested alternatives, which give the same error but list setOnClickListener as a suggested alternative.  I get another error after the override: "The method onClick(View) of type new DialogInterface.OnClickListener(){} must override a superclass method"</p>
  
  <p>There has to be an easy way to accomplish this task?  Am I missing something that should be obvious?  </p>
  
  <pre><code>//now stick it in a dialog box
          Context mContext = getApplicationContext();
          Dialog dialog = new Dialog(mContext);
          dialog.setContentView(R.layout.custom_dialog);
          dialog.setTitle("Totals");
          dialog.setCancelable(true);
          TextView text1 = (TextView) dialog.findViewById(R.id.diagtext1);
          TextView text2 = (TextView) dialog.findViewById(R.id.diagtext2);
          TextView text3 = (TextView) dialog.findViewById(R.id.diagtext3);
          Button btn = (Button) dialog.findViewById(R.id.button);
          text1.setText(dist);
          text2.setText(time);
          text3.setText(speed);
          //******************************************************
          btn.setOnClickListener(new OnClickListener(){
              @Override
              public void onClick(View v){
                  finish();
              }
  
          });
          //******************************************************
          dialog.show();
  
      }
  </code></pre>