コード例 #1
0
 /**
  * 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.
  *
  * @param shown If true, the list view is shown; if false, the progress indicator. The initial
  *     value is true.
  * @param animate If true, an animation will be used to transition to the new state.
  */
 private void setListShown(boolean shown, boolean animate) {
   ensureList();
   if (mProgressContainer == null) {
     throw new IllegalStateException("Can't be used with a custom content view");
   }
   if (mListShown == shown) {
     return;
   }
   mListShown = shown;
   if (shown) {
     if (animate) {
       mProgressContainer.startAnimation(
           AnimationUtils.loadAnimation(getActivity(), android.R.anim.fade_out));
       mListContainer.startAnimation(
           AnimationUtils.loadAnimation(getActivity(), android.R.anim.fade_in));
     }
     mProgressContainer.setVisibility(View.GONE);
     mListContainer.setVisibility(View.VISIBLE);
   } else {
     if (animate) {
       mProgressContainer.startAnimation(
           AnimationUtils.loadAnimation(getActivity(), android.R.anim.fade_in));
       mListContainer.startAnimation(
           AnimationUtils.loadAnimation(getActivity(), android.R.anim.fade_out));
     }
     mProgressContainer.setVisibility(View.VISIBLE);
     mListContainer.setVisibility(View.GONE);
   }
 }
コード例 #2
0
 /**
  * The default content for a ListFragment has a TextView that can be shown when the list is empty.
  * If you would like to have it shown, call this method to supply the text it should use.
  */
 public void setEmptyText(CharSequence text) {
   ensureList();
   if (mStandardEmptyView == null) {
     throw new IllegalStateException("Can't be used with a custom content view");
   }
   mStandardEmptyView.setText(text);
   if (!mSetEmptyText) {
     mList.setEmptyView(mStandardEmptyView);
     mSetEmptyText = true;
   }
 }
コード例 #3
0
 /** Get the activity's list view widget. */
 public ListView getListView() {
   ensureList();
   return mList;
 }
コード例 #4
0
 /** Get the cursor row ID of the currently selected list item. */
 public long getSelectedItemId() {
   ensureList();
   return mList.getSelectedItemId();
 }
コード例 #5
0
 /** Get the position of the currently selected list item. */
 public int getSelectedItemPosition() {
   ensureList();
   return mList.getSelectedItemPosition();
 }
コード例 #6
0
 /**
  * Set the currently selected list item to the specified position with the adapter's data
  *
  * @param position
  */
 public void setSelection(int position) {
   ensureList();
   mList.setSelection(position);
 }
コード例 #7
0
 /** Attach to list view once Fragment is ready to run. */
 @Override
 public void onActivityCreated(Bundle savedInstanceState) {
   super.onActivityCreated(savedInstanceState);
   ensureList();
 }