0

I have two variables. I need to show these variables addition and also add some text in textView.

Example

val a val b

The text i needed "Addition is (a+b)"

Sorry if i've done any mistake, I'm a newbie.

Ryan M
  • 18,333
  • 31
  • 67
  • 74
Bemres
  • 1

2 Answers2

0
val a =...
val b =...

val textView =...

In Kotlin you can use interpolation so

textView.text = "Addition is ($a+$b)"

the Android way of doing so is using the strings.xml

<string name="addition">Addition is (%1d+%2d)</string>

And then

textView.text = resources.getString(R.string.addition, a, b)
cutiko
  • 9,887
  • 3
  • 45
  • 59
0
    int c=a+b;
     
    String textNeeded="Addition is "+c;

    textView.setText(textNeeded);
androidLearner
  • 1,654
  • 1
  • 7
  • 13