可能重複:
how to call the ok button in the EditTextPreference如何將SetOnClickListener()設置爲EditTextPreference對話框的OK按鈕?
我想驗證輸入(輸入6位數字)的EditTextPreference對話框。
這是怎麼我的(相關)的preferences.xml片段是這樣的:
<!--EditTextPreference-->
<com.app.preferences.UpdatePincodePreference
android:key="PIN_CODE_PREFERENCE"
android:title="@string/pincode_preference_title"
android:summary="@string/pincode_preference_summary"
android:dialogTitle="@string/pincode_preference_dialog_title"
android:dialogMessage="@string/pincode_preference_dialog_message"
android:inputType="number"
/>
如何測試,在首選項對話框的EditText上的用戶沒有輸入少於或多於6個數字?
基本上我需要在OK按鈕上設置一個onClickListener(),但是如何獲得我沒有定義的OK按鈕。它是EditTextPreference的默認視圖,取消按鈕也是如此。
問題與「how to call the ok button in the EditTextPreference」完全相同,但接受的解決方案中提供的鏈接現在已被破壞。
太棒了!那就是我正在看的東西。似乎是一個相當複雜的解決方案。將挖掘什麼與我有關。日Thnx! – 2012-04-20 11:37:46
不知道在代碼中發生了什麼:(你能解釋一下我的相關邏輯嗎?我需要的是當用戶在EditTextPreference對話框中按下確定按鈕時,是否輸入6位數字?Thnx! – 2012-04-20 11:56:09