繁体   English   中英

如何将EditText动态添加到android

[英]How to dynamically add edittext to android

我想将edittext动态添加到android显示。 我想在android通讯录中添加类似内容,您可以在其中动态添加字段,如果不需要,可以将其删除。

谢谢您的帮助

动态查看一切

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);

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM