本文介绍了如何申请背景图像AlertDilog的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我参加办法我想显示的菜单在不同的风格,我想给背景图片alertdialog。

In my appplication i want to display a menu in a different style for that I want give background image to alertdialog.

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

Any tutorial or link which help me to achieve my goal.

推荐答案

好了,你可以自定义视图中创建一个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();
    }

希望这有助于

hope this helps

这篇关于如何申请背景图像AlertDilog的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-29 20:56