SoFunction
Updated on 2025-04-07

A dialog instance with confirmation and cancellation pops up

A dialog instance with confirmation and cancellation pops up

Updated: March 16, 2017 09:25:38 Submission: jingxian
Below, the editor will bring you a pop-up dialog example with confirmation and cancellation. The editor thinks it is quite good, so I will share it with you now and give you a reference. Let's take a look with the editor

Examples are as follows:

/**
  * A dialog with confirmation and cancellation pops up
  * @param context
  * @param title
  * @param msg
  * @param okbutton
  * @param ok Click to confirm event
  * @param nobutton
  * @param no Click to cancel the event
  * @return
  */
public static AlertDialog openConfirmDialog(Context context, String title,
String msg, String okbutton, OnClickListener ok, String nobutton,
OnClickListener no) {
Builder builder = new Builder(context);
(title);
("\n" + msg + "\n");
(okbutton, ok);
(nobutton, no);
AlertDialog loadWaitDialog = ();
(false);
();
return loadWaitDialog;

}







/**
 * Listen back button
 */
public boolean onKeyDown(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_BACK) {

 (this, "", "Whether to exit?", "Sure",
new () {


@Override
public void onClick(DialogInterface dialog,
int which) {
//TODO
}
}, "Cancel", new () {


@Override
public void onClick(DialogInterface dialog,
int which) {

                                //TODO
}
});

return false;
}

The above article pops up a dialog example with confirmation and cancellation. This is all the content I share with you. I hope you can give you a reference and I hope you can support me more.

  • pop up
  • confirm
  • Cancel
  • dialog

Related Articles

  • Detailed explanation of the reflection mechanism in Android development

    The reflection mechanism is in the running state. For any class, you can know all the properties and methods of this class. For any object, you can call all its methods and properties and modify some type information. This dynamic acquisition of information and dynamically call object methods is called Java's reflection mechanism.
    2022-11-11
  • Android programming method to operate contacts (query, get, add, etc.)

    This article mainly introduces the methods of Android programming to operate contacts, including query, acquisition, addition and other operations for contacts. It has certain reference value. Friends who need it can refer to it.
    2016-01-01
  • Android implements cross-process update UI example through RemoteViews

    This article mainly introduces the example of Android's cross-process update UI through RemoteViews. The editor thinks it is quite good. Now I will share it with you and give you a reference. Let's take a look with the editor
    2017-02-02
  • Sample code for communication between Android devices via Wifi

    This article mainly introduces the sample code for communication between Android devices through Wifi. The editor thinks it is quite good. Now I will share it with you and give you a reference. Let's take a look with the editor
    2018-01-01
  • A summary of issues with Android Easeui 3.0 instant messaging

    This article mainly introduces relevant information about Android Easeui 3.0 instant messaging issues. Friends who need it can refer to it.
    2016-09-09
  • Android car multimedia development MediaSession framework example detailed explanation

    This article mainly introduces a detailed explanation of the MediaSession framework example of Android car multimedia development. Friends in need can refer to it for reference. I hope it can be helpful. I wish you more progress and get a promotion as soon as possible.
    2022-10-10
  • In-depth analysis of the image loading function in Android's Volley library

    This article mainly introduces the image loading function in the Volley framework of Android, analyzes the request queue processing when Volley loads pictures from the source code. Friends who need it can refer to it
    2016-04-04
  • Android md5 encryption and rsa encryption and decryption implementation code

    This article will introduce the sharing of encryption and decryption implementation codes of MD5 and RSA on Android in detail. If you need to know more, please refer to it.
    2012-12-12
  • Android imitation music Yuetai page interactive effect example code

    This article mainly introduces the sample code of the Android imitation music music platform page playback effect. The new version of the music music music platform APP playback page interaction is very interesting. You can drag the player down, then float a small box at the bottom, and you can drag left and right.
    2017-01-01
  • Basic usage examples of Android's multimedia management library Glide

    This article mainly introduces the basic usage examples of Android's multimedia management library Glide. Glide performs very well in the picture app. Google's Yelp is also used. Friends who need it can refer to it.
    2016-04-04

Latest Comments