Home > Software engineering >  Why do I get only a part of string when I use getString in Kotlin?
Why do I get only a part of string when I use getString in Kotlin?

Time:07-02

I saved a string in resources file, I run Code A and get Result A, I hope to get the Result B.

What's wrong with my code?

Result A

Recommend the app to a friend

Code A

   val context = LocalContext.current
   val temp=context.getString(R.string.myRecommendContent)


   <string name="myRecommendContent"><a href="#">Recommend</a> the app to a friend</string>

Result B

<a href="#">Recommend</a> the app to a friend

CodePudding user response:

I know that this has been downvoted and all, but have you tried:

    <string name="myRecommendContent">&lt;a href=&quot;#&quot;&gt;Recommend&lt;/a&gt; the app to a friend</string>

By what I can see, it ignores you're "other" elements such as the anchor element and just goes on with the string element itself.

  • Related