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

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

问题描述

请参阅下面的布局。我无法把页脚按钮下方的的GridView 。 任何帮助将AP preciate。

当的GridView填写屏幕按钮不会显示。

 < XML版本=1.0编码=UTF-8&GT?;

< RelativeLayout的的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android
机器人:ID =@ + ID / relativeLayout1
机器人:layout_width =FILL_PARENT
机器人:layout_height =FILL_PARENT
 >

< GridView控件
    的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android
    机器人:ID =@ + ID / GridView控件
    机器人:layout_width =FILL_PARENT
    机器人:layout_height =WRAP_CONTENT
    机器人:columnWidth中=90dp
    机器人:重力=中心
    机器人:horizo​​ntalSpacing =10dp
    机器人:为numColumns =auto_fit
    机器人:stretchMode =columnWidth中
    机器人:verticalSpacing =10dp/>

<按钮
    机器人:ID =@ + ID /按钮1
    机器人:layout_width =FILL_PARENT
    机器人:layout_height =WRAP_CONTENT
    机器人:layout_below =@ + ID / GridView控件
    机器人:文本=加载更多图片/>

 < / RelativeLayout的>
 

解决方案

我一直在保持搜索了很久的一个GridView,使我们能够 addFooterView addHeaderView 的ListView

这是一个交2年前。我来到这里按照在谷歌搜索结果中的链接。我不知道天气这个问题已经解决或没有。

如果不是,这里是一个库,它可能会有所帮助。 <一href="https://github.com/liaohuqiu/android-GridViewWithHeaderAndFooter">https://github.com/liaohuqiu/android-GridViewWithHeaderAndFooter.

这是非常简单的:

  GridViewWithHeaderAndFooter的GridView =(GridViewWithHeaderAndFooter)v.findViewById(R.id.ly_image_list_grid);

LayoutInflater layoutInflater = LayoutInflater.from(本);
查看headerView = layoutInflater.inflate(R.layout.test_header_view,NULL);
查看footerView = layoutInflater.inflate(R.layout.test_footer_view,NULL);
gridView.addHeaderView(headerView);
gridView.addFooterView(footerView);
 

下面是一个屏幕快照:

截屏

希望这将是有益的。祝你好运!

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

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>

解决方案

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.

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

It's very simple:

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);

Here is a screen snapshot:

Hope this would be helpful. Good luck!

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

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