Code example for Fragment

Methods: getActivity, getView

0
mGridShown = shown;
        if (shown) {
            if (animate) {
                mProgressContainer.startAnimation(AnimationUtils.loadAnimation(
                        getActivity(), android.R.anim.fade_out));
                mGridContainer.startAnimation(AnimationUtils.loadAnimation(
                        getActivity(), android.R.anim.fade_in));
            } else { 
                mProgressContainer.clearAnimation();
                mGridContainer.clearAnimation();
            } 
            mProgressContainer.setVisibility(View.GONE);
            mGridContainer.setVisibility(View.VISIBLE);
        } else { 
            if (animate) {
                mProgressContainer.startAnimation(AnimationUtils.loadAnimation(
                        getActivity(), android.R.anim.fade_in));
                mGridContainer.startAnimation(AnimationUtils.loadAnimation(
                        getActivity(), android.R.anim.fade_out));
            } else { 
                mProgressContainer.clearAnimation();
                mGridContainer.clearAnimation();
            } 
            mProgressContainer.setVisibility(View.VISIBLE);
            mGridContainer.setVisibility(View.GONE);
        } 
    } 
 
    /** 
     * Get the ListAdapter associated with this activity's GridView. 
     */ 
    public ListAdapter getGridAdapter() {
        return mAdapter;
    } 
 
    /** 
     * Provide the cursor for the grid view. 
     */ 
    public void setGridAdapter(ListAdapter adapter) {
        boolean hadAdapter = mAdapter != null;
        mAdapter = adapter;
        if (mGridView != null) {
            mGridView.setAdapter(adapter);
            if (!mGridShown && !hadAdapter) {
                // The grid was hidden, and previously didn't have an 
                // adapter.  It is now time to show it. 
                setGridShown(true, getView().getWindowToken() != null);
            } 
        } 
    } 
 
    private void ensureList() {