0

sumTextView.setText(Integer.toString(a) + " + " + Integer.toString(b)); 

This Line show warning you see in pic..

croxy
  • 4,082
  • 9
  • 28
  • 46
  • Possible duplicate of [Android TextView : "Do not concatenate text displayed with setText"](http://stackoverflow.com/questions/33164886/android-textview-do-not-concatenate-text-displayed-with-settext) – Mr.7 Aug 08 '16 at 12:55
  • Not understanding the issue, please post the xml file or log file. – Satish Bonagiri Aug 08 '16 at 12:55

3 Answers3

0

Use String.format();

sumTextView.setText(String.format("%1$d + %2$d", a, b));

With this you can format a string correctly with multiple variables, no matter whether they are strings or integers. This example takes the value of variable a and replaces the placeholder %1$d with it. Same goes for the other variable.

UeliDeSchwert
  • 1,146
  • 10
  • 23
0

take an string copy whole line in it, then show string in setText

String str = (Integer.toString(a) + " + " + Integer.toString(a));
sumTextView.setText(str);
Shahzain ali
  • 1,679
  • 1
  • 20
  • 33
0

1. The First String Says that do not concate string with setText property.

String txt = String.valueOf(a) + " + " + String.valueOf(b);
sumTextView.setText(str);

2. Second warning says that your program have possibility to crash or genearte an exception in case if value of a or b is null or not an integer. So check condition if(a!=null and b!=null) then display text in if condition.

Jitesh Prajapati
  • 2,533
  • 4
  • 29
  • 51