安卓:添加的EditText编程当按钮是pressed [英] Android: Adding a EditText programatically when a button is 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屋!