需要在Android中为Gridview创建页脚 [英] Need to create Footer for Gridview in Android

查看:32
本文介绍了需要在Android中为Gridview创建页脚的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请参阅下面的布局.我无法将页脚按钮放在 GridView 下方.任何帮助将不胜感激.

See below layout. I am unable to put footer button below a GridView. Any help will be appreciate.

Gridview 填充屏幕时 Button 不显示.

When Gridview fill in the screen Button is not displayed.

<?xml version="1.0" encoding="utf-8"?>

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/relativeLayout1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
 >

<GridView
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/gridview"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:columnWidth="90dp"
    android:gravity="center"
    android:horizontalSpacing="10dp"
    android:numColumns="auto_fit"
    android:stretchMode="columnWidth"
    android:verticalSpacing="10dp" />

<Button
    android:id="@+id/button1"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_below="@+id/gridview"
    android:text="Load More Images" />

 </RelativeLayout>

推荐答案

我一直在寻找一个 GridView,它允许我们 addFooterViewaddHeaderViewListView.

I have been keeping searching for a long time for a GridView which allows us to addFooterView and addHeaderView like ListView.

这是两年前的帖子.我是按照谷歌搜索结果中的链接来到这里的.我不知道这个问题是否已经解决了.

It's a post 2 years ago. I come here by following the link in google search result. I don't know weather this problem has been solved or not.

如果没有,这里有一个可能有用的库.https://github.com/liaohuqiu/android-GridViewWithHeaderAndFooter.

If not, here is a library which may be helpful. https://github.com/liaohuqiu/android-GridViewWithHeaderAndFooter.

很简单:

GridViewWithHeaderAndFooter gridView = (GridViewWithHeaderAndFooter) v.findViewById(R.id.ly_image_list_grid);

LayoutInflater layoutInflater = LayoutInflater.from(this);
View headerView = layoutInflater.inflate(R.layout.test_header_view, null);
View footerView = layoutInflater.inflate(R.layout.test_footer_view, null);
gridView.addHeaderView(headerView);
gridView.addFooterView(footerView);

这是屏幕截图:

希望这会有所帮助.祝你好运!

Hope this would be helpful. Good luck!

这篇关于需要在Android中为Gridview创建页脚的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆