如何在android中创建上述自定义对话框? [英] How to create the above custom dialog in android?

查看:34
本文介绍了如何在android中创建上述自定义对话框?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人可以告诉我如何创建与链接 [此处][1] 类似/完全相同的上述对话框视图,问题的重点是在图片中心创建视图吗?

Can someone tell me how to create the above dialog view similar/exactly to the link [here][1], whereby the focus of the problem is to create the view in the centre of the picture?

我做了一些研究,这让我想知道我应该使用自定义 xml 来创建自定义对话框视图,还是应该使用 alertdialog 来创建上面显示的确切视图可编程性?即使alertdialog 是可能的,我将如何适应对话框图片中间显示的这么多textview 消息给定alertdialog 限制?例如:builder.setMessage("这是警报正文");"如果你知道我的意思!!

I have done some research and it made me wonder should i be using a custom xml to create a custom dialog view or should i be using alertdialog to create the exact view programmability shown above? And even if alertdialog is possible how am i going to accommodate with so many textview messages shown in the middle of the dialog picture given alertdialog limitation? Eg: "builder.setMessage("This is the alert's body");" If you know what i mean!!

有人能告诉我获得完全相同视图的最简单方法吗,因为我正在做同样的应用程序并且是 android 的新手.谢谢 :)

Can someone tell me the easiest way to get the exact same view because i'm kinna doing the same app and new to android.. Thanks :)

推荐答案

最好的方法是自定义对话框.因为这将有助于创建所有这些背景颜色和效果.我确定您发布的链接也使用了自定义对话框,

The best approach will be custom dialog. As it will be helpful creating all those background colours and the effect. I am sure the link you have posted is using custom dialog as well,

干杯

可能有帮助的链接:

[1] http://developer.android.com/guide/topics/ui/dialogs.html#CustomDialog

[2] http://androidideasblog.blogspot.com/2010/02/creating-custom-dialog-in-android.html

///在您的代码实现中,只需在创建对话框时添加此代码....之后只需将所有 TextView 安排在您的布局中,并将该布局 id 添加到下面的代码中,祝您好运

/// In your code implementations just add this code when you create dialog....after having this just have all TextView arranged in your layout and add that layout id to this below code good luck

//Dialog box creator
private Dialog constructYourDialog()
{
    //Preparing views
  LayoutInflater inflater = (LayoutInflater) getSystemService(LAYOUT_INFLATER_SERVICE);
  View layout = inflater.inflate(R.layout.***your_xml_name***, (ViewGroup) findViewById(R.id.***Yout view id***));
    //Building dialog
    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder.setView(layout);

    builder.setPositiveButton("Show Videos", new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
                Log.i("","Show Video Click");
                dialog.dismiss();
    });
    builder.setNegativeButton("E-Mail", new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
           Log.i("","E-mail Click");
           dialog.dismiss();
        }
    });
     builder.setNeutralButton("Show Map", new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            Log.i("","Show Map Click");
            dialog.dismiss();
        }
    });
          AlertDialog alert = builder.create();
    return alert;

}

这篇关于如何在android中创建上述自定义对话框?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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