Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //R.layout.framgnet
- <LinearLayout
- android:id="@+id/root_layout"
- android:layout_width="fill_parent"
- android:layout_height="fill_parent"
- android:gravity="center"
- android:orientation="vertical">
- <ListView
- android:id="@+id/list"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:otherStuffsYouNeed="whaaaatever"/>
- </LinearLayout>
- //Fragment.java
- public class Fragment extends Fragment {
- public LinearLayout mRoot;
- public ListView mList;
- public ProgressBar mProgress;
- @Override
- public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
- //Get allllll the references
- View layout = inflater.inflate(R.layout.fragment, null);
- mRoot = (LinearLayout) layout.findViewById(R.id.root_layout);
- mList = (ListView) layout.findViewById(R.id.list);
- //Create your ProgressBar (I'm assuming you want it indeterminate as common
- mProgress = new ProgressBar();
- mProgress.setIndeterminate(true);
- showLoading();
- //Blah blah blah get your ListView data and in your onDone() or whatever method
- //you may have
- ...
- @Override
- public void onDone() {
- mRoot.removeViewAt(0);
- mRoot.addView(mList, 0);
- }
- return layout;
- }
- public void showLoading() {
- mRoot.removeViewAt(0);
- mRoot.addView(mProgress, 0);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement