需求
要做一个这样的界面。
界面里有多选的三种水果,然后点一下【提交】按钮,控制台打印你选择的是哪些?
设计
- 我们使用TableRow排局,做上中下三层;
- 由于当中有三个组件即三列,因此第一行和第二行里的组件中使用:android:layout_span="3"做三列合并操作;
UI端代码
activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/TableLayout2"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<TableRow>
<TextView
android