Reputation: 35
I have made a list of names that I need to send to a different activity like this:
for(i=0;i<n;i++)
{
imena[i] = player[i].toString();
}
allPlayers = new ArrayList<String>();
Collection l = Arrays.asList(imena);
allPlayers.addAll(l);
I'm not sure if this is correct, but then in the other activity I need to set the text of dynamically made EditText boxes to the names that I have set to my list, this is my try:
if(bundle!= null)
{
allPlayers = bundle.getStringArrayList("allPlayers");
for (i = 0;i<n;i++)
{
player[i] = new EditText(getApplicationContext());
player[i].setTextSize(20);
String p1 = allPlayers.get(i).toString();
player[i].setText(p1);
root.addView(player[i]);
}
}
As a result I get the EditBoxes filled with the text: "Android.widget.EditText{4085a09....}" any ideas how to get the actual names in those boxes?
Upvotes: 0
Views: 197
Reputation: 32878
You have:
imena[i] = player[i].toString();
Note that player
is an array of EditText, not String, so you need to call player[i].getText().toString()
rather than player[i].toString()
to get the value of the EditText.
Upvotes: 2