當前位置: 首頁>>代碼示例>>Java>>正文


Java AlertDialog.setIcon方法代碼示例

本文整理匯總了Java中android.app.AlertDialog.setIcon方法的典型用法代碼示例。如果您正苦於以下問題:Java AlertDialog.setIcon方法的具體用法?Java AlertDialog.setIcon怎麽用?Java AlertDialog.setIcon使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.app.AlertDialog的用法示例。


在下文中一共展示了AlertDialog.setIcon方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: 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

示例2: showAlert

import android.app.AlertDialog; //導入方法依賴的package包/類
/**
 * Show dialog
 * @param context Context
 * @param title Title
 * @param layoutResource Layout resource id
 * @param iconResource Icon resource id
 * @return AlertDialog Dialog
 */
static AlertDialog showAlert(Context context, CharSequence title, int layoutResource, int iconResource) {
    @SuppressLint("InflateParams")
    View view = ((Activity) context).getLayoutInflater().inflate(layoutResource, null, false);
    AlertDialog alertDialog = new AlertDialog.Builder(context).create();
    alertDialog.setTitle(title);
    alertDialog.setView(view);
    if (iconResource > 0) {
        alertDialog.setIcon(iconResource);
    }
    alertDialog.show();
    return alertDialog;
}
 
開發者ID:bfabiszewski,項目名稱:ulogger-android,代碼行數:21,代碼來源:Alert.java

示例3: showErrorDialog

import android.app.AlertDialog; //導入方法依賴的package包/類
private void showErrorDialog(String message) {
    AlertDialog alertDialog = new AlertDialog.Builder(this).create();
    alertDialog.setTitle("Error!");
    alertDialog.setMessage(message);
    alertDialog.setIcon(android.R.drawable.alert_dark_frame);
    alertDialog.setButton(DialogInterface.BUTTON_POSITIVE, "OK", new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            MainActivity.this.finish();
        }
    });

    alertDialog.show();
}
 
開發者ID:PacktPublishing,項目名稱:Java-9-Programming-Blueprints,代碼行數:15,代碼來源:MainActivity.java

示例4: showInfo

import android.app.AlertDialog; //導入方法依賴的package包/類
/**
 * Shows an info dialog.
 * 
 * @param context
 *            {@link Context}
 * @param msg
 *            the message.
 * @param listener
 *            the {@link DialogInterface.OnDismissListener}.
 */
public static void showInfo(Context context, CharSequence msg,
        DialogInterface.OnDismissListener listener) {
    AlertDialog dlg = newAlertDlg(context);
    dlg.setIcon(android.R.drawable.ic_dialog_info);
    dlg.setTitle(R.string.afc_title_info);
    dlg.setMessage(msg);
    dlg.setOnDismissListener(listener);
    dlg.show();
}
 
開發者ID:PhilippC,項目名稱:keepass2android,代碼行數:20,代碼來源:Dlg.java

示例5: showError

import android.app.AlertDialog; //導入方法依賴的package包/類
/**
 * Shows an error message.
 * 
 * @param context
 *            {@link Context}
 * @param msg
 *            the message.
 * @param listener
 *            will be called after the user cancelled the dialog.
 */
public static void showError(Context context, CharSequence msg,
        DialogInterface.OnCancelListener listener) {
    AlertDialog dlg = newAlertDlg(context);
    dlg.setIcon(android.R.drawable.ic_dialog_alert);
    dlg.setTitle(R.string.afc_title_error);
    dlg.setMessage(msg);
    dlg.setOnCancelListener(listener);
    dlg.show();
}
 
開發者ID:PhilippC,項目名稱:keepass2android,代碼行數:20,代碼來源:Dlg.java

示例6: confirmYesno

import android.app.AlertDialog; //導入方法依賴的package包/類
/**
 * Shows a confirmation dialog.
 * 
 * @param context
 *            {@link Context}
 * @param msg
 *            the message.
 * @param onYes
 *            will be called if the user selects positive answer (a
 *            <i>Yes</i> or <i>OK</i>).
 * @param onNo
 *            will be called after the user cancelled the dialog.
 */
public static void confirmYesno(Context context, CharSequence msg,
        DialogInterface.OnClickListener onYes,
        DialogInterface.OnCancelListener onNo) {
    AlertDialog dlg = newAlertDlg(context);
    dlg.setIcon(android.R.drawable.ic_dialog_alert);
    dlg.setTitle(R.string.afc_title_confirmation);
    dlg.setMessage(msg);
    dlg.setButton(DialogInterface.BUTTON_POSITIVE,
            context.getString(android.R.string.yes), onYes);
    dlg.setOnCancelListener(onNo);
    dlg.show();
}
 
開發者ID:PhilippC,項目名稱:keepass2android,代碼行數:26,代碼來源:Dlg.java


注:本文中的android.app.AlertDialog.setIcon方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。