Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/198.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 将背景图像应用于AlertDilog_Android_Background_Android Alertdialog - Fatal编程技术网

Android 将背景图像应用于AlertDilog

Android 将背景图像应用于AlertDilog,android,background,android-alertdialog,Android,Background,Android Alertdialog,我想以不同的样式显示一个菜单,我想给alertdialog提供背景图像 帮助我实现目标的任何教程或链接。好的,你可以在自定义视图中创建一个AlertDialog,在该自定义视图中只指定你想要的背景。稍后设置该视图,如AlertDialog自定义视图。 例如: -相对稳定的布局: <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/

我想以不同的样式显示一个菜单,我想给
alertdialog
提供背景图像


帮助我实现目标的任何教程或链接。

好的,你可以在自定义视图中创建一个AlertDialog,在该自定义视图中只指定你想要的背景。稍后设置该视图,如AlertDialog自定义视图。 例如: -相对稳定的布局:

<?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>

希望这有帮助

是的……谢谢你的回复,但我已经完成了……效果很好……再次感谢
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();
    }