Checkbox

Layout

<CheckBox android:id="@+id/option1"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:text="option1" />
<CheckBox android:id="@+id/option2"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:text="option2" />

Java

if  (((CheckBox) findViewById(R.id.option1)).isChecked()) {
    Toast.makeText(this, "Checked option1", Toast.LENGTH_SHORT).show();
}
if  (((CheckBox) findViewById(R.id.option2)).isChecked()) {
    Toast.makeText(this, "Checked option2", Toast.LENGTH_SHORT).show();

}

Last updated