0

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?

4

1 Answer 1

2

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.

Sign up to request clarification or add additional context in comments.

1 Comment

If resolved, it is appropriate to accept Peter's vote with the checkmark so that he gets credit for doing so.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.