List of usage examples for android.preference PreferenceScreen removeAll
public void removeAll()
From source file:com.mattprecious.notisync.preferences.DevicePreferenceFragment.java
@Override public void onResume() { super.onResume(); BluetoothAdapter btAdapter = BluetoothAdapter.getDefaultAdapter(); if (btAdapter == null) { return;/* w w w . j a v a2 s .c o m*/ } PreferenceScreen screen = getPreferenceScreen(); screen.removeAll(); Set<String> selectedDevices = Preferences.getDevices(getActivity()); // Get a set of currently paired devices Set<BluetoothDevice> pairedDevices = btAdapter.getBondedDevices(); for (BluetoothDevice device : pairedDevices) { CheckBoxPreference preference = new CheckBoxPreference(getActivity()); preference.setOnPreferenceChangeListener(preferenceListener); preference.setTitle(device.getName()); preference.setSummary(device.getAddress()); int iconResId = Helpers.getBtClassDrawable(device); if (iconResId != 0) { preference.setIcon(iconResId); } if (selectedDevices.contains(device.getAddress())) { preference.setDefaultValue(true); localDeviceSet.add(device.getAddress()); } getPreferenceScreen().addPreference(preference); } }
From source file:de.ub0r.android.callmeter.ui.prefs.PreferencesPlain.java
/** Load widget list. */ @SuppressWarnings("deprecation") private void loadWidgets() { SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); Preference p = findPreference("container"); if (p != null && p instanceof PreferenceScreen) { PreferenceScreen ps = (PreferenceScreen) p; ps.removeAll(); int[] ids = AppWidgetManager.getInstance(this) .getAppWidgetIds(new ComponentName(this, StatsAppWidgetProvider.class)); boolean added = false; if (ids != null && ids.length > 0) { for (int id : ids) { if (prefs.getLong(StatsAppWidgetProvider.WIDGET_PLANID + id, -1) <= 0) { continue; }/* w w w . java2 s.c o m*/ added = true; p = new Preference(this); p.setTitle(getString(R.string.widget_) + " #" + id); final int fid = id; p.setOnPreferenceClickListener(new OnPreferenceClickListener() { @Override public boolean onPreferenceClick(final Preference preference) { Intent i = new Intent(PreferencesPlain.this, StatsAppWidgetConfigure.class); i.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, fid); PreferencesPlain.this.startActivity(i); return true; } }); ps.addPreference(p); } } ids = AppWidgetManager.getInstance(this) .getAppWidgetIds(new ComponentName(this, LogsAppWidgetProvider.class)); if (ids != null && ids.length > 0) { for (int id : ids) { if (prefs.getLong(LogsAppWidgetProvider.WIDGET_PLANID + id, -1) <= 0) { continue; } added = true; p = new Preference(this); p.setTitle(getString(R.string.widget_) + " #" + id); final int fid = id; p.setOnPreferenceClickListener(new OnPreferenceClickListener() { @Override public boolean onPreferenceClick(final Preference preference) { Intent i = new Intent(PreferencesPlain.this, LogsAppWidgetConfigure.class); i.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, fid); PreferencesPlain.this.startActivity(i); return true; } }); ps.addPreference(p); } } if (!added) { p = new Preference(this); p.setTitle(R.string.widgets_no_widgets_); p.setSummary(R.string.widgets_no_widgets_hint); ps.addPreference(p); } } }
From source file:org.mozilla.gecko.fxa.activities.FxAccountStatusFragment.java
protected void hardRefresh() { // This is the only way to guarantee that the EditText dialogs created by // EditTextPreferences are re-created. This works around the issue described // at http://androiddev.orkitra.com/?p=112079. final PreferenceScreen statusScreen = (PreferenceScreen) ensureFindPreference("status_screen"); statusScreen.removeAll(); addPreferences();//from w w w. ja v a 2 s. co m refresh(); }
From source file:org.linphone.SettingsFragment.java
private void emptyAndHidePreferenceScreen(int preferenceKey) { Preference preference = findPreference(getString(preferenceKey)); if (!(preference instanceof PreferenceScreen)) return;//from ww w. j a v a 2 s . co m PreferenceScreen preferenceScreen = (PreferenceScreen) preference; preferenceScreen.removeAll(); hidePreference(preferenceScreen); }