不能在Android Studio上使用其他语言(英语除外) [英] Can't use other languages(except English) on Android Studio

查看:95
本文介绍了不能在Android Studio上使用其他语言(英语除外)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在我的android应用中用另一种语言发出警报消息.但是这些文本不会出现在Android Studio中.它们显示为某些未知的字符类型,如在该图像中

I want to make an alert message in another language in my android app. But those texts do not appear in Android studio. They appear as some unknown character types as shown in this image

我该如何解决?

推荐答案

虽然这不能真正回答您的问题,

While this doesn't really answer your question,

我建议不要使用硬编码的字符串,而应使用Android资源系统来支持多种语言,

I suggest that instead of using hardcoded strings, use the Android resources system to support multiple languages,

例如:

英语字符串(默认语言环境),/values/strings.xml :

English strings (default locale), /values/strings.xml:

<resources>
  <string name="hello_world">Hello World!</string>
</resources>

西班牙语字符串(语言环境),/values-es/strings.xml :

Spanish strings (es locale), /values-es/strings.xml:

<resources>
  <string name="hello_world">¡Hola Mundo!</string>
</resources>

然后使用如下语言资源:

Then use the language resource like this:

showMessage(getString(R.string.error_title), getString(R.string.hello_world));

这篇关于不能在Android Studio上使用其他语言(英语除外)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆