本文整理汇总了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();
}
示例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;
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}