本文整理汇总了Java中android.app.AlertDialog.setMessage方法的典型用法代码示例。如果您正苦于以下问题:Java AlertDialog.setMessage方法的具体用法?Java AlertDialog.setMessage怎么用?Java AlertDialog.setMessage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.app.AlertDialog
的用法示例。
在下文中一共展示了AlertDialog.setMessage方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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();
}
}
示例2: commonAlertDialog
import android.app.AlertDialog; //导入方法依赖的package包/类
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();
}
示例3: onBackPressed
import android.app.AlertDialog; //导入方法依赖的package包/类
@Override
public void onBackPressed() {
if (core != null && core.hasChanges()) {
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();
}
}
示例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();
}
示例5: 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();
}
}
示例6: onRequestPermissionsResult
import android.app.AlertDialog; //导入方法依赖的package包/类
@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String permissions[],
@NonNull int[] grantResults) {
switch (requestCode) {
case RECORD_AUDIO_PERMISSION: {
if (grantResults.length > 0
&& grantResults[0] == PackageManager.PERMISSION_GRANTED) {
startRecording();
} else {
AlertDialog alertDialog = new AlertDialog.Builder(MainActivity.this).create();
alertDialog.setTitle(R.string.permission_required);
alertDialog.setMessage("Microphone permission is required. App will be closed");
alertDialog.setButton(AlertDialog.BUTTON_NEUTRAL, "OK",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
finishAffinity();
} else {
finish();
}
}
});
alertDialog.show();
}
}
}
}
示例7: onRequestPermissionsResult
import android.app.AlertDialog; //导入方法依赖的package包/类
@Override
public void onRequestPermissionsResult(int requestCode,
String permissions[], int[] grantResults) {
switch (requestCode) {
case MY_PERMISSIONS_REQUEST_LOCATION: {
// If request is cancelled, the result arrays are empty.
if (grantResults.length > 0
&& grantResults[0] == PackageManager.PERMISSION_GRANTED) {
// permission was granted
if (ContextCompat.checkSelfPermission(this,
android.Manifest.permission.ACCESS_FINE_LOCATION)
== PackageManager.PERMISSION_GRANTED) {
if (mGoogleApiClient == null) {
buildGoogleApiClient();
}
mMap.setMyLocationEnabled(true);
}
} else {
// Permission denied, show alert
AlertDialog alertDialog = new AlertDialog.Builder(MainActivity.this).create();
alertDialog.setTitle("Alert");
alertDialog.setMessage("Please allow the location permission!");
alertDialog.setButton(AlertDialog.BUTTON_NEUTRAL, "OK",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
checkLocationPermission();
}
});
alertDialog.show();
}
return;
}
}
}
示例8: onPrepareDialog
import android.app.AlertDialog; //导入方法依赖的package包/类
@Override
public void onPrepareDialog(int dialogId, @NonNull Dialog dialog) {
AlertDialog alert = (AlertDialog) dialog;
switch (dialogId) {
case DIALOG_CONFIRM: {
int messageCount = messagesToDelete.size();
alert.setMessage(getResources().getQuantityString(
R.plurals.dialog_confirm_delete_messages, messageCount, messageCount));
break;
}
}
super.onPrepareDialog(dialogId, dialog);
}
示例9: showAlertDialog
import android.app.AlertDialog; //导入方法依赖的package包/类
private void showAlertDialog(String message) {
AlertDialog alertDialog = new AlertDialog.Builder(this).create();
alertDialog.setTitle("Alert");
alertDialog.setMessage(message);
alertDialog.setButton(AlertDialog.BUTTON_NEUTRAL, "OK",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
}
});
alertDialog.show();
}
示例10: showAlert
import android.app.AlertDialog; //导入方法依赖的package包/类
/**
* 展示一个通用的弹出框UI
*
* @param context 展示弹出框的上下文环境
* @param title 警告的title信息
* @param text 警告信息
*/
public static void showAlert(Context context, String title, String text) {
AlertDialog alertDialog = new Builder(context).create();
alertDialog.setTitle(title);
alertDialog.setMessage(text);
alertDialog.setCanceledOnTouchOutside(true);
alertDialog.show();
}
示例11: 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();
}