国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > OS > 安卓 > 正文

Android使用RecyclerView實現投票系統

2024-09-11 17:15:16
字體:
來源:轉載
供稿:網友

本文實例為大家分享了Android投票系統的具體代碼,供大家參考,具體內容如下

一、創建一個fragment_vote_list.xml用來顯示投票的主頁面

(1)標題欄使用Toolbar
(2)投票區域可以滑動,使用RecyclerView實現

<?xml version="1.0" encoding="utf-8"?><RelativeLayout xmlns:andro android:layout_width="match_parent" android:layout_height="match_parent" xmlns:app="http://schemas.android.com/apk/res-auto" android:clickable="true" android:background="@color/backgroundColorWhite"> <LinearLayout  android:layout_width="match_parent"  android:layout_height="match_parent"  android:background="@color/backgroundColorWhite"  android:orientation="vertical">  <android.support.v7.widget.Toolbar   android:   android:layout_width="match_parent"   android:layout_height="@dimen/toolbarHeight"   android:background="@color/backgroundColorWhite"   app:contentInsetStart="0dp">   <RelativeLayout    android:layout_width="match_parent"    android:layout_height="match_parent">    <Button     android:     android:layout_width="@dimen/titleBarBackWidth"     android:layout_height="@dimen/titleBarBackHeight"     android:layout_margin="@dimen/margin_min"     android:layout_centerVertical="true"     android:background="@drawable/titlebar_back"     android:layout_marginLeft="@dimen/padding_20"     />    <TextView     android:     android:layout_width="wrap_content"     android:layout_height="wrap_content"     android:layout_centerInParent="true"     android:layout_gravity="center_vertical"     android:text="投票"     android:textColor="@color/textcolor_28282d"     android:textSize="@dimen/textSizeMax"     android:textStyle="bold"/>   </RelativeLayout>  </android.support.v7.widget.Toolbar>  <android.support.v7.widget.RecyclerView   android:   android:layout_width="match_parent"   android:layout_height="match_parent">  </android.support.v7.widget.RecyclerView> </LinearLayout></RelativeLayout>

注:界面字體大小以及控件寬度自行調整即可,使用RecyclerView首先需要在項目的build.gradle中添加相應的依賴庫才行。添加:implementation ‘com.android.support:recyclerview-v7:24.2.1'

界面效果:

二、創建一個item_vote.xml用來顯示投票的具體內容

(1)主布局使用LinearLayout實現,里面添加一個TextView用來顯示投票的問題,使用CheckBox作為投票的多選框。
(2)將當前的Item加載到投票的主頁面中

<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:andro android:orientation="vertical"  android:layout_width="match_parent" android:layout_height="wrap_content" android:background="@color/backgroundColorWhite" > <TextView  android:  android:layout_width="wrap_content"  android:layout_height="wrap_content"  android:text="1.請問你支持哪一個決議?"  android:textColor="@color/black"  android:textSize="@dimen/item_vote_question"  android:layout_marginLeft="@dimen/padding_20" /> <LinearLayout  android:layout_width="wrap_content"  android:layout_height="wrap_content"  android:background="@color/backgroundColorWhite"  android:orientation="vertical"  android:layout_margin="@dimen/padding_20">  <CheckBox   android:   android:layout_width="wrap_content"   android:layout_height="wrap_content"   android:text="AAAAAA"   android:textColor="@color/black"   android:textSize="@dimen/item_vote_answer" />  <CheckBox   android:   android:layout_width="wrap_content"   android:layout_height="wrap_content"   android:text="BBBBBBB"   android:textColor="@color/black"   android:textSize="@dimen/item_vote_answer" />  <CheckBox   android:   android:layout_width="wrap_content"   android:layout_height="wrap_content"   android:text="BCCCCC"   android:textColor="@color/black"   android:textSize="@dimen/item_vote_answer" /> </LinearLayout> </LinearLayout>
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 镇巴县| 高密市| 太原市| 张北县| 沁水县| 平遥县| 增城市| 罗平县| 江达县| 玉龙| 巴南区| 凉城县| 昌邑市| 卢龙县| 嘉兴市| 灌南县| 大竹县| 济源市| 平潭县| 揭西县| 凤凰县| 灌云县| 肥城市| 陕西省| 澳门| 防城港市| 扶绥县| 张掖市| 客服| 济源市| 长宁县| 大英县| 凤庆县| 威远县| 勃利县| 江津市| 宁强县| 海丰县| 新营市| 南宫市| 元江|