1
I can’t generate the amount of EditTexts
based on the parameter of for
? Where is the error?
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main4);
layout = (LinearLayout) findViewById(R.id.layoutEdits);
int qtd = getIntent().getIntExtra("ValorDados", 0);
vetorEdits = new EditText[qtd];
for (int i = 0; i < qtd; i++) {
vetorEdits[i] = new EditText(Main4Activity.this);
vetorEdits[i].setHint("Valor do Edit " + (i+1));
layout.addView(vetorEdits[i], new ViewGroup.LayoutParams(
LinearLayout.LayoutParams.MATCH_PARENT,
LinearLayout.LayoutParams.WRAP_CONTENT));
}
Does an error appear ? If yes, which ? If not, what behavior does it show ?
– Isac
Appears only 1 Edittext
– Wesley
Maybe because
qtd = 1
– ramaral
@ramaral It was precisely what I was going to say. Confirm the value you have in
qtd
makingLog
ofqtd
before entering thefor
. If possible put up a print of this in the question– Isac
I got it. The problem was in XML. Thank you all.
– Wesley