jeudi 22 janvier 2015

How to make an option fade but still be clickable on Android Studio?

I currently have a two checkboxes, where when one is clicked, the other automatically unchecks. I would like to keep that however have the unchecked one become a faded white color, yet still be clickable and readable if the user decides to change his/her mind.


This is the current code I have: final CheckBox chk1 = (CheckBox) findViewById(R.id.checkBox1); final CheckBox chk2 = (CheckBox) findViewById(R.id.checkBox2);



chk1.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
chk2.setChecked(false);
chk1.setChecked(b);
}
});
chk2.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
chk1.setChecked(false);
chk2.setChecked(b);
}
});
}




Aucun commentaire:

Enregistrer un commentaire