i have a problem and i dont know how to fix it .I want to make a basic begginer calculator app.I want only one checkbox to be checkable at time but i cant figure out ,stil can check all .And how can i cast strings from edittext to doubl?.App is not finished yet . Sorry for english.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.top_fragment);
double result ;
EditText number_1 = (EditText)findViewById(R.id.number_1);
EditText number_2 = (EditText)findViewById(R.id.number_2);
CheckBox add_box = (CheckBox)findViewById(R.id.add_box);
CheckBox subtract_box = (CheckBox)findViewById(R.id.subtract_box);
CheckBox divide_box = (CheckBox)findViewById(R.id.divide_box);
CheckBox product_box = (CheckBox)findViewById(R.id.product_box);
final Button button = (Button)findViewById(R.id.button);
number_1.getText().toString();
number_2.getText().toString();
if(add_box.isChecked())
{
subtract_box.setEnabled(false);
divide_box.setEnabled(false);
product_box.setEnabled(false);
}else if(subtract_box.isChecked())
{
product_box.setEnabled(false);
divide_box.setEnabled(false);
add_box.setEnabled(false);
}else if(divide_box.isChecked())
{
subtract_box.setEnabled(false);
product_box.setEnabled(false);
add_box.setEnabled(false);
}else if(product_box.isChecked())
{
subtract_box.setEnabled(false);
divide_box.setEnabled(false);
add_box.setEnabled(false);
}
}
}
Aucun commentaire:
Enregistrer un commentaire