What is addFooterView for GridView?

ListView has an addFooterView method, which is useful for displaying a loaded message. But GridView does not have this method. So, how to add a footer to a GridView as shown on Google Play?Google Play loading footer view

+5
source share
5 answers

Android BucketListAdapter

This is an implementation of the bucket list adapter, similar to what you see in the Google Play app. It has a grid layout of list items, with the advantage that you can still use the list of headers and footers - something that is not possible with the standard GridView.

Link: https://github.com/rzsombor/bucket-list-adapter

+6
source

, , GridView .

"click here for more", , . CommonsWare EndlessAdapter GridView.

0

, android:layout_alignParentBottom="true", , Grid, , , , .

0

gridview. , . , , (AsyncTask Loader ), .

0
source

You can use this. Use OnScrollListener to control the scroll position; when scrolling to the last item, you can control the visibility of the load view.

        @Override
    public void onScroll(AbsListView view, int firstVisibleItem,
            int visibleItemCount, int totalItemCount) {
        if (mOnScrollListener != null) {
            mOnScrollListener.onScroll(view, firstVisibleItem,
                    visibleItemCount, totalItemCount);
        }
        // The count of footer view will be add to visibleItemCount also are
        // added to totalItemCount
        if (visibleItemCount == totalItemCount) {
            // If all the item can not fill screen, we should make the
            // footer view invisible.
        } else if (!mIsLoading
                && (firstVisibleItem + visibleItemCount >= totalItemCount)
                && mCurrentScrollState != SCROLL_STATE_IDLE) {
            mIsLoading = true;
            if (mOnLoadMoreListener != null) {
                mOnLoadMoreListener.onLoadMore();
            }
        }
    }

<LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:orientation="vertical" >

            <LinearLayout
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:fillViewport="true" >

                <com.baidu.hao123.module.video.view.LoadMoreGridView
                    android:id="@+id/gv_movie_home"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:cacheColorHint="@null"
                    android:fitsSystemWindows="true"
                    android:horizontalSpacing="10dip"
                    android:listSelector="@android:color/transparent"
                    android:numColumns="3"
                    android:paddingLeft="13dip"
                    android:paddingRight="13dip"
                    android:paddingTop="10dip"
                    android:scrollbars="none"
                    android:verticalSpacing="12dip" />
            </LinearLayout>

            <LinearLayout
                android:id="@+id/auto_load_view"
                android:layout_width="wrap_content"
                android:layout_gravity="center_horizontal"
                android:layout_height="wrap_content"
                android:paddingTop="10dip"
                android:visibility="gone" 
                android:paddingBottom="10dip"
                android:gravity="center"
                android:orientation="horizontal" >

                <ProgressBar
                    android:id="@+id/loadingBar"
                    android:layout_width="23dip"
                    android:layout_height="23dip"
                    android:layout_marginRight="10dip"
                    android:indeterminateDrawable="@drawable/progress_small" />

                <TextView
                    android:id="@+id/loadingText"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:gravity="center_vertical"
                    android:text="@string/loading"
                    android:textColor="@color/color_ff555555"
                    android:textSize="@dimen/fontSize_middle" />
            </LinearLayout>
        </LinearLayout>
0
source

All Articles