java - Android:XML Textview 文本属性

标签 java android xml eclipse

我看过一个 Android 教程,它允许使用简单的 android:text,就像下面的示例一样:

<TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Android Application" android:textColor="#ffffff" />

但在我的 eclipse 中, 它说:

[I18N] Hardcoded string "Android Application", should use @string resource

我应该做什么?

我需要插入很多文本,就像,

Accounting has begun since time immemorial. Consider this truth: God said unto Noah; “and every living thing of all flesh, two of every sort shall thou bring into the ark, to keep them alive with thee; they shall be male and female. Of fowls after their kind, and of cattle after their kind, of every creeping thing of the earth after his kind, two of every sort shall come unto thee, to keep them alive. And take thou unto thee of all food that is eaten, and thou shall gather it to thee; and it shall be for food for thee, and for them.” The Bible – Genesis 6:19-20. “Of every clean beast thou shall take to thee by sevens, the male and his female: and of the beast that are not clean by two, the male and his female. Of fowls of the air by sevens, the male and the female; to keep seed alive upon the face of all earth.” The Bible – Genesis 7:2-3

有什么建议或告诉我更好的做法吗?

最佳答案

这只是一个警告。

但是通过使用字符串资源,您可以支持多语言。

您只需在文件 strings.xml 中创建一个新的字符串资源即可(res/values/strings.xml)。

然后添加行:

<string name="your_name">Your text</string>

只需更改:

android:text="Android Application"通过android:text="@string/your_name"

现在,如果您想向应用程序添加一种新语言(例如法语),您只需在 res 中创建一个新文件夹即可。名为 values-fr 的文件夹并复制/粘贴文件 strings.xml您已经拥有并最终翻译了您定义的字符串(即 <string name="your_name">Your text translated in french</string> )

您可以查看this (使用屏幕截图解决了问题)。

关于java - Android:XML Textview 文本属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18943030/

相关文章:

android - 避免使用 'px' 作为单位,改用 'dp'

android - 我应该担心在收到付款之前将 Apk 发送给客户吗?

Android 推送通知消息格式

android - 解析 XML 文件时出现非法参数异常

java - 从我的文件中删除空行

java - 在启动时启动应用程序

java - 在 Mac 和 Windows 上从 swing 打印 - Postscript 支持在哪里?

java - 尝试从以前的数组创建 ArrayList<Object> - Java

wpf - 边框背景上的 Style.DataTrigger

javascript - HTML5 游戏的对象存储 - 使用什么?