在preference中需要用到一個EditTextPreference,然后需要對輸入的內(nèi)容進(jìn)行限制,必須只能是整數(shù),所以將EditTextPreference中的xml文件中的dialogLayout屬性設(shè)置為自定義的edittext. 結(jié)果發(fā)現(xiàn)點擊這個EditTextPreference并修改edittext中的值后都不好觸發(fā)onPreferenceChanged這個函數(shù),而且輸入的值也不會自動被保存到sharedPreference里面,也無法通過getEditText().getText()這個函數(shù)獲取輸入的值~~~~
1 回答

catspeake
TA貢獻(xiàn)1111條經(jīng)驗 獲得超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.意思應(yīng)該是你可以在EditTextPreference里面使用任何的EditText的屬性,那你還替換自定義的EditText做什么?
- 1 回答
- 0 關(guān)注
- 108 瀏覽
添加回答
舉報
0/150
提交
取消