1

我已经为自定义对话框实现了以下代码,并希望在标题栏中也放一个图标,但失败了。弹出对话框,左侧没有任何图标。

final Dialog dialog1 = new Dialog(First.this, android.R.style.Theme_Translucent_NoTitleBar);
        dialog1.requestWindowFeature(Window.FEATURE_LEFT_ICON);
        WindowManager.LayoutParams lp = dialog1.getWindow().getAttributes();
        lp.dimAmount = 0.5f;
        dialog1.getWindow().addFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND); 
        dialog1.setCancelable(true);
        dialog1.setContentView(R.layout.alert_dialog);
        dialog1.show();
        dialog1.setFeatureDrawableResource(Window.FEATURE_LEFT_ICON,R.drawable.lemon1_fw);

我尝试了一些在网上找到的评论,似乎放在setFeatureDrawableResource前面或后面没有区别.show()

怎么可能解决?非常感谢!!

4

1 回答 1

0

这是获取对话框自定义布局的简单示例

private Dialog m_ShowAction;
//in onCreate
m_ShowAction = new Dialog(Contacts_List_Activity.this);
m_ShowAction.requestWindowFeature(Window.FEATURE_NO_TITLE);
m_ShowAction.setContentView(R.layout.popup_action_dialog);
m_ShowAction.setCanceledOnTouchOutside(true);
......

//inflate your control on custom Dialog layout like this
ListView lstActionList = (ListView) m_ShowAction.findViewById(R.id.listView1);

并且您可以为自定义布局上的任何控件设置 onclick 或任何内容,例如正常的活动布局

在结束通话时m_ShowAction.show();

于 2013-07-07T10:48:24.817 回答