安卓:添加的EditText编程当按钮是pressed [英] Android: Adding a EditText programatically when a button is pressed

查看:155
本文介绍了安卓:添加的EditText编程当按钮是pressed的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我工作的一个SMS应用。我有一个+按钮,这样,当用户点击该按钮一个新ExitText将在现有的一个用户输入多个电话号码发送文本出现。任何人都可以请当按钮为pressed创建一个新的EditText帮助?

I am working on an SMS application. I have a "+" button so that when user clicks that button a new ExitText will appear under the existing one for user to enter multiple phone numbers to send the text. Can anyone please help with creating a new EditText when a button is pressed?

感谢你,

推荐答案

我会保持一个列表的EditText 对象和添加一个新的

I would keep a List of EditText objects and add a new one

EditText toAdd = new EditText(this);
list.add(toAdd);

在按钮preSS名单。此外,阅读此链接,如何在新的的EditText 添加到您当前布局。 <一href=\"http://stackoverflow.com/questions/2305395/laying-out-views-in-relativelayout-programmatically\">Laying出的RelativeLayout查看编程

to the list on button press. Also, read this link for how to add that new EditText to your current layout. Laying out Views in RelativeLayout programmatically

当你知道用户完成,并要保存号码,通过的EditText 对象的列表迭代

When you know the user is done and wants to save the numbers, iterate through your List of EditText objects.

这篇关于安卓:添加的EditText编程当按钮是pressed的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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