Methods Summary |
---|
public void | addPreferencesFromIntent(android.content.Intent intent)Adds preferences from activities that match the given {@link Intent}.
requirePreferenceManager();
setPreferenceScreen(mPreferenceManager.inflateFromIntent(intent, getPreferenceScreen()));
|
public void | addPreferencesFromResource(int preferencesResId)Inflates the given XML resource and adds the preference hierarchy to the current
preference hierarchy.
requirePreferenceManager();
setPreferenceScreen(mPreferenceManager.inflateFromResource(getActivity(),
preferencesResId, getPreferenceScreen()));
|
private void | bindPreferences()
final PreferenceScreen preferenceScreen = getPreferenceScreen();
if (preferenceScreen != null) {
preferenceScreen.bind(getListView());
}
onBindPreferences();
|
private void | ensureList()
if (mList != null) {
return;
}
View root = getView();
if (root == null) {
throw new IllegalStateException("Content view not yet created");
}
View rawListView = root.findViewById(android.R.id.list);
if (!(rawListView instanceof ListView)) {
throw new RuntimeException(
"Content has view with id attribute 'android.R.id.list' "
+ "that is not a ListView class");
}
mList = (ListView)rawListView;
if (mList == null) {
throw new RuntimeException(
"Your content must have a ListView whose id attribute is " +
"'android.R.id.list'");
}
mList.setOnKeyListener(mListOnKeyListener);
mHandler.post(mRequestFocus);
|
public Preference | findPreference(java.lang.CharSequence key)Finds a {@link Preference} based on its key.
if (mPreferenceManager == null) {
return null;
}
return mPreferenceManager.findPreference(key);
|
public android.widget.ListView | getListView()
ensureList();
return mList;
|
public PreferenceManager | getPreferenceManager()Returns the {@link PreferenceManager} used by this fragment.
return mPreferenceManager;
|
public PreferenceScreen | getPreferenceScreen()Gets the root of the preference hierarchy that this fragment is showing.
return mPreferenceManager.getPreferenceScreen();
|
public boolean | hasListView()
if (mList != null) {
return true;
}
View root = getView();
if (root == null) {
return false;
}
View rawListView = root.findViewById(android.R.id.list);
if (!(rawListView instanceof ListView)) {
return false;
}
mList = (ListView)rawListView;
if (mList == null) {
return false;
}
return true;
|
public void | onActivityCreated(android.os.Bundle savedInstanceState)
super.onActivityCreated(savedInstanceState);
if (mHavePrefs) {
bindPreferences();
}
mInitDone = true;
if (savedInstanceState != null) {
Bundle container = savedInstanceState.getBundle(PREFERENCES_TAG);
if (container != null) {
final PreferenceScreen preferenceScreen = getPreferenceScreen();
if (preferenceScreen != null) {
preferenceScreen.restoreHierarchyState(container);
}
}
}
|
public void | onActivityResult(int requestCode, int resultCode, android.content.Intent data)
super.onActivityResult(requestCode, resultCode, data);
mPreferenceManager.dispatchActivityResult(requestCode, resultCode, data);
|
protected void | onBindPreferences()
|
public void | onCreate(android.os.Bundle savedInstanceState)
super.onCreate(savedInstanceState);
mPreferenceManager = new PreferenceManager(getActivity(), FIRST_REQUEST_CODE);
mPreferenceManager.setFragment(this);
|
public android.view.View | onCreateView(android.view.LayoutInflater inflater, android.view.ViewGroup container, android.os.Bundle savedInstanceState)
TypedArray a = getActivity().obtainStyledAttributes(null,
com.android.internal.R.styleable.PreferenceFragment,
com.android.internal.R.attr.preferenceFragmentStyle,
0);
mLayoutResId = a.getResourceId(com.android.internal.R.styleable.PreferenceFragment_layout,
mLayoutResId);
a.recycle();
return inflater.inflate(mLayoutResId, container, false);
|
public void | onDestroy()
super.onDestroy();
mPreferenceManager.dispatchActivityDestroy();
|
public void | onDestroyView()
mList = null;
mHandler.removeCallbacks(mRequestFocus);
mHandler.removeMessages(MSG_BIND_PREFERENCES);
super.onDestroyView();
|
public boolean | onPreferenceTreeClick(PreferenceScreen preferenceScreen, Preference preference){@inheritDoc}
if (preference.getFragment() != null &&
getActivity() instanceof OnPreferenceStartFragmentCallback) {
return ((OnPreferenceStartFragmentCallback)getActivity()).onPreferenceStartFragment(
this, preference);
}
return false;
|
public void | onSaveInstanceState(android.os.Bundle outState)
super.onSaveInstanceState(outState);
final PreferenceScreen preferenceScreen = getPreferenceScreen();
if (preferenceScreen != null) {
Bundle container = new Bundle();
preferenceScreen.saveHierarchyState(container);
outState.putBundle(PREFERENCES_TAG, container);
}
|
public void | onStart()
super.onStart();
mPreferenceManager.setOnPreferenceTreeClickListener(this);
|
public void | onStop()
super.onStop();
mPreferenceManager.dispatchActivityStop();
mPreferenceManager.setOnPreferenceTreeClickListener(null);
|
protected void | onUnbindPreferences()
|
private void | postBindPreferences()
if (mHandler.hasMessages(MSG_BIND_PREFERENCES)) return;
mHandler.obtainMessage(MSG_BIND_PREFERENCES).sendToTarget();
|
private void | requirePreferenceManager()
if (mPreferenceManager == null) {
throw new RuntimeException("This should be called after super.onCreate.");
}
|
public void | setPreferenceScreen(PreferenceScreen preferenceScreen)Sets the root of the preference hierarchy that this fragment is showing.
if (mPreferenceManager.setPreferences(preferenceScreen) && preferenceScreen != null) {
onUnbindPreferences();
mHavePrefs = true;
if (mInitDone) {
postBindPreferences();
}
}
|