特殊字符(@,?)作为Android应用XML字符串 [英] special chars (@, ?) as xml-string in android app

查看:370
本文介绍了特殊字符(@,?)作为Android应用XML字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我尝试做这样的事情,这是行不通的...
(空字符串或没有资源类型错误)

If i try to do things like this, it doesn't work... (empty string or no resource type error)

<string name="random">?</string>
<string name="random">@</string>

我也试过HTML实体变量

i also tried the html entity variant

<string name="random">&#63;</string>

任何想法如何使用?和@作为Android的字符串资源?

any ideas how to use the "?" and "@" as string resource in android?

推荐答案

最简单方法是引号和反斜线他们:

Easiest way is to quote or backslash them:

<string name="random">"?"</string>
<string name="random">\?</string>

请参阅这里和的这里多一点讨论。

See here and here for a bit more discussion.

  • ? reference styling attributes
  • @ signs access other resources.

下面是一个较大的字符串资源陷阱收集的。

这篇关于特殊字符(@,?)作为Android应用XML字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆