GridView在Fragment中的使用

该博客介绍了如何在Android的Fragment中使用GridView来显示广告图片。内容包括如何通过GridView加载图片并设置点击监听,当点击图片时携带Id进行页面跳转。此外,还提到了在GridView上方添加布局实现'今日推荐'和'更多'的文字展示。
摘要由CSDN通过智能技术生成

以下是实现的通过GridView加载广告图片(没有加载文字),上面的“今日推荐”,“更多”字样是通过Layout布局实现的。通过添加监听器,点击每一个图片,并且携带图片的Id进行转跳

这是一个GridView容器,用来放后面的gridview_tuijian_item,包括附加了上面的一个标题行“今日推荐”,“更多”

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >


    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginLeft="16dp"
        android:layout_marginRight="16dp"
        android:background="#ccc" >

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_centerVertical="true"
            android:text="今日推荐"
            android:textSize="16sp"
            android:textStyle="bold" />

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            andr
  • 7
    点赞
  • 19
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值