how to clear the checked box after we get the checked result ?
something like selection.clear();
but, that only clear the output, not the checkbox.
what i am trying to do is, to set the checkbox to the original state, which is unchecked.
after user checked the checkbox then click button to get result of checked checkbox, i wish to clear all the selection in the checkbox. how please help?
public class DessertIngAvail extends Dessert {
ArrayList<String> selection = new ArrayList<String>();
TextView final_text;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_dessert_ing_avail);
final_text = (TextView)findViewById(R.id.final_result);
final_text.setEnabled(false);
}
public void selectItem(View view){
boolean checked = ((CheckBox) view).isChecked();
switch (view.getId())
{
case R.id.checkBox181:
if(checked)
{
if(!selection.contains("Tebaloi"))
selection.add("Tebaloi");
if(!selection.contains("Tumpik"))
selection.add("Tumpik");
}
break;
case R.id.checkBox182:
if(checked)
{
if(!selection.contains("Ambuyat"))
selection.add("Ambuyat");
}
break;
case R.id.checkBox183:
if(checked)
{
if(!selection.contains("Tumpik"))
selection.add("Tumpik");
}
break;
case R.id.checkBoxCM:
if(checked)
{
if(!selection.contains("Honey Frankincense Cake"))
selection.add("Honey Frankincense Cake");
if(!selection.contains(" Ray Heart Cake"))
selection.add(" Ray Heart Cake");
}
break;
}
}
public void finalSelection(View view){
String final_fruit_selection = "";
for(String Selection : selection)
{
final_fruit_selection = final_fruit_selection + Selection + "\n";
}
final_text.setText(final_fruit_selection);
selection.clear();
final_text.setEnabled(true);
}}
Aucun commentaire:
Enregistrer un commentaire