diff --git a/api/current.xml b/api/current.xml index 1f3a283751156..8c84bc6b35156 100644 --- a/api/current.xml +++ b/api/current.xml @@ -15341,6 +15341,17 @@ visibility="public" > + + - + + + If you are overriding this method with your own custom content, + * consider including the standard layout {@link android.R.layout#list_content} + * in your layout file, so that you continue to retain all of the standard + * behavior of ListFragment. In particular, this is currently the only + * way to have the built-in indeterminant progress state be shown. */ @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { - return inflater.inflate(com.android.internal.R.layout.list_content_rich, + return inflater.inflate(com.android.internal.R.layout.list_content, container, false); } @@ -217,9 +223,15 @@ public class ListFragment extends Fragment { * Provide the cursor for the list view. */ public void setListAdapter(ListAdapter adapter) { + boolean hadAdapter = mAdapter != null; mAdapter = adapter; if (mList != null) { mList.setAdapter(adapter); + if (!mListShown && !hadAdapter) { + // The list was hidden, and previously didn't have an + // adapter. It is now time to show it. + setListShown(true, getView().getWindowToken() != null); + } } } @@ -271,6 +283,32 @@ public class ListFragment extends Fragment { mList.setEmptyView(mStandardEmptyView); } + /** + * Control whether the list is being displayed. You can make it not + * displayed if you are waiting for the initial data to show in it. During + * this time an indeterminant progress indicator will be shown instead. + * + *

Applications do not normally need to use this themselves. The default + * behavior of ListFragment is to start with the list not being shown, only + * showing it once an adapter is given with {@link #setListAdapter(ListAdapter)}. + * If the list at that point had not been shown, when it does get shown + * it will be do without the user ever seeing the hidden state. + * + * @param shown If true, the list view is shown; if false, the progress + * indicator. The initial value is true. + */ + public void setListShown(boolean shown) { + setListShown(shown, true); + } + + /** + * Like {@link #setListShown(boolean)}, but no animation is used when + * transitioning from the previous state. + */ + public void setListShownNoAnimation(boolean shown) { + setListShown(shown, false); + } + /** * Control whether the list is being displayed. You can make it not * displayed if you are waiting for the initial data to show in it. During @@ -281,7 +319,7 @@ public class ListFragment extends Fragment { * @param animate If true, an animation will be used to transition to the * new state. */ - public void setListShown(boolean shown, boolean animate) { + private void setListShown(boolean shown, boolean animate) { ensureList(); if (mProgressContainer == null) { throw new IllegalStateException("Can't be used with a custom content view"); @@ -356,6 +394,12 @@ public class ListFragment extends Fragment { mList.setOnItemClickListener(mOnClickListener); if (mAdapter != null) { setListAdapter(mAdapter); + } else { + // We are starting without an adapter, so assume we won't + // have our data right away and start with the progress indicator. + if (mProgressContainer != null) { + setListShown(false, false); + } } mHandler.post(mRequestFocus); } diff --git a/core/res/res/layout/list_content.xml b/core/res/res/layout/list_content.xml index 6f9f1e0f0f6f7..14140322b7cd4 100644 --- a/core/res/res/layout/list_content.xml +++ b/core/res/res/layout/list_content.xml @@ -1,8 +1,6 @@ - + + + + + + + + + + + + + + + + diff --git a/core/res/res/layout/list_content_rich.xml b/core/res/res/layout/list_content_rich.xml deleted file mode 100644 index 14140322b7cd4..0000000000000 --- a/core/res/res/layout/list_content_rich.xml +++ /dev/null @@ -1,56 +0,0 @@ - - - - - - - - - - - - - - - - - - diff --git a/core/res/res/layout/list_content_simple.xml b/core/res/res/layout/list_content_simple.xml new file mode 100644 index 0000000000000..6f9f1e0f0f6f7 --- /dev/null +++ b/core/res/res/layout/list_content_simple.xml @@ -0,0 +1,24 @@ + + + diff --git a/core/res/res/values/public.xml b/core/res/res/values/public.xml index 48d7dc1adcad6..d0be554efeb02 100644 --- a/core/res/res/values/public.xml +++ b/core/res/res/values/public.xml @@ -1315,4 +1315,11 @@ + + +