gpt4 book ai didi

android - 确定之前是否设置了 Android 首选项

转载 作者:太空宇宙 更新时间:2023-11-03 13:36:37 25 4
gpt4 key购买 nike

我有一个应用程序,它有不同语言的 UI 文本。我不想将其保存在 strings.xml 中,因为我希望用户能够更改它们(而不是依赖于手机的区域设置)。

我已经设置了一个阅读偏好。默认情况下,我希望 UI 采用语言环境值,但如果用户更改了 UI 语言首选项,我希望它使用它。

有什么方法可以确定以前是否设置了首选项?问题是,getInt 让我设置默认值,所以我无法检查(例如)uiLang==null 以确定之前是否设置了首选项。

SharedPreferences settings = getPreferences(MODE_PRIVATE);
//If uiLang has not been set before, then lets use the locale.
uiLang = settings.getInt("uiLang", 1); //English (=1) es default
myUI = new UIText(uiLang);
myTextView.setText(myUI.title);

最佳答案

关于android - 确定之前是否设置了 Android 首选项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6400865/

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