Code example for PreferenceCategory

Methods: setTitle, addPreference

0
    private PreferenceScreen createPreferenceHierarchy() {
        // Root 
        PreferenceScreen root = getPreferenceManager().createPreferenceScreen(this);
         
        // Dialog based preferences 
        PreferenceCategory masterInfoPrefCat = new PreferenceCategory(this);
        masterInfoPrefCat.setTitle("Master Username/Password");
        root.addPreference(masterInfoPrefCat);
        //Username edit 
        editUsername = new EditTextPreference(this);
        editUsername.setDialogTitle("Username:");
        editUsername.setKey("edittext_preference");
        editUsername.setTitle("Username");
        editUsername.setSummary("Change master username");
        masterInfoPrefCat.addPreference(editUsername);
        //password edit 
        editPassword = new EditTextPreference(this);
        editPassword.setDialogTitle("Password:");
        editPassword.setKey("edittext_preference");
        editPassword.setTitle("Password");
        editPassword.setSummary("Change master password");
        masterInfoPrefCat.addPreference(editPassword);
         
        //remove master login 
        removeLogin = new CheckBoxPreference(this);
        removeLogin.setTitle("Remove");
        removeLogin.setSummary("Removes master username/password");
        masterInfoPrefCat.addPreference(removeLogin);
                 
        //Title of this settings  
        PreferenceCategory closeVaultPrefCat = new PreferenceCategory(this);
        closeVaultPrefCat.setTitle("Close Vault Settings");
        root.addPreference(closeVaultPrefCat);