如何创建的Andr​​oid上面的自定义对话框?自定义、对话框、Andr、oid

2023-09-07 00:33:41 作者:命运在我手中

有人可以告诉我如何创建上面的对话框查看类似/确切地链接[点击这里] [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可能我应该如何去适应,在给定的alertdialog限制的对话框画面的中间显示这么多TextView的消息?例如: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!!

有人可以告诉我,最简单的方法来获得完全相同的看法,因为我kinna在做相同的应用程序和新到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

///在code实现,当你创建对话框....有这个经过短短都TextView的排列布局只需添加这code和补充,布局ID这个$ C $以下Ç好运气

/// 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;

}