This question might have been answered 100 times before but am still not able to get it.I want to select only one checkbox at a time out of 7.Below is my code. Please help!
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
cbBan = (CheckBox) findViewById(R.id.cbBandra);
cbAnd = (CheckBox) findViewById(R.id.cbAndheri);
checkBoxListener = new OnClickListener() {
@Override
public void onClick(View v) {
tv = (TextView) findViewById(R.id.tvD);
tv.setText("");
if (cbBan.isChecked()) {
tv.setText(tv.getText().toString() + "" + cbBan.getText().toString());
}
if (cbAnd.isChecked()) {
tv.setText(tv.getText().toString() + "" + cbAnd.getText().toString());
}
}
};
cbBan.setOnClickListener(checkBoxListener);
cbAnd.setOnClickListener(checkBoxListener);
Aucun commentaire:
Enregistrer un commentaire