0

只是一个简单的问题,不知道该怎么做。有谁知道如何/如果可以做到这一点?

原因:我只想要一个没有分区的实心对话框,因为它在我的应用程序中看起来更好一些。

编辑

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();
}

4

2 回答 2

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();
于 2010-10-22T13:49:51.250 回答
0

只需调用 dialog.requestWindowFeature(dialog.getWindow().FEATURE_NO_TITLE); 在通过 dialog.setContentView(R.layout.customdialog) 设置对话框视图之前;

于 2010-11-03T16:07:21.110 回答