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