在应用程序级别支持多种语言的Android应用程序

时间:2014-03-28 05:02:20

标签: android multilingual

您好我计划为英语和西班牙语语言开发一个Android应用程序。为此我们将数据存储在Sq lite Database.without取决于设备语言。 应用程序包含存储在sq lite数据库中的长文本值列表和从db中检索并在列表视图中显示的数据。我可以在sq lite中存储不同的语言数据以及如何根据语言选择在视图中检索和显示。

1 个答案:

答案 0 :(得分:1)

您可以在sqlite中创建一个表,其中包含一个列的节点和另外两个包含相同和英语版本的西班牙语版本的列。像:

ID             NODE              SPANISH              ENGLISH
1              LOGIN             S-LOGIN              LOGIN

使用:

Locale current = getResources().getConfiguration().locale;

获取当前语言环境,谷歌稍微了解如何获取当前语言选择。

在活动的onResume方法中:

1. Check the current locale
2. Based on the current locale, fetch the strings for the labels and views 
3. SetText to the views using the strings that you obtain

就是这样。 我希望这一点很有帮助!