1
我有12个复选框,我需要确保用户只选择其中5个,然后将5个选项标签输入到5个不同的字符串中。 我该怎么做?复选框标签到字符串
这是我的XML文件:
<CheckBox
android:id="@+id/chkInterestsMovies"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_x="223dp"
android:layout_y="257dp"
android:text="סרטים" />
<CheckBox
android:id="@+id/chkInterestsAnimals"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_x="222dp"
android:layout_y="306dp"
android:text="חיות" />
<CheckBox
android:id="@+id/chkInterestsShopping"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_x="222dp"
android:layout_y="356dp"
android:text="קניות" />
<CheckBox
android:id="@+id/chkInterestsBooks"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_x="149dp"
android:layout_y="257dp"
android:text="ספרים" />
<CheckBox
android:id="@+id/chkInterestsRestaurants"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_x="147dp"
android:layout_y="305dp"
android:text="מסעדות" />
<CheckBox
android:id="@+id/chkInterestsComputers"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_x="153dp"
android:layout_y="356dp"
android:text="מחשבים" />
<CheckBox
android:id="@+id/chkInterestsTV"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_x="72dp"
android:layout_y="255dp"
android:text="טלויזיה" />
<CheckBox
android:id="@+id/chkInterestsPubs"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_x="76dp"
android:layout_y="306dp"
android:text="פאבים" />
<CheckBox
android:id="@+id/chkInterestsDancing"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_x="76dp"
android:layout_y="355dp"
android:text="ריקודים" />
<CheckBox
android:id="@+id/chkInterestsMusic"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_x="7dp"
android:layout_y="257dp"
android:text="מוזיקה" />
<CheckBox
android:id="@+id/chkInterestsCoffe"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_x="8dp"
android:layout_y="304dp"
android:text="בתי קפה" />
<CheckBox
android:id="@+id/chkInterestsOther"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_x="7dp"
android:layout_y="350dp"
android:text="אחר" />
我是新来的android我不明白该功能如何检查所有复选框 –
更新了答案,随时问如果任何部分不清楚:) @LirazShakaAmir –