Methods Summary |
---|
public void | bind(android.widget.ListView listView)Binds a {@link ListView} to the preferences contained in this {@link PreferenceScreen} via
{@link #getRootAdapter()}. It also handles passing list item clicks to the corresponding
{@link Preference} contained by this {@link PreferenceScreen}.
listView.setOnItemClickListener(this);
listView.setAdapter(getRootAdapter());
onAttachedToActivity();
|
public android.app.Dialog | getDialog()Used to get a handle to the dialog.
This is useful for cases where we want to manipulate the dialog
as we would with any other activity or view.
return mDialog;
|
public android.widget.ListAdapter | getRootAdapter()Returns an adapter that can be attached to a {@link PreferenceActivity}
or {@link PreferenceFragment} to show the preferences contained in this
{@link PreferenceScreen}.
This {@link PreferenceScreen} will NOT appear in the returned adapter, instead
it appears in the hierarchy above this {@link PreferenceScreen}.
This adapter's {@link Adapter#getItem(int)} should always return a
subclass of {@link Preference}.
if (mRootAdapter == null) {
mRootAdapter = onCreateRootAdapter();
}
return mRootAdapter;
|
protected boolean | isOnSameScreenAsChildren()
return false;
|
protected void | onClick()
if (getIntent() != null || getFragment() != null || getPreferenceCount() == 0) {
return;
}
showDialog(null);
|
protected android.widget.ListAdapter | onCreateRootAdapter()Creates the root adapter.
return new PreferenceGroupAdapter(this);
|
public void | onDismiss(android.content.DialogInterface dialog)
mDialog = null;
getPreferenceManager().removePreferencesScreen(dialog);
|
public void | onItemClick(android.widget.AdapterView parent, android.view.View view, int position, long id)
// If the list has headers, subtract them from the index.
if (parent instanceof ListView) {
position -= ((ListView) parent).getHeaderViewsCount();
}
Object item = getRootAdapter().getItem(position);
if (!(item instanceof Preference)) return;
final Preference preference = (Preference) item;
preference.performClick(this);
|
protected void | onRestoreInstanceState(android.os.Parcelable state)
if (state == null || !state.getClass().equals(SavedState.class)) {
// Didn't save state for us in onSaveInstanceState
super.onRestoreInstanceState(state);
return;
}
SavedState myState = (SavedState) state;
super.onRestoreInstanceState(myState.getSuperState());
if (myState.isDialogShowing) {
showDialog(myState.dialogBundle);
}
|
protected android.os.Parcelable | onSaveInstanceState()
final Parcelable superState = super.onSaveInstanceState();
final Dialog dialog = mDialog;
if (dialog == null || !dialog.isShowing()) {
return superState;
}
final SavedState myState = new SavedState(superState);
myState.isDialogShowing = true;
myState.dialogBundle = dialog.onSaveInstanceState();
return myState;
|
private void | showDialog(android.os.Bundle state)
Context context = getContext();
if (mListView != null) {
mListView.setAdapter(null);
}
LayoutInflater inflater = (LayoutInflater)
context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View childPrefScreen = inflater.inflate(
com.android.internal.R.layout.preference_list_fragment, null);
mListView = (ListView) childPrefScreen.findViewById(android.R.id.list);
bind(mListView);
// Set the title bar if title is available, else no title bar
final CharSequence title = getTitle();
Dialog dialog = mDialog = new Dialog(context, context.getThemeResId());
if (TextUtils.isEmpty(title)) {
dialog.getWindow().requestFeature(Window.FEATURE_NO_TITLE);
} else {
dialog.setTitle(title);
}
dialog.setContentView(childPrefScreen);
dialog.setOnDismissListener(this);
if (state != null) {
dialog.onRestoreInstanceState(state);
}
// Add the screen to the list of preferences screens opened as dialogs
getPreferenceManager().addPreferencesScreen(dialog);
dialog.show();
|