Advertisement
andoird213

SampleProgressLoadList

Aug 23rd, 2013
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.34 KB | None | 0 0
  1.  
  2. //R.layout.framgnet
  3. <LinearLayout
  4.     android:id="@+id/root_layout"
  5.     android:layout_width="fill_parent"
  6.     android:layout_height="fill_parent"
  7.     android:gravity="center"
  8.     android:orientation="vertical">
  9.     <ListView
  10.         android:id="@+id/list"
  11.         android:layout_width="match_parent"
  12.         android:layout_height="match_parent"
  13.         android:otherStuffsYouNeed="whaaaatever"/>
  14. </LinearLayout>
  15.  
  16. //Fragment.java
  17. public class Fragment extends Fragment {
  18.     public LinearLayout mRoot;
  19.     public ListView mList;
  20.     public ProgressBar mProgress;
  21.  
  22.     @Override
  23.     public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
  24.             //Get allllll the references
  25.             View layout = inflater.inflate(R.layout.fragment, null);
  26.             mRoot = (LinearLayout) layout.findViewById(R.id.root_layout);
  27.             mList = (ListView) layout.findViewById(R.id.list);
  28.             //Create your ProgressBar (I'm assuming you want it indeterminate as common
  29.             mProgress = new ProgressBar();
  30.             mProgress.setIndeterminate(true);
  31.             showLoading();
  32.  
  33.             //Blah blah blah get your ListView data and in your onDone() or whatever method
  34.             //you may have
  35.             ...
  36.             @Override
  37.             public void onDone() {
  38.                 mRoot.removeViewAt(0);
  39.                 mRoot.addView(mList, 0);
  40.             }
  41.             return layout;
  42.     }
  43.  
  44.     public void showLoading() {
  45.         mRoot.removeViewAt(0);
  46.         mRoot.addView(mProgress, 0);
  47.     }
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement