+ updateTextViews();
+
+ PreferenceManager.getDefaultSharedPreferences(this)
+ .registerOnSharedPreferenceChangeListener(this);
+ }
+
+ @Override
+ protected void onResume() {
+ super.onResume();
+ PreferenceManager.getDefaultSharedPreferences(this)
+ .registerOnSharedPreferenceChangeListener(this);
+ }
+
+ @Override
+ protected void onPause() {
+ super.onPause();
+ PreferenceManager.getDefaultSharedPreferences(this)
+ .unregisterOnSharedPreferenceChangeListener(this);
+ }
+
+ public void onSharedPreferenceChanged(SharedPreferences sharedPreferences,
+ String key) {
+ updateTextViews();
+ }
+
+ private void updateTextViews() {
+ // argh...
+ SharedPreferences sp = PreferenceManager
+ .getDefaultSharedPreferences(this);
+ fillTextView(sp, R.id.textViewHL1, "hiscore_HL1");
+ fillTextView(sp, R.id.textViewHL2, "hiscore_HL2");
+ fillTextView(sp, R.id.textViewHM1, "hiscore_HM1");
+ fillTextView(sp, R.id.textViewHM2, "hiscore_HM2");
+ fillTextView(sp, R.id.textViewHS1, "hiscore_HS1");
+ fillTextView(sp, R.id.textViewHS2, "hiscore_HS2");
+ fillTextView(sp, R.id.textViewEL1, "hiscore_EL1");
+ fillTextView(sp, R.id.textViewEL2, "hiscore_EL2");
+ fillTextView(sp, R.id.textViewEM1, "hiscore_EM1");
+ fillTextView(sp, R.id.textViewEM2, "hiscore_EM2");
+ fillTextView(sp, R.id.textViewES1, "hiscore_ES1");
+ fillTextView(sp, R.id.textViewES2, "hiscore_ES2");
+ }
+
+ private void fillTextView(SharedPreferences sp, int id, String key) {
+ TextView tv = (TextView) findViewById(id);
+ tv.setText(sp.getString(key, "9:99:99"));