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


Java PreferenceCategory.getPreferenceCount方法代碼示例

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


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

示例1: initPrefSummary

import android.preference.PreferenceCategory; //導入方法依賴的package包/類
private void initPrefSummary() {
    sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this.getActivity());

    for (int i = 0; i < getPreferenceScreen().getPreferenceCount(); ++i) {
        Preference preference = getPreferenceScreen().getPreference(i);

        if (preference instanceof PreferenceCategory) {
            PreferenceCategory pGrp = (PreferenceCategory) preference;
            for (int j = 0; j < pGrp.getPreferenceCount(); j++) {
                updatePrefSummary(pGrp.getPreference(j));
            }
        } else {
            updatePrefSummary(preference);
        }
    }
}
 
開發者ID:cuihaoleo,項目名稱:AndroidEquationSolver,代碼行數:17,代碼來源:SettingsActivity.java

示例2: 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

示例3: setSummaryPref

import android.preference.PreferenceCategory; //導入方法依賴的package包/類
public void setSummaryPref(Preference pref) {
    if (pref == null)
        return;

    String key = pref.getKey();
    if (key == null)
        key = "";

    if (pref instanceof KeyMapPreference) {
        KeyMapPreference kbPref = (KeyMapPreference) pref;
        String desc = kbPref.getDescription();
        pref.setSummary(desc);
    } else if (pref instanceof PreferenceCategory) {
        PreferenceCategory prefCat = (PreferenceCategory) pref;
        int count = prefCat.getPreferenceCount();
        for (int i = 0; i < count; i++) {
            setSummaryPref(prefCat.getPreference(i));
        }
    } else if (pref instanceof PreferenceScreen) {
        setSummaryAll((PreferenceScreen) pref);
    }
}
 
開發者ID:michaelbarlow7,項目名稱:dungeon-crawl-android,代碼行數:23,代碼來源:PreferencesActivity.java

示例4: onReceive

import android.preference.PreferenceCategory; //導入方法依賴的package包/類
@Override
public void onReceive(Context context, Intent intent) {
    final String packageName = intent.getStringExtra(OpenFitIntent.EXTRA_PACKAGE_NAME);
    final String appName = intent.getStringExtra(OpenFitIntent.EXTRA_APP_NAME);
    Log.d(LOG_TAG, "Recieved del application: "+appName+" : "+packageName);
    appManager.delNotificationApp(packageName);
    oPrefs.removeSet(packageName);
    oPrefs.removeString(packageName);
    PreferenceCategory category = (PreferenceCategory) findPreference("preference_category_apps");
    Preference app = (Preference) findPreference(packageName);
    category.removePreference(app);
    // If no more preference in the category, restore the placeholder
    if(category.getPreferenceCount() <= 0) {
        category.addPreference(preference_apps_placeholder);
    }
    sendNotificationApplications();
}
 
開發者ID:jareddlc,項目名稱:OpenFit,代碼行數:18,代碼來源:OpenFitActivity.java

示例5: initSummary

import android.preference.PreferenceCategory; //導入方法依賴的package包/類
private void initSummary(Preference p) {
    if (p instanceof PreferenceCategory) {
        PreferenceCategory pCat = (PreferenceCategory) p;
        for (int i = 0; i < pCat.getPreferenceCount(); i++) {
            initSummary(pCat.getPreference(i));
        }
    } else {
        p.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
            @Override
            public boolean onPreferenceChange(Preference preference, Object newVal) {
                preference.setSummary(newVal.toString());
                return true;
            }

        });
        updatePrefSummary(p);
    }
}
 
開發者ID:hecosire,項目名稱:hecosire-androidapp,代碼行數:19,代碼來源:SamplePreferenceActivity.java

示例6: initSummary

import android.preference.PreferenceCategory; //導入方法依賴的package包/類
private void initSummary(Preference p) {
    if (p instanceof PreferenceCategory) {
        PreferenceCategory pCat = (PreferenceCategory) p;
        for (int i = 0; i < pCat.getPreferenceCount(); i++) {
            initSummary(pCat.getPreference(i));
        }
    } else {
        updatePrefSummary(p);
    }
}
 
開發者ID:pazaan,項目名稱:600SeriesAndroidUploader,代碼行數:11,代碼來源:SettingsFragment.java

示例7: 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

示例8: initSummary

import android.preference.PreferenceCategory; //導入方法依賴的package包/類
private void initSummary(Preference p) {
    if (p instanceof PreferenceCategory) {
        PreferenceCategory cat = (PreferenceCategory) p;
        for (int i = 0; i < cat.getPreferenceCount(); i++) {
            initSummary(cat.getPreference(i));
        }
    } else {
        updatePreferences(p);
    }
}
 
開發者ID:SecureSmartHome,項目名稱:SecureSmartHome,代碼行數:11,代碼來源:MasterPreferenceFragment.java

示例9: 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

示例10: updateSummaryForPreference

import android.preference.PreferenceCategory; //導入方法依賴的package包/類
private void updateSummaryForPreference(Preference p){
    if(p instanceof ListPreference){
        ListPreference lp = (ListPreference) p;
        lp.setSummary(lp.getEntry());
    }
    if(p instanceof EditTextPreference){
        EditTextPreference ep = (EditTextPreference) p;
        ep.setSummary(ep.getText());
    }
    if(p instanceof PreferenceCategory){
        PreferenceCategory pc = (PreferenceCategory) p;
        for(int i=0; i < pc.getPreferenceCount(); i++)
            updateSummaryForPreference(pc.getPreference(i));
    }
}
 
開發者ID:jkarolus,項目名稱:UltraSense,代碼行數:16,代碼來源:SettingsFragment.java

示例11: initPrefsSummary

import android.preference.PreferenceCategory; //導入方法依賴的package包/類
protected void initPrefsSummary(SharedPreferences sharedPreferences,
                                Preference p) {
    if (p instanceof PreferenceCategory) {
        PreferenceCategory pCat = (PreferenceCategory) p;
        for (int i = 0; i < pCat.getPreferenceCount(); i++) {
            initPrefsSummary(sharedPreferences, pCat.getPreference(i));
        }
    } else {
        updatePrefsSummary(sharedPreferences, p.getKey());
    }
}
 
開發者ID:lowwor,項目名稱:Realtime-Bus,代碼行數:12,代碼來源:SettingsActivity.java

示例12: pickPreferenceObject

import android.preference.PreferenceCategory; //導入方法依賴的package包/類
private void pickPreferenceObject(Preference p) {
    if (p instanceof PreferenceCategory) {
        PreferenceCategory category = (PreferenceCategory) p;
        for (int i = 0; i < category.getPreferenceCount(); i++) {
            pickPreferenceObject(category.getPreference(i));
        }
    } else {
        initSummary(p);
    }
}
 
開發者ID:xpush,項目名稱:lib-xpush-android,代碼行數:11,代碼來源:SettingsFragment.java

示例13: 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

示例14: 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


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