警报消息是不是在警告对话框中显示? [英] Alert message is not displaying in alert dialog box?

查看:245
本文介绍了警报消息是不是在警告对话框中显示?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要显示的提醒对话框设备的屏幕尺寸。我通过这个链接<一个得到了解决href=\"http://stackoverflow.com/questions/2306503/how-to-make-an-alert-dialog-fill-90-of-screen-size\">How作出警告对话框填补90%的屏幕尺寸?我用给那里的解决方案,它工作得很好,但我的警报消息显示在非常小的尺寸。我们甚至无法辨认出横向的消息。我用下面的code。

I want to display the alert dialog box to device screen size. I got the solution through this link How to make an alert dialog fill 90% of screen size? I use the solution given there, it works just fine but my alert message is displaying in very small size. we can't even make out the message in landscape orientation. I have used the following code.

AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setMessage(R.string.app_description).setPositiveButton(
                    "Ok", new DialogInterface.OnClickListener() {
                        public void onClick(DialogInterface dialog, int id) {
                            dialog.dismiss();
                        }
                    });
            builder.Title(title);

            Dialog d = builder.setView(new View(this)).create();
            WindowManager.LayoutParams lp = new WindowManager.LayoutParams();
            lp.copyFrom(d.getWindow().getAttributes());
            lp.width = WindowManager.LayoutParams.FILL_PARENT;
            lp.height = WindowManager.LayoutParams.FILL_PARENT;
            d.show();
            d.getWindow().setAttributes(lp);

如何设置的信息,所以它会在对话窗口中正确显示?

How to set the message, so that it will properly display in the dialog window?

在此先感谢
普什帕

Thanks in advance Pushpa

推荐答案

勾选此code和告诉我,如果这就是你真正想要达到什么目的?

Check this code and tell me if that's what you really wanted to achieve ?.

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

    // Creates textview
    TextView text = new TextView(this);  
    text.setText("Hello This text");  
    text.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
    text.setTextSize(20);        
    text.setGravity(Gravity.CENTER);

    //Creates a linearlayout layout and sets it with initial params
    LinearLayout ll = new LinearLayout(this);
    ll.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
    ll.setGravity(Gravity.CENTER);
    ll.addView(text);  //adds textview to llayout

    builder.setMessage("Title").setPositiveButton(
            "Ok", new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int id) {
                    dialog.dismiss();
                }
            }); 

    Dialog d = builder.setView(ll).create();   

    //Fills up the entire Screen
    WindowManager.LayoutParams lp = new WindowManager.LayoutParams();
    lp.copyFrom(d.getWindow().getAttributes());
    lp.width = WindowManager.LayoutParams.FILL_PARENT;
    lp.height = WindowManager.LayoutParams.FILL_PARENT;
    d.show();
    d.getWindow().setAttributes(lp);

这篇关于警报消息是不是在警告对话框中显示?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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