Example usage for android.content DialogInterface BUTTON1

List of usage examples for android.content DialogInterface BUTTON1

Introduction

In this page you can find the example usage for android.content DialogInterface BUTTON1.

Prototype

int BUTTON1

To view the source code for android.content DialogInterface BUTTON1.

Click Source Link

Usage

From source file:org.smap.smapTask.android.activities.MainTabsActivity.java

private void createErrorDialog(String errorMsg, final boolean shouldExit) {
    mAlertDialog = new AlertDialog.Builder(this).create();
    mAlertDialog.setIcon(android.R.drawable.ic_dialog_info);
    mAlertDialog.setMessage(errorMsg);//  w  ww .  j  a va  2 s  . com
    DialogInterface.OnClickListener errorListener = new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int i) {
            switch (i) {
            case DialogInterface.BUTTON1:
                if (shouldExit) {
                    finish();
                }
                break;
            }
        }
    };
    mAlertDialog.setCancelable(false);
    mAlertDialog.setButton(getString(R.string.ok), errorListener);
    mAlertDialog.show();
}

From source file:org.odk.collect.android.activities.GoogleDriveActivity.java

private void createAlertDialog(String message) {
    Collect.getInstance().getActivityLogger().logAction(this, "createAlertDialog", "show");

    AlertDialog alertDialog = new AlertDialog.Builder(this).create();
    alertDialog.setTitle(getString(R.string.download_forms_result));
    alertDialog.setMessage(message);//  w w w  .  j  a  v a 2  s .com
    DialogInterface.OnClickListener quitListener = new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int i) {
            switch (i) {
            case DialogInterface.BUTTON1: // ok
                Collect.getInstance().getActivityLogger().logAction(this, "createAlertDialog", "OK");
                alertShowing = false;
                finish();
                break;
            }
        }
    };
    alertDialog.setCancelable(false);
    alertDialog.setButton(getString(R.string.ok), quitListener);
    alertDialog.setIcon(android.R.drawable.ic_dialog_info);
    alertShowing = true;
    alertMsg = message;
    alertDialog.show();
}