gpt4 book ai didi

java - Android:XML Textview 文本属性

转载 作者:行者123 更新时间:2023-12-01 14:05:26 25 4
gpt4 key购买 nike

我看过一个 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com