Reputation: 433
Please explain how this for loop
works:
Button submit = new Button(this);
submit.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
for (EditText editText : editTexts) {
editText.getText().toString();
// whatever u want to do with the strings
}
}
Particularly, what does the for (EditText editText : editTexts)
part do?
Upvotes: 0
Views: 58
Reputation: 2657
This is saying for each EditText view within editTexts (an array or collection).
EXAMPLE
If editTexts was an array of editTexts like et1,et2,et3,et4 This loop would start at et1 accomlish all the work in the inner loop then go to et2 and do the same thing over and over until after et4 it will exit the loop.
Upvotes: 2
Reputation: 14199
its for-each loop, EditText editText
within array of editTexts
Upvotes: 0
Reputation: 1335
You should look at the type of 'editTexts'. It seems to be a simple 'foreach' loop in java.
Upvotes: 0