Example usage for android.preference PreferenceCategory getKey

List of usage examples for android.preference PreferenceCategory getKey

Introduction

In this page you can find the example usage for android.preference PreferenceCategory getKey.

Prototype

public String getKey() 

Source Link

Document

Gets the key for this Preference, which is also the key used for storing values into SharedPreferences or PreferenceDataStore .

Usage

From source file:org.mozilla.gecko.fxa.activities.FxAccountStatusFragment.java

/**
 * Iterate through debug buttons, adding a special debug preference click
 * listener to each of them./*  w  ww .  ja v a2s . com*/
 */
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);
    }
}