如何在网格视图端添加文本 [英] how to add text in grid view end

查看:85
本文介绍了如何在网格视图端添加文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用gridview显示图像.最初,我在gridview中显示16个图像,然后我想在gridview中显示32个图像.

我希望网格视图底部的下一个按钮转到下一组图像.

如何在Android的gridview底部设置按钮?

解决方案

如果您确实需要GridView底部的按钮",那么这里是您必须在加载XML文件中设计的布局.

 < GridViewandroid:id ="@ + id/gridview"android:layout_width ="match_parent"android:layout_height ="wrap_content"android:layout_alignParentTop ="true"android:layout_centerHorizo​​ntal ="true"android:numColumns ="3"></GridView><按钮android:id ="@ + id/button1"android:layout_width ="wrap_content"android:layout_height ="wrap_content"android:layout_alignParentBottom ="true"android:layout_centerHorizo​​ntal ="true"android:text ="Button"/></RelativeLayout> 

对于较小的网格,则可以.如果您的网格超出了屏幕显示的范围,您将得到这样的显示(单击此处)

现在,您可以编写按钮的OnClickListner.

但是我建议您使用的是自定义菜单来放置该按钮.这样,如果您的活动"中有太多网格项,就不会有任何重叠的问题.

祝你好运

I am using gridview for displaying images. Initially I am displaying 16 images in the gridview and next I want to display 32 images in the gridview.

I want a next button at the bottom of the grid view to go to the next set of images.

How can I set button at the bottom of a gridview for Android?

解决方案

If you really need a "button" at the bottom of the GridView, here is the layout that you have to design in your loading XML file.

    <GridView
        android:id="@+id/gridview"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        android:layout_centerHorizontal="true"
        android:numColumns="3" >
    </GridView>

    <Button
        android:id="@+id/button1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_centerHorizontal="true"
        android:text="Button" />

</RelativeLayout>

For lesser grids it will be OK. If your have grids more than that your screen can show, you will get a display like this (click here)

Now you can write for the OnClickListner of the button.

BUT what I am suggesting you is, use a customize menu to put that button. Then you don't have any overlapping issue if there are so many grid items in your Activity.

Good luck

这篇关于如何在网格视图端添加文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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