gpt4 book ai didi

android - 编辑文本首选项

转载 作者:行者123 更新时间:2023-11-29 14:08:17 24 4
gpt4 key购买 nike

抱歉问了一个愚蠢的问题。

我有EditTextPreference...如何检查他的文本是否为空?

public void onSharedPreferenceChanged(SharedPreferences sharedPreference,
String key) {
String editorText= (editTextPreference.getText()).trim();
if (editorText== "") {
editorText.setText("Something");
}
}

那不行....

最佳答案

您还应该检查是否为 null。

尝试一下:

if (TextUtils.isEmpty(editTextPreference.getText())) {
editorText.setText("Something");}

关于android - 编辑文本首选项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5403715/

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