用户将输入一个数字。如何使用JAVA代码创建该EditText
个框的数量?
答案 0 :(得分:0)
试试这个--->
createMultipleEditTexts(int n) {
for(int i = 0; i < n; i++) {
EditText et = new EditText(this);
// Assign id for future reference probably store it somewhere
et.setId(i)
// Assign layout params to it
LayoutParams params = new LayoutParams(width, height)
et.setParams(params)
// Add it to the root layout of your activity's/view groups view
rootLayout.addView(et);
}
}
从用户那里取得n之后,从你活动的onCreate()调用上面的代码