如何在kotlin中连接/追加2个字符串?

5 android android-context kotlin

我试图连接Int一个String这样的输出是String但不确定如何去做.

到目前为止,这是我的代码:

val myMessage = context.getString(R.string.mymessage)
Run Code Online (Sandbox Code Playgroud)

哪里myMessage是String.

现在我想追加一个Int it.myinfo.codeid.

Moi*_*ira 16

您可以使用字符串模板:

"${context.getString(R.string.mymessage)} ${it.myinfo.codeid}"
Run Code Online (Sandbox Code Playgroud)