无法将按钮文本设置为"<<<"

Pam*_*Pam 4 java android button settext

我正试图从我的xml中将按钮的文本设置为"<<<",但我得到一个"错误:(20)解析XML时出错:格式不正确(无效令牌)"

    <Button
        android:id="@+id/test"
        android:text="<<<"
        android:layout_width="wrap_content"
        android:layout_height="match_parent" />
Run Code Online (Sandbox Code Playgroud)

所以我跳到我的strings.xml进入那里,这显然不起作用.

<string name="abc"> <<< </string>
Run Code Online (Sandbox Code Playgroud)

这有解决方法吗?

Khe*_*raj 7

这些是html实体,也适用于android studio:

> can be replaced with &gt;
< can be replaced with &lt;
" can be replaced with &quot;, &ldquo; or &rdquo;
' can be replaced with &apos;, &lsquo; or &rsquo;
} can be replaced with &#125;
& can be replaced with &amp;
space can be replaced with &#160;
Run Code Online (Sandbox Code Playgroud)

  • 你有'<`和`>`错误的方法. (2认同)