[英]How to keep URLs in android xml resource file?
I would like to keep human readable URLs in my strings.xml
. 我想在我的strings.xml
保留人类可读的URL。 Some URL contain symbol &
. 一些网址包含符号&
。 Of course, I could replace that with %26
. 当然,我可以用%26
代替它。 But then when I apply url encode to the string, %26
will be replace wiith %2526
and I'll get wrong url. 但是,当我将url编码应用于字符串时, %26
将被替换为%2526
,我将得到错误的url。 Is there any way to avoid that? 有什么办法可以避免这种情况?
Upd. UPD。 I am supposed to have url where another url (taken from resource file is parameter), like: 我应该有另一个URL(从资源文件中获取的是参数)的URL,例如:
http://twitter.com/intent/tweet?text=Some+text&url=http%3A%2F%2Fstackoverflow.com
You should encode &
as &
您应该编码&
为&
. 。
Some other useful, predefined entities in XML are: XML中其他有用的预定义实体包括:
"
for a double quote ( "
) 双引号( "
) <
for a "less than" sign ( <
) 表示“小于”( <
) >
for a "greater than" sign ( >
) 表示“大于”符号( >
) Note that you should put the trailing colon ( ;
). 请注意,您应该在末尾加冒号( ;
)。
Here is the complete list for html escape characters. 这是html转义字符的完整列表 。
@kamituel的答案是正确的,否则,如果您确实需要它们可人工阅读,则可以将它们存储在静态最终变量中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.