如何向Android动态添加EditText [英] How to dynamically add edittext to android
本文介绍了如何向Android动态添加EditText的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想将edittext动态添加到android显示.我想在android通讯录中创建类似的内容,您可以在其中动态添加字段,并在不需要时将其删除.
I want to add edittext dynamically to the android display. I want to make something like in the android contacts where you can dynamically add fields and remove them if you dont need them.
谢谢您的帮助
推荐答案
动态查看所有内容
TextView tv=new TextView(this);
tv.setText("TaskID");
TextView tv1=new TextView(this);
task=new EditText(this);
task.setMaxWidth(100);
task.setMinHeight(100);
tv1.setText("Task");
id=new EditText(this);
id.setMaxHeight(10);
TextView tv2=new TextView(this);
name=new EditText(this);
name.setMaxHeight(1);
tv2.setText("Name");
LinearLayout l=new LinearLayout(this);
l.setOrientation(LinearLayout.VERTICAL);
l.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
setContentView(l);
l.addView(tv);
l.addView(id);
l.addView(tv1);
l.addView(task);
l.addView(tv2);
这篇关于如何向Android动态添加EditText的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文