android.app.AlertDialog#setButton ( )源码实例Demo

下面列出了android.app.AlertDialog#setButton ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

private void onEnterStartedState() {
    Log.d(TAG, "call onEnterStartedState");
    /* Connect camera */
    if (!connectCamera(getWidth(), getHeight())) {
        AlertDialog ad = new AlertDialog.Builder(getContext()).create();
        ad.setCancelable(false); // This blocks the 'BACK' button
        ad.setMessage("It seems that you device does not support camera (or it is locked). Application will be closed.");
        ad.setButton(DialogInterface.BUTTON_NEUTRAL,  "OK", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
                dialog.dismiss();
                ((Activity) getContext()).finish();
            }
        });
        ad.show();

    }
}
 
源代码2 项目: MOAAP   文件: CameraBridgeViewBase.java
private void onEnterStartedState() {
    Log.d(TAG, "call onEnterStartedState");
    /* Connect camera */
    if (!connectCamera(getWidth(), getHeight())) {
        AlertDialog ad = new AlertDialog.Builder(getContext()).create();
        ad.setCancelable(false); // This blocks the 'BACK' button
        ad.setMessage("It seems that you device does not support camera (or it is locked). Application will be closed.");
        ad.setButton(DialogInterface.BUTTON_NEUTRAL,  "OK", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
                dialog.dismiss();
                ((Activity) getContext()).finish();
            }
        });
        ad.show();

    }
}
 
源代码3 项目: LPR   文件: CameraBridgeViewBase.java
private void onEnterStartedState() {
    Log.d(TAG, "call onEnterStartedState");
    /* Connect camera */
    if (!connectCamera(getWidth(), getHeight())) {
        AlertDialog ad = new AlertDialog.Builder(getContext()).create();
        ad.setCancelable(false); // This blocks the 'BACK' button
        ad.setMessage("It seems that you device does not support camera (or it is locked). Application will be closed.");
        ad.setButton(DialogInterface.BUTTON_NEUTRAL,  "OK", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
                dialog.dismiss();
                ((Activity) getContext()).finish();
            }
        });
        ad.show();

    }
}
 
private void onEnterStartedState() {
    Log.d(TAG, "call onEnterStartedState");
    /* Connect camera */
    if (!connectCamera(getWidth(), getHeight())) {
        AlertDialog ad = new AlertDialog.Builder(getContext()).create();
        ad.setCancelable(false); // This blocks the 'BACK' button
        ad.setMessage("It seems that you device does not support camera (or it is locked). Application will be closed.");
        ad.setButton(DialogInterface.BUTTON_NEUTRAL,  "OK", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
                dialog.dismiss();
                ((Activity) getContext()).finish();
            }
        });
        ad.show();

    }
}
 
源代码5 项目: Form-N-Fun   文件: CameraBridgeViewBase.java
private void onEnterStartedState() {
    Log.d(TAG, "call onEnterStartedState");
    /* Connect camera */
    if (!connectCamera(getWidth(), getHeight())) {
        AlertDialog ad = new AlertDialog.Builder(getContext()).create();
        ad.setCancelable(false); // This blocks the 'BACK' button
        ad.setMessage("It seems that you device does not support camera (or it is locked). Application will be closed.");
        ad.setButton(DialogInterface.BUTTON_NEUTRAL,  "OK", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
                dialog.dismiss();
                ((Activity) getContext()).finish();
            }
        });
        ad.show();

    }
}
 
private void onEnterStartedState() {
    Log.d(TAG, "call onEnterStartedState");
    /* Connect camera */
    if (!connectCamera(getWidth(), getHeight())) {
        AlertDialog ad = new AlertDialog.Builder(getContext()).create();
        ad.setCancelable(false); // This blocks the 'BACK' button
        ad.setMessage("It seems that you device does not support camera (or it is locked). Application will be closed.");
        ad.setButton(DialogInterface.BUTTON_NEUTRAL,  "OK", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
                dialog.dismiss();
                ((Activity) getContext()).finish();
            }
        });
        ad.show();

    }
}
 
源代码7 项目: MOAAP   文件: CameraBridgeViewBase.java
private void onEnterStartedState() {
    Log.d(TAG, "call onEnterStartedState");
    /* Connect camera */
    if (!connectCamera(getWidth(), getHeight())) {
        AlertDialog ad = new AlertDialog.Builder(getContext()).create();
        ad.setCancelable(false); // This blocks the 'BACK' button
        ad.setMessage("It seems that you device does not support camera (or it is locked). Application will be closed.");
        ad.setButton(DialogInterface.BUTTON_NEUTRAL,  "OK", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
                dialog.dismiss();
                ((Activity) getContext()).finish();
            }
        });
        ad.show();

    }
}
 
源代码8 项目: Reader   文件: PdfActivity.java
@Override
public void onBackPressed() {
    if (core != null && core.hasChanges()) {
        mAlertBuilder = new AlertDialog.Builder(mContext);
        DialogInterface.OnClickListener listener = new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
                if (which == AlertDialog.BUTTON_POSITIVE)
                    core.save();

                finish();
            }
        };
        AlertDialog alert = mAlertBuilder.create();
        alert.setTitle("MuPDF");
        alert.setMessage(getString(R.string.document_has_changes_save_them_));
        alert.setButton(AlertDialog.BUTTON_POSITIVE, getString(R.string.yes), listener);
        alert.setButton(AlertDialog.BUTTON_NEGATIVE, getString(R.string.no), listener);
        alert.show();
    } else {
        super.onBackPressed();
    }
}
 
源代码9 项目: MOAAP   文件: CameraBridgeViewBase.java
private void onEnterStartedState() {
    Log.d(TAG, "call onEnterStartedState");
    /* Connect camera */
    if (!connectCamera(getWidth(), getHeight())) {
        AlertDialog ad = new AlertDialog.Builder(getContext()).create();
        ad.setCancelable(false); // This blocks the 'BACK' button
        ad.setMessage("It seems that you device does not support camera (or it is locked). Application will be closed.");
        ad.setButton(DialogInterface.BUTTON_NEUTRAL,  "OK", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
                dialog.dismiss();
                ((Activity) getContext()).finish();
            }
        });
        ad.show();

    }
}
 
private void onEnterStartedState() {
    Log.d(TAG, "call onEnterStartedState");
    /* Connect camera */
    if (!connectCamera(getWidth(), getHeight())) {
        AlertDialog ad = new AlertDialog.Builder(getContext()).create();
        ad.setCancelable(false); // This blocks the 'BACK' button
        ad.setMessage("It seems that you device does not support camera (or it is locked). Application will be closed.");
        ad.setButton(DialogInterface.BUTTON_NEUTRAL,  "OK", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
                dialog.dismiss();
                ((Activity) getContext()).finish();
            }
        });
        ad.show();

    }
}
 
private void onEnterStartedState() {
    Log.d(TAG, "call onEnterStartedState");
    /* Connect camera */
    if (!connectCamera(getWidth(), getHeight())) {
        AlertDialog ad = new AlertDialog.Builder(getContext()).create();
        ad.setCancelable(false); // This blocks the 'BACK' button
        ad.setMessage("It seems that you device does not support camera (or it is locked). Application will be closed.");
        ad.setButton(DialogInterface.BUTTON_NEUTRAL,  "OK", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
                dialog.dismiss();
                ((Activity) getContext()).finish();
            }
        });
        ad.show();

    }
}
 
源代码12 项目: Android-Car-duino   文件: CameraBridgeViewBase.java
private void onEnterStartedState() {
    /* Connect camera */
    if (!connectCamera(getWidth(), getHeight())) {
        AlertDialog ad = new AlertDialog.Builder(getContext()).create();
        ad.setCancelable(false); // This blocks the 'BACK' button
        ad.setMessage("It seems that you device does not support camera (or it is locked). Application will be closed.");
        ad.setButton(DialogInterface.BUTTON_NEUTRAL,  "OK", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
                dialog.dismiss();
                ((Activity) getContext()).finish();
            }
        });
        ad.show();

    }
}
 
源代码13 项目: sudokufx   文件: CameraBridgeViewBase.java
private void onEnterStartedState() {
    Log.d(TAG, "call onEnterStartedState");
    /* Connect camera */
    if (!connectCamera(getWidth(), getHeight())) {
        AlertDialog ad = new AlertDialog.Builder(getContext()).create();
        ad.setCancelable(false); // This blocks the 'BACK' button
        ad.setMessage("It seems that you device does not support camera (or it is locked). Application will be closed.");
        ad.setButton(DialogInterface.BUTTON_NEUTRAL,  "OK", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
                dialog.dismiss();
                ((Activity) getContext()).finish();
            }
        });
        ad.show();

    }
}
 
源代码14 项目: microbit   文件: CommonGUI.java
public static void commonAlertDialog(Context parent, String title, String message) {

        AlertDialog alertDialog = new AlertDialog.Builder(parent, AlertDialog.THEME_HOLO_DARK).create();
        alertDialog.setTitle(title);

        alertDialog.setMessage(Html.fromHtml(message));
        alertDialog.setButton(AlertDialog.BUTTON_NEUTRAL, "OK",
                new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int which) {
                        dialog.dismiss();
                    }
                }
        );

        alertDialog.show();
    }
 
源代码15 项目: restcomm-android-sdk   文件: MainFragment.java
private void showOkAlert(final String title, final String detail)
{
   AlertDialog alertDialog = new AlertDialog.Builder(getActivity(), R.style.SimpleAlertStyle).create();
   alertDialog.setTitle(title);
   alertDialog.setMessage(detail);
   alertDialog.setButton(AlertDialog.BUTTON_NEUTRAL, "OK", new DialogInterface.OnClickListener() {
      public void onClick(DialogInterface dialog, int which)
      {
         dialog.dismiss();
      }
   });
   alertDialog.show();
}
 
源代码16 项目: apigee-android-sdk   文件: AlertDialogManager.java
public void showAlertDialog(Context context, String title, String message) {

    AlertDialog alertDialog = new AlertDialog.Builder(context).create();
    alertDialog.setTitle(title);
    alertDialog.setMessage(message);

    alertDialog.setButton(AlertDialog.BUTTON_POSITIVE, "OK", new DialogInterface.OnClickListener() {
      public void onClick(DialogInterface dialog, int which) {
      }
    });

    alertDialog.show();
  }
 
源代码17 项目: commcare-android   文件: QuestionWidget.java
/**
 * Display extra help, triggered by user request.
 */
private void fireHelpText(final Runnable r) {
    if (!mPrompt.hasHelp()) {
        return;
    }

    // Depending on ODK setting, help may be displayed either as
    // a dialog or inline, underneath the question text

    if (showHelpWithDialog()) {
        AlertDialog mAlertDialog = new AlertDialog.Builder(this.getContext()).create();
        ScrollView scrollView = new ScrollView(this.getContext());
        scrollView.addView(createHelpLayout());
        mAlertDialog.setView(scrollView);

        DialogInterface.OnClickListener errorListener = (dialog, i) -> {
            switch (i) {
                case DialogInterface.BUTTON1:
                    dialog.cancel();
                    if (r != null) r.run();
                    break;
            }
        };
        mAlertDialog.setCancelable(true);
        mAlertDialog.setButton(StringUtils.getStringSpannableRobust(this.getContext(), R.string.ok), errorListener);
        mAlertDialog.show();
    } else {

        if (helpPlaceholder.getVisibility() == View.GONE) {
            expand(helpPlaceholder);
        } else {
            collapse(helpPlaceholder);
        }
    }
}
 
public void saveUser(String result) {
    ResultOfEnroll resultOfEnroll = gson.fromJson(result, ResultOfEnroll.class);
    Log.d(TAG, resultOfEnroll.result.user);


    editor = sharedPreferences.edit();

    editor.putString("BlockchainUserId",resultOfEnroll.result.user);
    editor.apply();

    sendToMongo(resultOfEnroll.result.user);

    // send user id to registeree-api

    // save the user name

    AlertDialog alertDialog = new AlertDialog.Builder(MainActivity.this).create();
    alertDialog.setTitle("Enrollment successful!");
    alertDialog.setMessage("You have been enrolled to the blockchain network. Your User ID is:\n\n" + resultOfEnroll.result.user);
    alertDialog.setButton(AlertDialog.BUTTON_POSITIVE, "CONFIRM",
            new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {
                    dialog.dismiss();
                }
            });
    alertDialog.show();
}
 
源代码19 项目: traccar-manager-android   文件: StartFragment.java
private void onError() {
    startButton.setEnabled(true);

    AlertDialog alertDialog = new AlertDialog.Builder(getActivity()).create();
    alertDialog.setMessage(getString(R.string.error_connection));
    alertDialog.setButton(AlertDialog.BUTTON_NEUTRAL, getString(android.R.string.ok),
            new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {
                    dialog.dismiss();
                }
            });
    alertDialog.show();
}
 
源代码20 项目: lrkFM   文件: FileActivity.java
/**
 * Launches a prompt to create a new directory.
 */
private void launchNewDirDialog() {
    AlertDialog newDirDialog = new AlertDialog.Builder(this)
            .setNegativeButton(R.string.cancel, (dialogInterface, i) -> Log.d(TAG, "Cancel pressed"))
            .setTitle(R.string.new_directory)
            .setView(R.layout.layout_name_prompt)
            .create();
    newDirDialog.setButton(DialogInterface.BUTTON_POSITIVE, getString(R.string.okay), (d, i) -> {
        String newDirName = currentDirectory + File.separator + ((EditText) newDirDialog.findViewById(R.id.destinationName)).getText().toString();
        newDir(new File(newDirName));
        reloadCurrentDirectory();
    });
    newDirDialog.show();
}