From d501b5c963c0cbcc9c666f502229599464eaf3fd Mon Sep 17 00:00:00 2001 From: Chia-chi Yeh Date: Fri, 15 Jul 2011 11:05:46 -0700 Subject: VpnSettings: bind OnPreferenceClickListener later. Bug: 4999108 Change-Id: Idab3029a30943d1118584e6a1b01db96340858ed --- src/com/android/settings/vpn2/VpnSettings.java | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) (limited to 'src/com') diff --git a/src/com/android/settings/vpn2/VpnSettings.java b/src/com/android/settings/vpn2/VpnSettings.java index 082b95f..4dbb6bd 100644 --- a/src/com/android/settings/vpn2/VpnSettings.java +++ b/src/com/android/settings/vpn2/VpnSettings.java @@ -73,9 +73,7 @@ public class VpnSettings extends SettingsPreferenceFragment implements public void onCreate(Bundle savedState) { super.onCreate(savedState); addPreferencesFromResource(R.xml.vpn_settings2); - PreferenceGroup group = getPreferenceScreen(); - group.setOrderingAsAdded(false); - group.findPreference("add_network").setOnPreferenceClickListener(this); + getPreferenceScreen().setOrderingAsAdded(false); if (savedState != null) { VpnProfile profile = VpnProfile.decode(savedState.getString("VpnKey"), @@ -124,6 +122,7 @@ public class VpnSettings extends SettingsPreferenceFragment implements // safely cache profiles in the memory. if (mPreferences == null) { mPreferences = new HashMap(); + PreferenceGroup group = getPreferenceScreen(); String[] keys = mKeyStore.saw(Credentials.VPN); if (keys != null && keys.length > 0) { @@ -138,13 +137,11 @@ public class VpnSettings extends SettingsPreferenceFragment implements } else { VpnPreference preference = new VpnPreference(context, profile); mPreferences.put(key, preference); + group.addPreference(preference); } } } - } - PreferenceGroup group = getPreferenceScreen(); - for (VpnPreference preference : mPreferences.values()) { - group.addPreference(preference); + group.findPreference("add_network").setOnPreferenceClickListener(this); } // Show the dialog if there is one. -- cgit v1.1