在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 關注
- 109 瀏覽
添加回答
舉報
0/150
提交
取消