应用背景图像AlertDilog [英] Apply background image to AlertDilog
本文介绍了应用背景图像AlertDilog的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想在不同的风格来显示一个菜单,我想给背景图片 alertdialog
。
I want to display a menu in a different style for that I want give background image to alertdialog
.
的的任何教程或链接,帮助我实现我的目标。的
推荐答案
好了,你可以自定义视图中创建一个AlertDialog,在自定义视图只分配给你想要的背景。后来设置像AlertDialog自定义视图这一观点。
一个例子:
- 一个RelativeCustomLayout:
well, you can create an AlertDialog within a custom view, in that custom view only assign a background you want. Later set that view like AlertDialog custom view. an example: - A RelativeCustomLayout:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:background="@drawable/shape_1"
android:padding="10dip">
............
</RelativeLayout>
现在,这种充气查看和设置对话框一样自定义视图
now, inflate this view and set like dialog custom view
protected void createCustomDialog(int drawable, String title, String message){
LayoutInflater inflater = LayoutInflater.from(WkActivity.this);
View customDialog = inflater.inflate(R.layout.generic_error_dialog, null);
((TextView)customDialog.findViewById(R.id.genericErrorDialogTitle)).setText(title);
((TextView)customDialog.findViewById(R.id.genericErrorDialogMessage)).setText(message);
((ImageView)customDialog.findViewById(R.id.genericErrorDialogIcon)).setImageResource(drawable);
dialog = new AlertDialog.Builder(WkActivity.this).create();
dialog.setView(customDialog);
dialog.setButton(getText(R.string.listaBusquedasGuardadasNoResultDialogButton), onClickListener);
dialog.show();
}
希望这有助于
这篇关于应用背景图像AlertDilog的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文