diff options
-rw-r--r-- | api/current.xml | 15 | ||||
-rw-r--r-- | core/java/android/preference/PreferenceActivity.java | 23 |
2 files changed, 34 insertions, 4 deletions
diff --git a/api/current.xml b/api/current.xml index 870c2ea..59a20ba 100644 --- a/api/current.xml +++ b/api/current.xml @@ -139564,6 +139564,21 @@ <parameter name="preferenceScreen" type="android.preference.PreferenceScreen"> </parameter> </method> +<method name="startPreferenceFragment" + return="void" + abstract="false" + native="false" + synchronized="false" + static="false" + final="false" + deprecated="not deprecated" + visibility="public" +> +<parameter name="fragment" type="android.app.Fragment"> +</parameter> +<parameter name="push" type="boolean"> +</parameter> +</method> <method name="startWithFragment" return="void" abstract="false" diff --git a/core/java/android/preference/PreferenceActivity.java b/core/java/android/preference/PreferenceActivity.java index 4889c19..c28ccd3 100644 --- a/core/java/android/preference/PreferenceActivity.java +++ b/core/java/android/preference/PreferenceActivity.java @@ -22,6 +22,7 @@ import org.xmlpull.v1.XmlPullParser; import org.xmlpull.v1.XmlPullParserException; import android.app.Fragment; +import android.app.FragmentTransaction; import android.app.ListActivity; import android.content.Context; import android.content.Intent; @@ -34,12 +35,11 @@ import android.os.Handler; import android.os.Message; import android.text.TextUtils; import android.util.AttributeSet; -import android.util.Log; import android.util.Xml; import android.view.LayoutInflater; import android.view.View; -import android.view.ViewGroup; import android.view.View.OnClickListener; +import android.view.ViewGroup; import android.widget.ArrayAdapter; import android.widget.Button; import android.widget.FrameLayout; @@ -730,11 +730,26 @@ public abstract class PreferenceActivity extends ListActivity implements com.android.internal.R.id.prefs, f).commit(); } + /** + * Start a new fragment. + * + * @param fragment The fragment to start + * @param push If true, the current fragment will be pushed onto the back stack. If false, + * the current fragment will be replaced. + */ + public void startPreferenceFragment(Fragment fragment, boolean push) { + FragmentTransaction transaction = getFragmentManager().openTransaction(); + transaction.replace(com.android.internal.R.id.prefs, fragment); + if (push) { + transaction.addToBackStack(BACK_STACK_PREFS); + } + transaction.commit(); + } + @Override public boolean onPreferenceStartFragment(PreferenceFragment caller, Preference pref) { Fragment f = Fragment.instantiate(this, pref.getFragment(), pref.getExtras()); - getFragmentManager().openTransaction().replace(com.android.internal.R.id.prefs, f) - .addToBackStack(BACK_STACK_PREFS).commit(); + startPreferenceFragment(f, true); return true; } |