只是一个简单的问题,不知道如何做到这一点。有谁知道如何做到这一点?
原因:我只想要一个没有分区的可靠对话框,因为它在我的应用程序中看起来好一点。
修改
public void showCustomDialog() {
Dialog dialog = new Dialog(this);
dialog.setContentView(R.layout.customdialog);
TextView thisText = (TextView) dialog.findViewById(R.id.customDialogThisText);
thisText.setText("This");
TextView thatText = (TextView) dialog.findViewById(R.id.customDialogThatText);
thatText.setText("That");
ImageView image = (ImageView) dialog.findViewById(R.id.customDialogImageView);
image.setImageResource(R.drawable.icon);
//Crashes the program with an AndroidRuntimeError
//dialog.requestWindowFeature(dialog.getWindow().FEATURE_NO_TITLE);
dialog.show();
}
答案 0 :(得分:2)
只是不要调用setTitle()并且没有标题,如:
LayoutInflater factory = LayoutInflater.from(this);
final View textEntryView = factory.inflate(R.layout.alert_dialog_text_entry, null);
new AlertDialog.Builder(AlertDialogSamples.this)
.setView(textEntryView)
.setPositiveButton(R.string.alert_dialog_ok, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
/* User clicked OK so do some stuff */
}
})
.setNegativeButton(R.string.alert_dialog_cancel, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
/* User clicked cancel so do some stuff */
}
})
.create();
答案 1 :(得分:0)
打电话 dialog.requestWindowFeature(dialog.getWindow()FEATURE_NO_TITLE。); 在设置对话框的视图之前 dialog.setContentView(R.layout.customdialog);