1、项目需求
- 本项目是一个安卓项目,启动页面有多个复选框和一个提交按钮
- 复选框分别显示为北京、上海、广州
- 点击提交按钮,toast提示选中的城市有几个,选中的城市名是什么
2、项目分析
- 考察CheckBox和toast
(1)提交按钮需要设置点击监听器,监听器的作用是发一个toast
(2)遍历复选框列表,判断复选框的选中状态,如果选中,就将文本添加到结果字符串中
(3)显示toast
3、布局文件
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/activity_main"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_marg