In my app I have a spinner that shows a list of elements. The user is able to select one of them and next click on a "Confirm" button. 
However, the element list may also be empty: in this case I don't want the button to be enabled. I tried to accomplish this behaviour programmatically, but I didn't succeed: the button appears always as enabled. What am I missing? 
Here's my code:

```
Spinner dropdownProperty;
AppCompatButton confirmBtn;
...
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);

dropdownProperty.setOnItemSelectedListener(new 
AdapterView.OnItemSelectedListener() {
   @Override
   public void onItemSelected(AdapterView<?> parent, View view,
                                   int position, long id) {

      if(dropdownProperty.getSelectedItem().toString().equals(""))
      confirmBtn.setEnabled(false);
                  else confirmBtn.setEnabled(true);
        }

   @Override
   public void onNothingSelected(AdapterView<?> parent) {
                            }
    });
...
}

```

I've also tried to manage the situation in the onNothingSelected method but it didn't help. 

Any idea? Thank you