I have 2 prefs - a song title and the audio state(mute or volume) that I want to store in the same key. This works for the clicks and the only problem I have is resetting the summary on onSharedPreferencesChanged I get errors with this.
PreferenceScreen musicPrefScreen = (PreferenceScreen)getPreferenceScreen
().findPreference("theme" + Team_ID);
musicPrefScreen.setSummary(mPreferences.getString("theme" +
Team_ID, "CantGetTeam"));
ListPreference audiostatePref = (ListPreference)getPreferenceScreen()
.findPreference("theme" + Team_ID);
audiostatePref.setSummary(AudioState);
audiostatePref.setEntryValues(audiostates_values);
because the second call to findPreference returns the first Pref. The docs say you can call findPreference on the first to get the second but they are different types of prefs and i get a cast error. Is there another way to find the ListPreference so I can reset the Entry Values on the list?
EDIT: Here is the layout
public PreferenceScreen createPreferenceHierarchy() {
PreferenceScreen prefScreenRoot = getPreferenceManager().createPreferenceScreen(this);
PreferenceCategory TeamCategory = new PreferenceCategory(this);
TeamCategory.setTitle("Team " + Team_ID + " Settings");
prefScreenRoot.addPreference(TeamCategory);
// set team name
EditTextPreference teamnamePref = new EditTextPreference(this);
teamnamePref.setTitle("Team Name");
teamnamePref.setKey( "team" + Team_ID );
teamnamePref.setSummary(TheTeamName);
teamnamePref.setDialogTitle("Enter Name For Team " + Team_ID);
teamnamePref.setDefaultValue(TheTeamName);
teamnamePref.getEditText().setSingleLine(true);
TeamCategory.addPreference(teamnamePref);
// select theme music
PreferenceScreen musicPrefScreen = getPreferenceManager().createPreferenceScreen(this);
Intent musicIntent = new Intent(this, MusicDroid.class);
musicIntent.putExtra( "team_id", Team_ID);
musicPrefScreen.setIntent(musicIntent);
musicPrefScreen.setKey( "theme" + Team_ID );
musicPrefScreen.setTitle("Theme Music");
musicPrefScreen.setSummary(TheThemeName);
TeamCategory.addPreference(musicPrefScreen);
// select audio state
ListPreference audiostatePref = new ListPreference(this);
audiostatePref.setTitle("Audio State");
audiostatePref.setKey( "theme" + Team_ID );
audiostatePref.setSummary(AudioState); //
audiostatePref.setEntries(audiostates);
audiostatePref.setEntryValues(audiostates_values);
TeamCategory.addPreference(audiostatePref);
return prefScreenRoot;
}