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
  • 15,686
  • 29
  • 53
  • 64
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
  • 8,436
  • 3
  • 41
  • 53
0
    int c=a+b;
     
    String textNeeded="Addition is "+c;

    textView.setText(textNeeded);
androidLearner
  • 1,534
  • 1
  • 6
  • 13