@@ -0,0 +1,3517 @@
+package com.example.asadkhan.sunshine;%0A%0Aimport android.annotation.TargetApi;%0Aimport android.content.Intent;%0Aimport android.os.Build;%0Aimport android.os.Bundle;%0Aimport android.preference.ListPreference;%0Aimport android.preference.Preference;%0Aimport android.preference.PreferenceActivity;%0Aimport android.preference.PreferenceManager;%0Aimport android.util.Log;%0A%0A/**%0A * A %7B@link PreferenceActivity%7D that presents a set of application settings.%0A * %3Cp%3E%0A * See %3Ca href=%22http://developer.android.com/design/patterns/settings.html%22%3E%0A * Android Design: Settings%3C/a%3E for design guidelines and the %3Ca%0A * href=%22http://developer.android.com/guide/topics/ui/settings.html%22%3ESettings%0A * API Guide%3C/a%3E for more information on developing a Settings UI.%0A */%0Apublic class SettingsActivity extends PreferenceActivity%0A        implements Preference.OnPreferenceChangeListener %7B%0A%0A    @Override%0A    public void onCreate(Bundle savedInstanceState) %7B%0A        super.onCreate(savedInstanceState);%0A        // Add 'general' preferences, defined in the XML file%0A        addPreferencesFromResource(R.xml.pref_general);%0A%0A        // For all preferences, attach an OnPreferenceChangeListener so the UI summary can be%0A        // updated when the preference changes.%0A        bindPreferenceSummaryToValue(findPreference(getString(R.string.pref_location_key)));%0A        bindPreferenceSummaryToValue(findPreference(getString(R.string.pref_units_key)));%0A    %7D%0A%0A    /**%0A     * Attaches a listener so the summary is always updated with the preference value.%0A     * Also fires the listener once, to initialize the summary (so it shows up before the value%0A     * is changed.)%0A     */%0A    private void bindPreferenceSummaryToValue(Preference preference) %7B%0A        // Set the listener to watch for value changes.%0A        preference.setOnPreferenceChangeListener(this);%0A%0A        // Trigger the listener immediately with the preference's%0A        // current value.%0A        onPreferenceChange(preference,%0A                PreferenceManager%0A                        .getDefaultSharedPreferences(preference.getContext())%0A                        .getString(preference.getKey(), %22%22));%0A    %7D%0A%0A    @Override%0A    public boolean onPreferenceChange(Preference preference, Object value) %7B%0A        String stringValue = value.toString();%0A%0A        if (preference instanceof ListPreference) %7B%0A            // For list preferences, look up the correct display value in%0A            // the preference's 'entries' list (since they have separate labels/values).%0A            ListPreference listPreference = (ListPreference) preference;%0A            int prefIndex = listPreference.findIndexOfValue(stringValue);%0A            if (prefIndex %3E= 0) %7B%0A                preference.setSummary(listPreference.getEntries()%5BprefIndex%5D);%0A            %7D%0A        %7D else %7B%0A            // For other preferences, set the summary to the value's simple string representation.%0A            preference.setSummary(stringValue);%0A        %7D%0A        return true;%0A    %7D%0A%0A    @TargetApi(Build.VERSION_CODES.JELLY_BEAN)%0A    @Override%0A    public Intent getParentActivityIntent() %7B%0A        try%7B%0A            Intent intento = super.getParentActivityIntent().addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);%0A            if (intento != null) %7B%0A                return intento;%0A            %7D else %7B%0A                Log.e(%22HAHAHA Intento is null!%22, %22Huh??%22);%0A            %7D%0A        %7D catch (NullPointerException npe)%7B%0A            Log.e(%22HAHAHA Null pointer!!!%22, npe.getMessage());%0A        %7D%0A        return super.getParentActivityIntent();%0A    %7D%0A%0A%7D

Add custom activity for settings page