Android GridView中存在checkbox

本文介绍如何在Android项目中创建一个自定义Dialog,该Dialog包含一个GridView,每个单元格内都有一个Checkbox。详细展示了相关布局文件、自定义Adapter以及Dialog的触发和事件处理方法。
摘要由CSDN通过智能技术生成

Android GridView中存在checkbox的自定义dialog


在项目中遇到了要使用自定义的dialog,其中要存在gridview,gridview中要存在checkbox。

直接贴代码:


主布局:mainlayout

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent">
    <TextView
        android:id="@+id/tv_count"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerInParent="true"
        android:text="点击选择楼层"/>
</RelativeLayout>

布局名称 :checkdialog

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent">
    <RelativeLayout
        android:layout_width="330dp"
        android:layout_height="330dp"
        android:layout_alignParentTop="true"
        android:layout_centerHorizontal="true"
        android:background="@drawable/tab_rectangle" >
        <TextView
            android:id="@+id/tv_prompt"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentLeft="true"
            android:layout_alignParentTop="true"
            android:layout_marginLeft="17dp"
            android:layout_marginTop="15dp"
            android:text="请选择楼层"
            android:textColor="#000000"
            android:textSize="15sp" />
        <CheckBox
            android:id="@+id/select_true"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignBaseline="@+id/tv_prompt"
            android:layout_alignBottom="@+id/tv_prompt"
            android:layout_alignParentRight="true"
            android:layout_marginRight="22dp"
            android:button="@drawable/selector_radio"
            android:text="全选"
            android:textSize="15sp" />
        <View
            android:id="@+id/view_linerr"
            android:layout_width="match_parent"
            android:layout_height="0.5dp"
            android:layout_alignParentLeft="true"
            android:layout_marginTop="45dp"
            android:background="#e1e1e1" />
        <GridView
            android:id="@+id/gridview_floor"
            android:layout_width="match_parent"
            android:layout_height="200

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值