在AlertDialog多的EditText对象 [英] Multiple EditText objects in AlertDialog

查看:147
本文介绍了在AlertDialog多的EditText对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我工作的一个项目上大学,可以让用户的地方在地图上的一个点,然后设置标题和描述的覆盖对象。问题是,在第二箱的EditText覆盖的第一个。这是我的code的对话框。

I'm working on a project for college that will let a user place a point on a map and then set the title and description for the Overlay object. The problem is, the second EditText box overwrites the first one. Here is my code for the dialog box.

            //Make new Dialog
            AlertDialog.Builder dialog = new AlertDialog.Builder(mapView.getContext());
            dialog.setTitle("Set Target Title & Description");
            dialog.setMessage("Title: ");

            final EditText titleBox = new EditText(mapView.getContext());
            dialog.setView(titleBox);

            dialog.setMessage("Description: ");
            final EditText descriptionBox = new EditText(mapView.getContext());
            dialog.setView(descriptionBox);

任何帮助将是AP preciated!谢谢!

Any help would be appreciated!! Thanks!

推荐答案

就像任何其他的布局,则需要在两个EditTexts添加到ViewGroup中:

Just like any other layout, you need to add both EditTexts to a ViewGroup:

Context context = mapView.getContext();
LinearLayout layout = new LinearLayout(context);
layout.setOrientation(LinearLayout.VERTICAL);

final EditText titleBox = new EditText(context);
titleBox.setHint("Title");
layout.addView(titleBox);

final EditText descriptionBox = new EditText(context);
descriptionBox.setHint("Description");
layout.addView(descriptionBox);

dialog.setView(layout);

这是一个基本的例子,但它应该让你开始。

This is a basic example, but it should get you started.

这篇关于在AlertDialog多的EditText对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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