當前位置: 首頁>>代碼示例>>Java>>正文


Java PreferenceCategory.getPreference方法代碼示例

本文整理匯總了Java中android.preference.PreferenceCategory.getPreference方法的典型用法代碼示例。如果您正苦於以下問題:Java PreferenceCategory.getPreference方法的具體用法?Java PreferenceCategory.getPreference怎麽用?Java PreferenceCategory.getPreference使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.preference.PreferenceCategory的用法示例。


在下文中一共展示了PreferenceCategory.getPreference方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: connectDebugButtons

import android.preference.PreferenceCategory; //導入方法依賴的package包/類
/**
 * Iterate through debug buttons, adding a special debug preference click
 * listener to each of them.
 */
protected void connectDebugButtons() {
  // Separate listener to really separate debug logic from main code paths.
  final OnPreferenceClickListener listener = new DebugPreferenceClickListener();

  // We don't want to use Android resource strings for debug UI, so we just
  // use the keys throughout.
  final PreferenceCategory debugCategory = (PreferenceCategory) ensureFindPreference("debug_category");
  debugCategory.setTitle(debugCategory.getKey());

  for (int i = 0; i < debugCategory.getPreferenceCount(); i++) {
    final Preference button = debugCategory.getPreference(i);
    button.setTitle(button.getKey()); // Not very friendly, but this is for debugging only!
    button.setOnPreferenceClickListener(listener);
  }
}
 
開發者ID:jrconlin,項目名稱:mc_backup,代碼行數:20,代碼來源:FxAccountStatusFragment.java

示例2: setupPeriodicControls

import android.preference.PreferenceCategory; //導入方法依賴的package包/類
private void setupPeriodicControls() {
    final PreferenceCategory periodicSpeechPrefs = (PreferenceCategory) findPreference(DroidPlannerPrefs.PREF_TTS_PERIODIC);
    ListPreference periodic = ((ListPreference) periodicSpeechPrefs.getPreference(0));
    periodic.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
        @Override
        public boolean onPreferenceChange(Preference preference, final Object newValue) {
            // Broadcast the event locally on update.
            // A handler is used to that the current action has the time to
            // return, and store the value in the preferences.
            mHandler.post(new Runnable() {
                @Override
                public void run() {
                    lbm.sendBroadcast(new Intent(ACTION_UPDATED_STATUS_PERIOD)
                            .putExtra(EXTRA_UPDATED_STATUS_PERIOD, (String) newValue));

                    setupPeriodicControls();
                }
            });
            return true;
        }
    });

    int val = Integer.parseInt(periodic.getValue());

    final boolean isEnabled = val != 0;
    if (isEnabled) {
        periodic.setSummary(getString(R.string.pref_tts_status_every) + " " + val + " "
                + getString(R.string.pref_tts_seconds));
    } else {
        periodic.setSummary(R.string.pref_tts_periodic_status_disabled);
    }

    for (int i = 1; i < periodicSpeechPrefs.getPreferenceCount(); i++) {
        periodicSpeechPrefs.getPreference(i).setEnabled(isEnabled);
    }
}
 
開發者ID:mxiao6,項目名稱:Tower-develop,代碼行數:37,代碼來源:SettingsFragment.java

示例3: setupPeriodicControls

import android.preference.PreferenceCategory; //導入方法依賴的package包/類
private void setupPeriodicControls() {
    final PreferenceCategory periodicSpeechPrefs = (PreferenceCategory) findPreference(getString(R.string.pref_tts_periodic_key));
    ListPreference periodic = ((ListPreference) periodicSpeechPrefs.getPreference(0));
    periodic.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
        @Override
        public boolean onPreferenceChange(Preference preference, final Object newValue) {
            // Broadcast the event locally on update.
            // A handler is used to that the current action has the time to
            // return,
            // and store the value in the preferences.
            mHandler.post(new Runnable() {
                @Override
                public void run() {
                    LocalBroadcastManager.getInstance(getActivity()).sendBroadcast(
                            new Intent(ACTION_UPDATED_STATUS_PERIOD).putExtra(
                                    EXTRA_UPDATED_STATUS_PERIOD, (String) newValue));

                    setupPeriodicControls();
                }
            });
            return true;
        }
    });

    int val = Integer.parseInt(periodic.getValue());

    final boolean isEnabled = val != 0;
    if (isEnabled) {
        periodic.setSummary(getString(R.string.pref_tts_status_every) + " " + val + " "
                + getString(R.string.pref_tts_seconds));
    } else {
        periodic.setSummary(R.string.pref_tts_periodic_status_disabled);
    }

    for (int i = 1; i < periodicSpeechPrefs.getPreferenceCount(); i++) {
        periodicSpeechPrefs.getPreference(i).setEnabled(isEnabled);
    }
}
 
開發者ID:jiaminghan,項目名稱:droidplanner-master,代碼行數:39,代碼來源:SettingsFragment.java

示例4: setupPeriodicControls

import android.preference.PreferenceCategory; //導入方法依賴的package包/類
private void setupPeriodicControls() {
    final PreferenceCategory periodicSpeechPrefs = (PreferenceCategory) findPreference(getString(R.string.pref_tts_periodic_key));
    ListPreference periodic = ((ListPreference) periodicSpeechPrefs.getPreference(0));
    periodic.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
        @Override
        public boolean onPreferenceChange(Preference preference, final Object newValue) {
            // Broadcast the event locally on update.
            // A handler is used to that the current action has the time to
            // return, and store the value in the preferences.
            mHandler.post(new Runnable() {
                @Override
                public void run() {
                    lbm.sendBroadcast(new Intent(ACTION_UPDATED_STATUS_PERIOD)
                            .putExtra(EXTRA_UPDATED_STATUS_PERIOD, (String) newValue));

                    setupPeriodicControls();
                }
            });
            return true;
        }
    });

    int val = Integer.parseInt(periodic.getValue());

    final boolean isEnabled = val != 0;
    if (isEnabled) {
        periodic.setSummary(getString(R.string.pref_tts_status_every) + " " + val + " "
                + getString(R.string.pref_tts_seconds));
    } else {
        periodic.setSummary(R.string.pref_tts_periodic_status_disabled);
    }

    for (int i = 1; i < periodicSpeechPrefs.getPreferenceCount(); i++) {
        periodicSpeechPrefs.getPreference(i).setEnabled(isEnabled);
    }
}
 
開發者ID:sommishra,項目名稱:DroidPlanner-Tower,代碼行數:37,代碼來源:SettingsFragment.java

示例5: onCreate

import android.preference.PreferenceCategory; //導入方法依賴的package包/類
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    // Bind the view with presenter
    presenter = new Presenter(this);
    presenter.getInitialize(getArguments());

    PreferenceScreen preferenceScreen = getPreferenceScreen();

    //START loop to set listener on Preferences
    // Set "this" to listen for all preference click/change listener for all preferences
    for (int i = 0, size = preferenceScreen.getPreferenceCount(); i < size; i++) {
        Preference preference = preferenceScreen.getPreference(i);
        preference.setOnPreferenceClickListener(this);
        preference.setOnPreferenceChangeListener(this);

        // If this is a preference category, make sure to go through all the subpreferences as well.
        if (preference instanceof PreferenceCategory) {
            Stack<PreferenceCategory> stack = new Stack<>();
            stack.push((PreferenceCategory) preference);

            do {
                PreferenceCategory category = stack.pop();
                for (int x = 0, xSize = category.getPreferenceCount(); x < xSize; x++) {
                    Preference subPref = category.getPreference(x);
                    subPref.setOnPreferenceChangeListener(this);
                    subPref.setOnPreferenceClickListener(this);

                    if (subPref instanceof PreferenceCategory) {
                        stack.push((PreferenceCategory) subPref);
                    }
                }
            }
            while (!stack.isEmpty());
        }
    } //END loop to set listener on Preferences

    //This will update the state of the Settings view
    presenter.handlePreferences();
}
 
開發者ID:pedromassango,項目名稱:Programmers,代碼行數:42,代碼來源:SettingsFragment.java

示例6: updateInfoPref

import android.preference.PreferenceCategory; //導入方法依賴的package包/類
private void updateInfoPref(PreferenceCategory category, int index, int helpId, boolean isOn) {
  TwoStatePreference pref = (TwoStatePreference) category.getPreference(index);
  pref.setChecked(isOn);
  pref.setOnPreferenceChangeListener(this);
  pref.setIntent(getHelpIntent(helpId));
}
 
開發者ID:sunnygoyal,項目名稱:PowerToggles,代碼行數:7,代碼來源:InfoFrag.java


注:本文中的android.preference.PreferenceCategory.getPreference方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。