コード例 #1
0
 /**
  * For each list dialog, we display the value selected in the "summary" text. When a new value is
  * selected from the list dialog, update the summary to the selected entry.
  */
 public boolean onPreferenceChange(Preference preference, Object newValue) {
   ListPreference list = (ListPreference) preference;
   int index = list.findIndexOfValue((String) newValue);
   CharSequence entry = list.getEntries()[index];
   preference.setSummary(entry);
   return true;
 }
コード例 #2
0
 /**
  * Create the "Select Instruments For Each Track " lists. The list of possible instruments is in
  * MidiFile.java.
  */
 private void createInstrumentPrefs(PreferenceScreen root) {
   PreferenceCategory selectInstrTitle = new PreferenceCategory(this);
   selectInstrTitle.setTitle(R.string.select_instruments_per_track);
   root.addPreference(selectInstrTitle);
   selectInstruments = new ListPreference[options.tracks.length];
   for (int i = 0; i < options.instruments.length; i++) {
     selectInstruments[i] = new ListPreference(this);
     selectInstruments[i].setOnPreferenceChangeListener(this);
     selectInstruments[i].setEntries(MidiFile.Instruments);
     selectInstruments[i].setEntryValues(MidiFile.Instruments);
     selectInstruments[i].setTitle("Track " + i);
     selectInstruments[i].setValueIndex(options.instruments[i]);
     selectInstruments[i].setSummary(selectInstruments[i].getEntry());
     root.addPreference(selectInstruments[i]);
   }
   setAllToPiano = new Preference(this);
   setAllToPiano.setTitle(R.string.set_all_to_piano);
   setAllToPiano.setOnPreferenceClickListener(this);
   root.addPreference(setAllToPiano);
 }
コード例 #3
0
 /* Create the "Restore Default Settings" preference */
 private void createRestoreDefaultPrefs(PreferenceScreen root) {
   restoreDefaults = new Preference(this);
   restoreDefaults.setTitle(R.string.restore_defaults);
   restoreDefaults.setOnPreferenceClickListener(this);
   root.addPreference(restoreDefaults);
 }