Take the 2-minute tour ×

I am trying to pass a string from one activity to another. I retrieved the information like this:

Intent openReadMail = getIntent();
String readfrom = openReadMail.getStringExtra("from");

Now I want to display this string on screen. I this xml TextView element:


but I can't convert the string to a textview, is there a better way of doing this? thanks for your help guys!

share|improve this question
One observation, your TextView should have a layout_height="" attribute as well, otherwise you may get an exception. –  Andy Res Oct 7 '12 at 16:33

2 Answers 2

up vote 2 down vote accepted

You have to create a variable for your TextView and then set the text.

TextView fromtxt = (TextView) findViewById(R.Id.from);

share|improve this answer

You need to set the text of the TextView with the String you read in.

TextView tv = (TextView)findViewById(R.id.from);
share|improve this answer
Thanks guys appreciate that! –  shanahobo86 Oct 7 '12 at 16:18

Your Answer


