Back to project page interamap.
The source code is released under:
MIT License
If you think the Android project interamap listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.richso.interamap.dialogue; //ww w . j a va 2 s .com import android.app.Activity; import android.app.AlertDialog; import android.app.Dialog; import android.content.DialogInterface; import android.os.Bundle; import android.support.v4.app.DialogFragment; import com.richso.interamap.utils.Constant; /** * Created with IntelliJ IDEA. * User: nikolai * Date: 10.09.13 * Time: 17:29 * To change this template use File | Settings | File Templates. */ public class WarningDialog extends DialogFragment { private int title = 0; private int message = 0; private int neutralBtn = 0; private int positiveBtn = 0; private int negativeBtn = 0; public interface DialogListener { public void onDialogNeutralClick(DialogFragment dialogFragment); public void onDialogPositiveClick(DialogFragment dialogFragment); public void onDialogNegativeClick(DialogFragment dialogFragment); void showWarningDialog(int title, int message, int positiveBtn, int neutralBtn, int negativeBtn); } DialogListener listener; public WarningDialog(int title, int message, int positiveBtn, int neutralBtn, int negativeBtn) { this.title = title; this.message = message; this.neutralBtn = neutralBtn; this.positiveBtn = positiveBtn; this.negativeBtn = negativeBtn; } @Override public void onAttach(Activity activity) { super.onAttach(activity); try{ listener = (DialogListener)activity; } catch (ClassCastException ex) { throw new ClassCastException(activity.toString() + " must implement NoticeDialogListener"); } } @Override public Dialog onCreateDialog(Bundle savedInstanceState) { AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); builder.setTitle(title); builder.setMessage(message); if( neutralBtn != Constant.NULL_DIALOG ){ builder.setNeutralButton(neutralBtn, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { listener.onDialogNeutralClick(WarningDialog.this); } }); } if( positiveBtn != Constant.NULL_DIALOG ){ builder.setPositiveButton(positiveBtn, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { listener.onDialogPositiveClick(WarningDialog.this); } }); } if( negativeBtn != Constant.NULL_DIALOG ){ builder.setNegativeButton(negativeBtn, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { listener.onDialogNegativeClick(WarningDialog.this); } }); } return builder.create(); } }