android - How do I display a custom dialog box from a function? -


In my app, I have three menu options that make function calls. One of the three calls is a function that should read some information from a file and then display it in a dialog box. My problem is getting the dialog box to work. I am using it as a reference, but the methods they use do not work for me

Part of the lines of stars The method where I am getting an error is not applicable for the argument in the setOnClickListener (View.OnClickListener) type view (New DialogInterface.OnClickListener () {}) "This is the suggested option of the list, which is the only mistake , But there is a suggestion The list goes on to give the list setOnClickListener. "The method onClick type (see) New DialogInterface.OnClickListener () {} should override a super class method"

An easy way to accomplish this task I got another error after override:? Dialog dialog = new dialog (mContext), dialog.setContentView (R. I have something that is clear

  // Now a dialog box context MContext = getApplicationContext () is missing this stick should be layout.custom_dialog); dialog.setTitle ("yoga"); dialog.setCancelable (co ); TextView text 1 = (TextView) dialog.findViewById (R.id.diagtext1); TextView text2 = (TextView) dialog.findViewById (id id.diagtext2); TextView text3 = (TextView) dialog.findViewById (R.id.diagtext3); Button btn = (button) dialog.findViewById (ri d.button); Text1.setText (district); Text2.setText (time); Text3.setText (speed); // ************************************************************************************************* ****** btn.setOnClickListener (New OnClickListener) {@Override Public Zero onClick (see v) {Finish (;)}}); // ************************************************************************************************* ****** dialog.show (); }    

You have to import android.view.View.OnClickListener; To get rid of the first error. Remove onClick () method before

@override See . There is no implementation to override the abstract void as onClickListener declared onClick () .

End () in the call> onClick () method will close your activity / app if there is only one activity, instead you You may want to use the dialog.dismiss () or dialog.cancel () .

Comments