Once the check box is check then the spinner will be show and once the check box is unchecked then the spinner will be hidden. I have shown that combination in the below image.

I have achieved this using below code I have shown.
halfHalfCB.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
if (halfHalfCB.isChecked()) {
extraDescriptionHalfSP.setVisibility(View.VISIBLE);
textview.setVisibility(View.VISIBLE);
} else {
extraDescriptionHalfSP.setVisibility(View.GONE);
textview.setVisibility(View.GONE);
// String extraDescriptionHalf = extraDescriptionHalfSP
// .getSelectedItem() != null ? extraDescriptionHalfSP
// .getSelectedItem().toString() : null;
// extraDescriptionHalf = null;
}
}
});
addToCartButton.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
try {
String extraDescriptionHalf = extraDescriptionHalfSP
.getSelectedItem() != null ? extraDescriptionHalfSP
.getSelectedItem().toString() : null;
Actually my problem is once the check box is checked and then user select a value from spinner and then user unchecked the check box. I want to clear the selected value from the spinner (or make the selected value null). How can I do that? From my current code spinner carries the selected item.
Any help will be highly appreciated.
To remove items from the spinner you can use :
myspinner.setAdapter(null);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With