动态添加一个文本编辑 [英] Dynamically add a Edit text

查看:130
本文介绍了动态添加一个文本编辑的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想编辑的文本字段添加到我的应用程序,当我点击一个按钮,但我不改变布局。只需添加下面的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.

这篇关于动态添加一个文本编辑的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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