Code example for ListPreference

Methods: setOnPreferenceChangeListener

0
        mParent = mFragment.getPreferenceScreen();
        mVoiceCategory = (PreferenceCategory) mParent.findPreference(KEY_VOICE_CATEGORY);
        mRecognizerPref = (ListPreference) mVoiceCategory.findPreference(KEY_RECOGNIZER);
        mRecognizerSettingsPref = mVoiceCategory.findPreference(KEY_RECOGNIZER_SETTINGS);
        mTtsSettingsPref = mVoiceCategory.findPreference(KEY_TTS_SETTINGS);
        mRecognizerPref.setOnPreferenceChangeListener(this);
        mSettingsPref = (PreferenceScreen)
                mVoiceCategory.findPreference(KEY_RECOGNIZER_SETTINGS);
 
        mAvailableRecognizersMap = new HashMap<String, ResolveInfo>();
 
        populateOrRemovePreferences(); 
    } 
 
    private void populateOrRemovePreferences() { 
        boolean hasRecognizerPrefs = populateOrRemoveRecognizerPrefs();
        boolean hasTtsPrefs = populateOrRemoveTtsPrefs();
        if (!hasRecognizerPrefs && !hasTtsPrefs) {
            // There were no TTS settings and no recognizer settings, 
            // so it should be safe to hide the preference category 
Connect your IDE to all the code out there  Get Codota for Java