我试图在Default AlertDialog中显示一条冗长的消息,其中包含以下代码.
public static void showAlert(String message, Context con) {
AlertDialog.Builder dialog = new AlertDialog.Builder(con);
dialog.setTitle(message);
dialog.setPositiveButton(" OK ", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
dialog.dismiss();
}
});
dialog.show();
}
Run Code Online (Sandbox Code Playgroud)
但是当我传递长消息时,警报对话框不显示完整消息.我可以按对话框对齐Dialog的文本.我不想使用自定义对话框.
当我在横向模式下在ICS设备上显示对话框时,对话框显示的宽度与纵向模式下的宽度相同.

但是当对话框处于横向模式时,在运行姜饼的设备上,它会在屏幕上显示宽度,而不是一切都紧凑

他们是否改变了ICS中对话框的显示方式,它不会像第二张图片那样在屏幕上显示?我怎样才能让它像第二张图片一样显示出来,所以它看起来不像第一张图片那么紧凑?
这个应用程序的目标api也是2.2所以我不能使用任何ICS api或任何东西
编辑
这就是我调用对话框的方式
incDialog = new MessageDialog(this, R.style.FullHeightDialog);
incDialog.PopUpMessage(this, oMessage);
Run Code Online (Sandbox Code Playgroud)
对话框位于一个扩展对话框的单独类中
这是PopUpMessage实际显示daialog 的方法
public void PopUpMessage(final Context context, clsMessageRecord oMessage) {
MainActivity.lastMessageClicked = oMessage;
moCallingContext = context;
moMessage = oMessage;
MainActivity.miShownDialogType = DialogID;
MainActivity.setShownMessage(moMessage);
MainActivity.mbIntentWasShown = true;
Log.i(className + "::PopUpMessage", "New Message Dialog Show....");
if (oMessage != null) {
if (oMessage.getIsStation() == true) {
// Incident Message Dialog
this.setContentView(R.layout.message_st);
clsStatusRecord oStation = ControlService.DB.StatusList.GetMessageByECM2ID(oMessage.ECM2ID);
if (oStation != null) {
if (oStation.AllowMapping()) {
ImageButton cmdMapping = …Run Code Online (Sandbox Code Playgroud) 我正在尝试按照Android文档关于多个选择对话框.我有一个问题,我认为这是我正在尝试加载的数组类型.
public void addCondition(View view){
ArrayList<String> mHelperNames= new ArrayList<String>();
mHelperNames.add("Test Item");
mHelperNames.add("Test Item");
mHelperNames.add("Test Item");
mSelectedItems = new ArrayList();
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle("My Title")
.setMultiChoiceItems(mHelperNames, null,
new DialogInterface.OnMultiChoiceClickListener() {
@Override
public void onClick(DialogInterface dialog, int which,
boolean isChecked) {
if (isChecked) {
mSelectedItems.add(which);
} else if (mSelectedItems.contains(which)) {
mSelectedItems.remove(Integer.valueOf(which));
}
}
})
.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int id) {
//Create onlcick method
}
})
.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, …Run Code Online (Sandbox Code Playgroud) 以下是我的代码,用于在GPS关闭时提醒用户.在这里,我的用户必须单击其中一个选项并进一步移动.但是,如果用户点击此警报以外的其他屏幕,此警报将消失.如何阻止此警报对话框自动消失.请帮忙
Builder bd = new AlertDialog.Builder(myTest.this);
bd.setTitle("Alert");
bd.setMessage("GPS is disabled. Do you want to");
bd.setNegativeButton("Enable GPS", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
startActivity(new Intent(android.provider.Settings.ACTION_LOCATION_SOURCE_SETTINGS));
}});
bd.setPositiveButton("Close App", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
finish();
}
});
bd.show();
Run Code Online (Sandbox Code Playgroud) 我想自定义所有对话框,alertDialogs和微调器.我想更改文本的颜色和标题栏的背景.

我试着更好地解释:我希望文本(JOLLY BAR DI ...)是白色的,标题的背景(从对话框顶部到标题下面的软蓝线)是蓝色的(# 044592).
我该怎么做?
如何在标签视图下方显示的Facebook应用中不显示互联网连接消息.

Android是否附带一个对话框,我可以弹出一个显示单个输入文本字段的"确定"和"取消"按钮,还是我必须自己创建?
我知道这可能在此之前讨论过.但我仍然感到困惑,如果我getApplicationContext()用来显示一个Dialog.
我有一个getApplicationContext()用于创建 AlertDialog.Builder的应用程序,当显示对话框时应用程序崩溃.但是,如果我使用SomeActivity.this上下文它工作正常.
注意:这个应用程序现在已经在Play商店中运行了一段时间,之前正在运行,但不确定从哪个Android版本崩溃.
崩溃堆栈跟踪
android.view.WindowManager$BadTokenException: Unable to add window -- token null is not for an application
at android.view.ViewRootImpl.setView(ViewRootImpl.java:540)
at android.view.WindowManagerGlobal.addView(WindowManagerGlobal.java:259)
at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:69)
at android.app.Dialog.show(Dialog.java:286)
at android.app.AlertDialog$Builder.show(AlertDialog.java:951)
Run Code Online (Sandbox Code Playgroud) 我用 - 创建了一个简单的对话框 -
Dialog dialog = new Dialog(Myactivity.this);
dialog.setContentView(R.layout.myLayout);
dialog.show();
Run Code Online (Sandbox Code Playgroud)
当我显示和关闭此对话框时,我想更新textView MyActivity.因此,onResume()当你解雇时,我会假设它被调用dialog.这是真的吗?或者我们还有其他更新方法textView吗?
我想阻止用户输入当前时间之前的时间.我使用before提供的方法检查有效时间Date.如何防止对话框在此有效性检查中接受无效时间?
我在初始化所选时间(作为a Date)时省略了多余的代码.
final Calendar mcurrentTime = Calendar.getInstance();
final int hour = mcurrentTime.get(Calendar.HOUR_OF_DAY);
final int minute = mcurrentTime.get(Calendar.MINUTE);
final TimePickerDialog mTimePicker;
mTimePicker = new TimePickerDialog(MainActivity.this, new TimePickerDialog.OnTimeSetListener() {
@Override
public void onTimeSet(TimePicker timePicker, int selectedHour, int selectedMinute) {
//PSEUDO: Date selectedDateTime init here
if (selectedDateTime.before(mcurrentTime.getTime())) {
// prevent user from selecting time
}
}
}, hour, minute, true);//true = 24 hour time
mTimePicker.setTitle("Select Time");
mTimePicker.show();
Run Code Online (Sandbox Code Playgroud)