Android GridView示例

In this android tutorial you will learn about android simple and custom gridview example.

在本android教程中,您将学习有关android简单和自定义gridview示例的信息。

In Android, GridView is a ViewGroup that is used to display items in a two dimensional scrollable grid form. You might have seen image gallery in Android mobiles, it is created using GridView layout.

在Android中,GridView是一个ViewGroup,用于以二维可滚动网格形式显示项目。 您可能已经在Android手机中看到了图片库,它是使用GridView布局创建的。

Here we will see two examples, one is simple GridView layout with some text and another is custom GridView layout with image and text.

在这里,我们将看到两个示例,一个是带有某些文本的简单GridView布局,另一个是带有图像和文本的自定义GridView布局。

Android GridView示例 (Android GridView Example)

Android Simple GridView示例 (Android Simple GridView Example)

Make an android project with package name com.gridviewexample and add following code in respective files.

使用包名称com.gridviewexample创建一个android项目,并在相应文件中添加以下代码。

activity_main.xml

activity_main.xml

<?xml version="1.0" encoding="utf-8"?>
<GridView xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/simpleGrid"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:columnWidth="100dp"
    android:numColumns="aut
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值