问题描述
我想编辑的文本字段添加到我的应用程序,当我点击一个按钮,但我不改变布局。只需添加下面的XML文件中定义一个现有的吧。
可以说我有一个通讯录应用,如果用户需要添加一个额外的字段按下按钮,并创建一个!
那怎么办?
I want to add an edit text field to my app when i click a button, but i do not change the layout. Just add it below an existing one defined by the xml file.Lets say i have a contacts app and if the user needs to add an extra field hit the button and creates one!How to do that?
推荐答案
你可以做的就是有那些的EditText在一个小组,即它们在面板组,然后有一个按钮,按钮点击创建一个EditText的实例并把它添加到相关面板。这样,你是不是限制了自己是唯一能够添加一个面板,而是尽可能用户想加。
What you can do is have those EditText's in a panel, i.e. group them in panels, then have a button, and on button click create an instance of an EditText and add it to the relevant panel. This way you are not limiting yourself to being only able to add one panel, but as much as the user would like to add.
这篇关于动态添加一个文本编辑的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!