i have two spinners when i select items(other then first item) in first spinner which is saved in array it populates data in spinner second which comes from web services. i want that when i again select first data which is title of spinner first it should clear all the value from spinner second. i did all tricks but helpless. suggest me.
my code is:
if(spinner1== 0) {
spinner2List.clear();
ArrayAdapter<String> adapterEmpty = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, spinner2List);
adapterEmpty.setDropDownViewResource(R.layout.spinner_layout);
// Apply the adapter to the spinner
spinner2.setAdapter(adapterEmpty);
}
thanks.
when you select one of your first spinner Items you can use code below in first spinner onItemSelected() method to clear your second spinner.
Spinner2.setAdapter(null)
You have called spinner2List.clear();
but haven't notified the adapter by using notifyDataSetChanged();
method.
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