简体   繁体   English

Android中textview上的语言不同

[英]Different language on textview in Android

我怎么能在Android上的textview或edittext上编写不同的语言(Bangla),为此我需要什么版本的API

If you use strings.xml to add a level of indirection for string values, then you can easily localize your strings as in: 如果使用strings.xml为字符串值添加间接级别,则可以轻松地对字符串进行本地化,如下所示:

android:text="@string/main_text_view_hello"

So I have a strings.xml in folders: 所以我在文件夹中有一个strings.xml:

res/values
res/values-en-rCa
res/values-en-rGB

Any time I want to change a value for Canada or United Kingdom, I just add it to the appropriate folder. 任何时候我想更改加拿大或英国的值,我只需将其添加到适当的文件夹。 All other values are obtained by default from res/values. 默认情况下,res / values会获取所有其他值。

You can set text with TextView.setText(String-ID) . 您可以使用TextView.setText(String-ID)设置文本。 String-IDs are managed in strings.xml files which are under res/values folder. String-ID在res / values文件夹下的strings.xml文件中管理。 If you want another language for example german you need another strings.xml file with the same String-IDs in res/values-de. 如果你想要另一种语言,例如德语,你需要另一个strings.xml文件,在res / values-de中使用相同的String-ID。 In android layout files you can reference such string ids with @string/stringid. 在android布局文件中,您可以使用@ string / stringid引用此类字符串ID。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM