Android 创建编辑文本

Android 创建编辑文本,android,android-edittext,Android,Android Edittext,我想在布局中重复创建对象。 实例 我有一个带有EditText的布局,我想创建50个EditText,如果不在xml文件中写入50,我怎么办 一旦完成,我如何读取数据而不用在java中创建50个变量 感谢您在活动中创建一个布局,然后使用for循环添加视图,例如LineatLayout mLayout=new LinearLayout(此);对于(inti=0;i请尝试以下代码 ArrayList<Button> list = new ArrayList<Button>()

我想在布局中重复创建对象。 实例 我有一个带有EditText的布局,我想创建50个EditText,如果不在xml文件中写入50,我怎么办

一旦完成,我如何读取数据而不用在java中创建50个变量


感谢您在活动中创建一个布局,然后使用for循环添加视图,例如LineatLayout mLayout=new LinearLayout(此);对于(inti=0;i请尝试以下代码

ArrayList<Button> list = new ArrayList<Button>();
Button b = new Button(MyActivity.this);
LinearLayout view = (LinearLayout) findViewById(android.R.id.content);
view.addView(b);
list.add(b);
ArrayList list=new ArrayList();
按钮b=新按钮(MyActivity.this);
LinearLayout视图=(LinearLayout)findViewById(android.R.id.content);
视图。添加视图(b);
列表.添加(b);