Reputation: 149
I'm trying to convert TextView into a string and I'm not sure if I'm going about it the right way, below is the code I thought would work but I keep getting errors.
TextView test1 = (TextView)findViewById(R.id.result1);
String testA = test1.getText().toString();
Is this the correct method to do this or is there another way? Any help would be appreciated.
Upvotes: 2
Views: 2586
Reputation: 38168
Your code is correct. Beware that it will only work once onCreate
has been called and your contentView
has been set.
Upvotes: 5