/**
  * 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;
 }
  /** Update the MidiOptions based on the preferences selected. */
  private void updateOptions() {
    for (int i = 0; i < options.tracks.length; i++) {
      options.tracks[i] = selectTracks[i].isChecked();
    }
    for (int i = 0; i < options.mute.length; i++) {
      options.mute[i] = muteTracks[i].isChecked();
    }
    for (int i = 0; i < options.tracks.length; i++) {
      ListPreference entry = selectInstruments[i];
      options.instruments[i] = entry.findIndexOfValue(entry.getValue());
    }
    options.scrollVert = scrollVertically.isChecked();
    options.showPiano = showPiano.isChecked();
    options.showLyrics = showLyrics.isChecked();
    if (twoStaffs != null) options.twoStaffs = twoStaffs.isChecked();
    else options.twoStaffs = false;

    options.showNoteLetters = Integer.parseInt(showNoteLetters.getValue());
    options.transpose = Integer.parseInt(transpose.getValue());
    options.key = Integer.parseInt(key.getValue());
    if (time.getValue().equals("Default")) {
      options.time = null;
    } else if (time.getValue().equals("3/4")) {
      options.time =
          new TimeSignature(3, 4, options.defaultTime.getQuarter(), options.defaultTime.getTempo());
    } else if (time.getValue().equals("4/4")) {
      options.time =
          new TimeSignature(4, 4, options.defaultTime.getQuarter(), options.defaultTime.getTempo());
    }
    options.combineInterval = Integer.parseInt(combineInterval.getValue());
    options.shade1Color = shade1Color.getColor();
    options.shade2Color = shade2Color.getColor();
    options.showMeasures = showMeasures.isChecked();
    options.playMeasuresInLoop = playMeasuresInLoop.isChecked();
    options.playMeasuresInLoopStart = Integer.parseInt(loopStart.getValue()) - 1;
    options.playMeasuresInLoopEnd = Integer.parseInt(loopEnd.getValue()) - 1;
  }