如何改变Alertdialog的背景图像 [英] how to change the background image of Alertdialog

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

问题描述

我已经创建了一个AlertDialog.Here我能够改变AlertDialog的和backgroundImage按钮。现在是有可能chnage区域的背景图像在button..I背面都送U屏幕shot..so,它会明确地告诉你我的want..and $ C $词用的是。

I have created an AlertDialog.Here i am able to change the backgroundImage of AlertDialog button. Now is it possible to chnage the background image of area at the back of button..I have send u the screen shot..so that it will make clear to you what i want..and the code i have used is..

        AlertDialog.Builder start_dialog = new AlertDialog.Builder(this);

        TextView start_dialog_title = new TextView(this);
        start_dialog_title.setText(m_res.getString(R.string.strt_dialog_title));
        start_dialog_title.setBackgroundResource(R.drawable.strt_dlg_tlt_bckgrnd);
        start_dialog_title.setGravity(Gravity.CENTER);
        start_dialog_title.setTextColor(Color.WHITE);
        start_dialog_title.setTextSize(20);         

        TextView start_dialog_desc = new TextView(this);
        start_dialog_desc.setText(Html.fromHtml(m_res.getString(R.string.strt_dialog_desc)));
        start_dialog_desc.setPadding(10, 10, 10, 10);
        start_dialog_desc.setBackgroundResource(R.drawable.strt_dlg_desc_bckgrnd);
        start_dialog_desc.setGravity(Gravity.CENTER);
        start_dialog_desc.setTextColor(Color.WHITE);
        start_dialog_desc.setTextSize(15);

        start_dialog.setCustomTitle(start_dialog_title);
        start_dialog.setView(start_dialog_desc);

        start_dialog.setPositiveButton("Ok", new DialogInterface.OnClickListener()
        {                                   
            public void onClick(DialogInterface dialog, int id)
            {
                dialog.cancel();
            }
        });

        AlertDialog alert = start_dialog.create();
        alert.show();
        ((Button)alert.findViewById(android.R.id.button1)).setBackgroundResource(R.drawable.settings_but);

推荐答案

不要设置正面按钮。在布局文件中您自己的按钮。这应该解决您的问题。

Do not set the positive button. Have your own button in the layout file. That should solve your issue.

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

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆