我试图使用带有计数器的forloop添加edittext,但是我不确定为什么它没有显示出来。我在这里错过了一些代码吗?
我尝试登录以查看是否进入,但是不知道为什么Android Studio从未进入for循环。
这些是我的日志
------------------------Current: Num Of AddOn: 2
------------------------Current: Integer Num Of AddOn: 2
`
final LinearLayout ll = (LinearLayout)findViewById(R.id.Maintainaddonlayout);
// //Codes here
ll.removeAllViews();
for(int i = 0; i < intNumOfAddOn;i++){
etFoodName = new EditText(MaintainFoodAddOns.this);
etFoodName.setId(ETFoodID + i);
Log.d("MaintainFoodAddOn","----------------What is the ETFoodID Now(For Loop):" + ETFoodID + i);
etFoodName.setHint("Enter your AddOn Name");
etPrice = new EditText(MaintainFoodAddOns.this);
etPrice.setId(ETPriceID + i);
Log.d("MaintainFoodAddOn","----------------What is the ETFoodID Now(For Loop): " + ETPriceID + i);
etPrice.setHint("Enter your AddOn Price");
ll.addView(etFoodName);
ll.addView(etPrice);
}
Log.d("MaintainFoodAddOn","----------------What is the ETFoodID Now(Outside For Loop): " + ETFoodID);
Log.d("MaintainFoodAddOn","----------------What is the ETFoodID Now(Outside For Loop): " + ETPriceID);
`
我希望编辑文本能够自动创建并显示在模拟器上。