如何更改自定义警告对话框的背景 [英] How to change the background of the custom alert dialog
本文介绍了如何更改自定义警告对话框的背景的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个自定义警告对话框,在其中我设置列表视图和它的背景是白色的。
但我得到这样的看法。
这是这是适合截图整个屏幕。
对话D =新的对话框(背景下,android.R.style.Theme_Translucent_NoTitleBar);
CustomDialogListAdapter customDialogAdapter;
ListView控件customList =新的ListView(背景);
customList.setLayoutParams(新的LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.WRAP_CONTENT));
customList.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
customDialogAdapter =新CustomDialogListAdapter(背景下,PaymentInfo.creditCardTypes,类型);
customList.setAdapter(customDialogAdapter);
customList.setBackgroundColor(Color.WHITE);
d.setContentView(customList);
d.show();
在此先感谢..!
解决方案
上下文mContext = getApplicationContext();
对话的对话=新的对话框(mContext,android.R.style.Theme_Translucent_NoTitleBar);
dialog.setContentView(R.layout.custom_dialog);
dialog.show();
以上code将产生一个透明的对话框。所以,你的列表视图背景将是该对话框的唯一背景。
I have a custom alert dialog, in which i set a list view and its background is white.
But i am getting a view like this.
This is the screenshot which is fits entire screen.
Dialog d = new Dialog(context,android.R.style.Theme_Translucent_NoTitleBar);
CustomDialogListAdapter customDialogAdapter;
ListView customList = new ListView(context);
customList.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.WRAP_CONTENT));
customList.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
customDialogAdapter = new CustomDialogListAdapter(context,PaymentInfo.creditCardTypes, type);
customList.setAdapter(customDialogAdapter);
customList.setBackgroundColor(Color.WHITE);
d.setContentView(customList);
d.show();
Thanks in advance..!
解决方案
Context mContext = getApplicationContext();
Dialog dialog = new Dialog(mContext,android.R.style.Theme_Translucent_NoTitleBar);
dialog.setContentView(R.layout.custom_dialog);
dialog.show();
the above code will generate a transparent dialog box. So your listviews background will be the only background for the dialog box.
这篇关于如何更改自定义警告对话框的背景的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文