如何在Android的alertDialog中取出标题和图标
我需要在单个AlertDialog中有更多的空间,当我将.title设置为null时,它不会显示标题,但也不会向AlertDialog添加任何空间。对话框只是在屏幕的较低位置启动。不使用SetPositiveButton具有所需的效果,但我确实需要关闭按钮。如何设置AlertDialog,以便从屏幕顶部开始显示我的长消息?对于标题和文本。。事实上,我假设您想要创建类似“关于”菜单的内容 您可以使用如何在Android的alertDialog中取出标题和图标,android,android-alertdialog,Android,Android Alertdialog,我需要在单个AlertDialog中有更多的空间,当我将.title设置为null时,它不会显示标题,但也不会向AlertDialog添加任何空间。对话框只是在屏幕的较低位置启动。不使用SetPositiveButton具有所需的效果,但我确实需要关闭按钮。如何设置AlertDialog,以便从屏幕顶部开始显示我的长消息?对于标题和文本。。事实上,我假设您想要创建类似“关于”菜单的内容 您可以使用.setPositiveButton完成活动,并使用.setNegaiveButton取消活动 .s
.setPositiveButton
完成活动,并使用.setNegaiveButton
取消活动
.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
MyActivity.this.finish();
}
})
.setNegativeButton("No", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
dialog.cancel();
}
})
我不想要头衔。我想把单词“Hi!”放在setMessage部分,让用户把它从屏幕上滚下来,让整个屏幕显示我剩下的帮助文本。将标题设置为null或不设置标题都可以,但alertdialog会变小,并保留标题的顶部。尝试此操作,如果不需要图标,请将setIcon(int resId)设置为0。
.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
MyActivity.this.finish();
}
})
.setNegativeButton("No", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
dialog.cancel();
}
})