Android Open Source - ramp_up_android Example Preference Fragment






From Project

Back to project page ramp_up_android.

License

The source code is released under:

Apache License

If you think the Android project ramp_up_android listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.macadamian;
//from   w ww . j a  va2s.  c  o m
import android.content.Intent;
import android.os.Bundle;
import android.preference.Preference;
import android.preference.PreferenceFragment;
import android.preference.PreferenceScreen;

import java.util.HashMap;
import java.util.Map;

public abstract class ExamplePreferenceFragment extends PreferenceFragment {
    private Map<String, Class<?>> _klasses = new HashMap<String, Class<?>>();

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        addPreferencesFromResource(getResourceId());
    }

    @Override
    public boolean onPreferenceTreeClick(PreferenceScreen screen, Preference pref) {
        String key = pref.getKey();
        if (_klasses.containsKey(key)) {
            getActivity().startActivity(new Intent(getActivity(), _klasses.get(key)));
            return true;
        }

        return false;
    }

    protected void add(String key, Class<?> klass) {
        _klasses.put(key, klass);
    }

    protected abstract int getResourceId();
}




Java Source Code List

com.macadamian.ActionBarExampleActivity.java
com.macadamian.ActionsActivity.java
com.macadamian.BasicUserInterfaceActivity.java
com.macadamian.BroadcastsActivity.java
com.macadamian.CursorAdapterActivity.java
com.macadamian.DataExamplesFragment.java
com.macadamian.ExamplePreferenceFragment.java
com.macadamian.ExamplesSelectionActivity.java
com.macadamian.ExecutionControlExamplesFragment.java
com.macadamian.FragmentsActivity.java
com.macadamian.InAppBillingActivity.java
com.macadamian.IntentsActivity.java
com.macadamian.IntentsStartedActivity.java
com.macadamian.SimpleListAdapterActivity.java
com.macadamian.SystemExamplesFragment.java
com.macadamian.UserInterfaceExamplesFragment.java
com.macadamian.ViewPagerActivity.java
com.macadamian.billing.Base64DecoderException.java
com.macadamian.billing.Base64.java
com.macadamian.billing.IabException.java
com.macadamian.billing.IabHelper.java
com.macadamian.billing.IabResult.java
com.macadamian.billing.Inventory.java
com.macadamian.billing.Purchase.java
com.macadamian.billing.Security.java
com.macadamian.billing.SkuDetails.java