6

我制作了一个自定义对话框,我希望标题具有像 AlertDialog 这样的背景。

更好的说:

它说“自定义对话框”的地方

替代文字

需要有一个像这样的“标题”:

替代文字

我不想只是将图像添加到文本中,而是真正实现显示的完整 UI 样式。

这可能吗?

这是我用于自定义对话框的代码:将图像添加到自定义 AlertDialog

4

2 回答 2

6

Galip 这是对我有用的代码

Dialog dialog = new Dialog(context);

dialog.setContentView(R.layout.dialoglayout);

dialog.setTitle("Pick A Colour");

在我的对话框布局中,我有根元素 RadioGroup

希望能帮助到你。

于 2011-02-03T14:12:32.577 回答
0

那么为什么不使用经典AlertDialog.Builder呢?

AlertDialog.Builder builder = new AlertDialog.Builder( activity );
builder.setTitle( title );
builder.setView( /* Your custom view here */ );

// optional
builder.setPositiveButton( R.string.button_ok, listener );
builder.setNegativeButton( R.string.button_cancel, listener );

AlertDialog alert = builder.create();
alert.show();

然后,您将拥有系统对话框的外观。

于 2011-01-20T15:16:58.480 回答