创建 EditText 作为输入的值
Create EditText as the entered value
用户将输入一个数字。我如何使用 JAVA 代码创建那么多 EditText
个盒子?
试试这个 --->
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 后,从 activity 的 onCreate() 调用上述代码
用户将输入一个数字。我如何使用 JAVA 代码创建那么多 EditText
个盒子?
试试这个 --->
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 后,从 activity 的 onCreate() 调用上述代码