Reputation: 15
There are 3 activities. The text value of Textview in the first and second activity is shown in EditText of third activity.
Mainactivity - Textview1 text
Secondactivity - Textview2 text
Displayactivity - Edittext=Textview1+Textview2
Using intent I have tried to pass the the TextView values of both activities to third activity. In the third activity I concatenated by simply using + in EditText. I am trying to show previous textview values in one paragraph i.e. EditText.
This code is on third activity :
Display activity
Intent intent = getIntent();
String displayingtext = intent.getStringExtra("message");
String displayingsecondtext = intent.getStringExtra("hey");
editText.setText(displayingtext+displayingsecondtext);
displayingtext name: message is from first activity
displaysecondtext name : hey is from second activity
The output displayed is from the first textview and the next word null.
In the code it shows
"Don't use concatenate on setText. Use android resources"
Input:
Textview1= Hello,monday.
Textview2=Bye, monday.
Expected Output:
Editext=Hello,monday.Bye monday.
Upvotes: 0
Views: 715
Reputation: 58
OK I got it.. It is saying that you have to put them in resources.. If your application doesn't use multiple language support, then you can simply neglect the warning
Upvotes: 0
Reputation: 1361
Using greenbot event bus you can do it better...
best example for event bus try it...
Upvotes: 0
Reputation: 369
U need to send the "message" got form Activity1 & "hey" in the Activity2 startActivity intent param to Activity3.
It is just a warning as Android Studio Lint tool check the setText method param use a '+' operator. Consider fix it like this:
String resultText = displayingtext+displayingsecondtext;
editText.setText(resultText);
Upvotes: 0
Reputation: 536
Use concat() method from java.lang.String insted of "+" operator.
String displayingtext = intent.getStringExtra("message");
String displayingsecondtext = intent.getStringExtra("hey");
editText.setText(displayingtext.concat(displayingsecondtext));
Upvotes: 0