简体   繁体   English

如何在Android中将href字符串值设置为格式字符串?

[英]How Do I make the href string value a format string in android?

I have a text view with 我有一个文本视图

android:autoLink="web" 

and string resource 和字符串资源

<string name="link_text">This is a sample <a href="%1$s"></a> to create</string>

wanted to use something of this sort so i can set the link in code and still get it work using 想使用这种东西,所以我可以在代码中设置链接,并仍然使用它

getString(R.string.link_text, "https:google.com");

You have to use special escape chars : 您必须使用特殊的转义字符:

<string name="link_text">This is a sample &#60;a href="%1$s"&#62;&#60;/a&#62; to create</string>

Here is a list (I'm not sure if it is complete): 这是一个列表(我不确定它是否完整):

"     (&#34; Or &quot;) 
'     (&#39; Or &apos;) 
&     (&#38; Or &amp;) 
lt(<) (&#60; Or &lt;) 
gt(>) (&#62; Or &gt;)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM