【问题标题】:Android - How to set button different value than its string?Android - 如何设置按钮与其字符串不同的值?
【发布时间】:2014-03-11 16:12:27
【问题描述】:

我有写入文本视图的按钮。我想写“?”,但在strings.xml中是不允许的。所以,我希望按钮具有与按钮中的文本不同的值(写入 textview)。我怎样才能做到这一点?提前致谢。

【问题讨论】:

  • 你想做什么?
  • 我想写“?”到带有按钮的文本视图。
  • 您是否已经编写了一些代码?你愿意分享吗?
  • ?在 strings.xml 中允许
  • 不,它说“错误:错误:资源 id 不能是空字符串(在 'buttonq' 处,值为 '?')。”

标签: android button textview


【解决方案1】:

使用

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

转义问号。

【讨论】:

  • 谢谢,它有效。我怎样才能用另一个按钮写一个空格?
【解决方案2】:

另外,您可以通过编程方式尝试 Html.fromHtml。 以下链接讨论了这一点。 android-TextView setText in Html.fromHtml to display image and text

谢谢 杰瑞

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-08-15
    • 2013-06-06
    • 1970-01-01
    相关资源
    最近更新 更多