当前位置: 首页>>代码示例>>Java>>正文


Java AlertDialog.setButton方法代码示例

本文整理汇总了Java中android.app.AlertDialog.setButton方法的典型用法代码示例。如果您正苦于以下问题:Java AlertDialog.setButton方法的具体用法?Java AlertDialog.setButton怎么用?Java AlertDialog.setButton使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.app.AlertDialog的用法示例。


在下文中一共展示了AlertDialog.setButton方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onEnterStartedState

import android.app.AlertDialog; //导入方法依赖的package包/类
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();

    }
}
 
开发者ID:daquexian,项目名称:DNNLibrary,代码行数:18,代码来源:CameraBridgeViewBase.java

示例2: onEnterStartedState

import android.app.AlertDialog; //导入方法依赖的package包/类
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();

    }
}
 
开发者ID:hoangphuc3117,项目名称:Android-Crop-Receipt,代码行数:17,代码来源:CameraBridgeViewBase.java

示例3: deleteAllCalls

import android.app.AlertDialog; //导入方法依赖的package包/类
private void deleteAllCalls() {
    AlertDialog alertDialog = new AlertDialog.Builder(getActivity()).create();
    alertDialog.setTitle(R.string.callLog_delDialog_title);
    alertDialog.setMessage(getString(R.string.callLog_delDialog_message));
    alertDialog.setButton(AlertDialog.BUTTON_POSITIVE, getString(R.string.callLog_delDialog_yes),
            new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {
                    getActivity().getContentResolver().delete(SipManager.CALLLOG_URI, null,
                            null);
                }
            });
    alertDialog.setButton(AlertDialog.BUTTON_NEGATIVE, getString(R.string.callLog_delDialog_no),
            (DialogInterface.OnClickListener) null);
    try {
        alertDialog.show();
    } catch (Exception e) {
        Log.e(THIS_FILE, "error while trying to show deletion yes/no dialog");
    }
}
 
开发者ID:treasure-lau,项目名称:CSipSimple,代码行数:20,代码来源:CallLogListFragment.java

示例4: showAlertDialog

import android.app.AlertDialog; //导入方法依赖的package包/类
public void showAlertDialog(Context context, String title, String message,
                            Boolean status) {
    AlertDialog alertDialog = new AlertDialog.Builder(context).create();
    alertDialog.setTitle(title);
    alertDialog.setMessage(message);
    if(status != null)
        alertDialog.setIcon((status) ? R.drawable.success : R.drawable.fail);
        alertDialog.setButton("Тийм", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {
        }
    });
    alertDialog.show();
}
 
开发者ID:tortuvshin,项目名称:actions,代码行数:14,代码来源:AlertDialogManager.java

示例5: alert

import android.app.AlertDialog; //导入方法依赖的package包/类
public static void alert(final Object context,
    final String message, final String title,final String buttonText) {
  Log.i("RuntimeErrorAlert", "in alert");
  AlertDialog alertDialog = new AlertDialog.Builder((Context) context).create();
  alertDialog.setTitle(title);
  alertDialog.setMessage(message);
  alertDialog.setButton(buttonText, new DialogInterface.OnClickListener() {
    public void onClick(DialogInterface dialog, int which) {
      ((Activity) context).finish();
    }});
  if (message == null) {
    // Avoid passing null to Log.e, which would cause a NullPointerException.
    Log.e(RuntimeErrorAlert.class.getName(), "No error message available");
  } else {
    Log.e(RuntimeErrorAlert.class.getName(), message);
  }
  alertDialog.show();
}
 
开发者ID:mit-cml,项目名称:appinventor-extensions,代码行数:19,代码来源:RuntimeErrorAlert.java

示例6: showConfirm

import android.app.AlertDialog; //导入方法依赖的package包/类
/**
 * Show confirmation dialog, OK and Cancel buttons
 * @param context Context
 * @param title Title
 * @param message Message
 * @param yesCallback Positive button callback
 */
static void showConfirm(Context context, CharSequence title, CharSequence message,
                               DialogInterface.OnClickListener yesCallback) {
    AlertDialog alertDialog = initDialog(context, title, message);
    alertDialog.setButton(AlertDialog.BUTTON_POSITIVE, context.getString(R.string.ok), yesCallback);
    alertDialog.setButton(AlertDialog.BUTTON_NEGATIVE, context.getString(R.string.cancel),
            new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {
                    dialog.dismiss();
                }
            });
    alertDialog.show();
}
 
开发者ID:bfabiszewski,项目名称:ulogger-android,代码行数:20,代码来源:Alert.java

示例7: createRateDialog

import android.app.AlertDialog; //导入方法依赖的package包/类
public static Dialog createRateDialog(Context context,
                                      DialogInterface.OnClickListener onClickListener) {
    AlertDialog rateDialog = new AlertDialog.Builder(context).create();
    rateDialog.setTitle(context.getString(R.string.dialog_rate_app_title));
    rateDialog.setMessage(context.getString(R.string.dialog_rate_app_text));
    rateDialog.setButton(AlertDialog.BUTTON_POSITIVE, context.getString(R.string.dialog_positive_button_text), onClickListener);
    rateDialog.setButton(AlertDialog.BUTTON_NEGATIVE, context.getString(R.string.dialog_negative_button_text), onClickListener);
    rateDialog.setButton(AlertDialog.BUTTON_NEUTRAL, context.getString(R.string.dialog_neutral_button_text), onClickListener);
    return rateDialog;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:11,代码来源:DialogFactory.java

示例8: showInfo

import android.app.AlertDialog; //导入方法依赖的package包/类
/**
 * Show information dialog with OK button
 * @param context Context
 * @param title Title
 * @param message Message
 */
static void showInfo(Context context, CharSequence title, CharSequence message) {
    AlertDialog alertDialog = initDialog(context, title, message);
    alertDialog.setButton(AlertDialog.BUTTON_NEUTRAL, context.getString(R.string.ok),
            new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {
                    dialog.dismiss();
                }
            });
    alertDialog.show();
}
 
开发者ID:bfabiszewski,项目名称:ulogger-android,代码行数:17,代码来源:Alert.java

示例9: renameFile

import android.app.AlertDialog; //导入方法依赖的package包/类
/**
 * Allows to rename file by given file path and a new file name.
 *
 * @param filePath Full path to the file.
 * @param newName  New name of the file.
 */
public void renameFile(String filePath, String newName) {

    FileUtils.RenameResult renameResult = FileUtils.renameFile(filePath, newName);
    if(renameResult != FileUtils.RenameResult.SUCCESS) {
        AlertDialog alertDialog = new AlertDialog.Builder(this).create();
        alertDialog.setTitle("Alert");

        String message = "OOPS!";
        switch(renameResult) {
            case NEW_PATH_ALREADY_EXIST:
                message = "Cannot rename, destination file already exists.";
                break;

            case OLD_PATH_NOT_CORRECT:
                message = "Cannot rename, source file not exist.";
                break;

            case RENAME_ERROR:
                message = "Rename operation failed.";
                break;
        }

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

        alertDialog.show();
    } else {
        updateProjectsListSortOrder(true);
    }
}
 
开发者ID:Samsung,项目名称:microbit,代码行数:42,代码来源:ProjectActivity.java


注:本文中的android.app.AlertDialog.setButton方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。