我已经为自定义对话框实现了以下代码,并希望在标题栏中也放置一个图标,但是失败了。弹出对话框,左侧没有任何图标。
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()
没有区别;
怎么可以解决?非常感谢!!
答案 0 :(得分: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();