gpt4 book ai didi

java - 如何为android本地化显示textview动态值

转载 作者:行者123 更新时间:2023-11-29 20:46:44 26 4
gpt4 key购买 nike

你好 friend 我想在我的应用程序中集成多种语言,所以我为不同的语言制作了多个值文件夹。现在我的问题是如何显示来 self 的 web api 的动态 textview 值,它是字符串值。但是如何根据我从应用程序中选择的语言显示语言。下面我提到了我的代码。请帮我。谢谢!

主.java

TextView textView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.fragment_main);
textView=(TextView)findViewById(R.id.textView1);
textView.setText("My custom text which comes from web api");

}

最佳答案

您可以在 TextView 中使用动态值,并在资源文件夹中进行本地化。您可以使用国家代码和语言代码本地化文本。喜欢:

res/values-en/string.xml
res/values-hi/string.xml
res/values-IN-gu/string.xml

Read More

关于java - 如何为android本地化显示textview动态值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30188002/

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