[英]Android EditTextPreference disable Dialog
I want to disable(not show) the Dialog, when i click the EditTextPreference in a Preference Activity. 当我单击首选项活动中的EditTextPreference时,我想禁用(不显示)对话框。
When i click the EditTextPreference, a pop up dialog show. 当我单击EditTextPreference时,会弹出一个弹出对话框。 Now i want to disable this. 现在我想禁用它。 I try set an onclicklistener, but the dialog show same. 我尝试设置一个onclicklistener,但对话框显示相同。
public class Settings extends PreferenceActivity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.settings);
EditTextPreference userName=(EditTextPreference) findPreference("prefUsername");
userName.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
return false;
}
}); ...
I try add this to the EditTextPreference: android:clickable="false", but nothing. 我尝试将此添加到EditTextPreference:android:clickable =“false”,但没有。
Disable it. 禁用它。
Use 采用
android:enabled="false"
in XML. 在XML中。 Or to disable in runtime, 或者在运行时禁用
userName.setEnabled(false);
Actually, if you do not want a dialog, you probably should use simple Preference
instead of EditTextPreference
. 实际上,如果您不想要对话框,则可能应该使用简单的Preference
而不是EditTextPreference
。
try to replace 试着替换
EditTextPreference
with 同
Preference
so your code will be like this 所以你的代码就是这样的
<Preference
android:selectAllOnFocus="true"
android:singleLine="true"
android:title="Version "
android:key="edit_text_preference_1"
android:summary="1.0"
android:enabled="true" />
hope this help you 希望这能帮助你
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.