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