Android examples for User Interface:Dialog
Show a yes/no dialog, providing the yes listener function
//package com.java2s; import android.app.AlertDialog; import android.content.Context; import android.content.DialogInterface; public class Main { /**// w w w. j a va 2s . c o m * Show a yes/no dialog, providing the yes listener function */ public static void showYesNoDialog(Context context, int titleRes, int msgRes, DialogInterface.OnClickListener posListener) { new AlertDialog.Builder(context) .setTitle(context.getString(titleRes)) .setMessage(context.getString(msgRes)) .setNegativeButton(android.R.string.no, (dialogInterface, i) -> dialogInterface.cancel()) .setPositiveButton(android.R.string.yes, posListener) .show(); } }