在preference中需要用到一个EditTextPreference,然后需要对输入的内容进行限制,必须只能是整数,所以将EditTextPreference中的xml文件中的dialogLayout属性设置为自定义的edittext. 结果发现点击这个EditTextPreference并修改edittext中的值后都不好触发onPreferenceChanged这个函数,而且输入的值也不会自动被保存到sharedPreference里面,也无法通过getEditText().getText()这个函数获取输入的值~~~~
1 回答

catspeake
TA贡献1111条经验 获得超0个赞
It is a subclass of DialogPreference and shows the EditText in a dialog. This EditText can be modified either programmatically via getEditText(), or through XML by setting any EditText attributes on the EditTextPreference.This preference will store a string into the SharedPreferences.意思应该是你可以在EditTextPreference里面使用任何的EditText的属性,那你还替换自定义的EditText做什么?
- 1 回答
- 0 关注
- 99 浏览
添加回答
举报
0/150
提交
取消