android – Call a method using Spinner selection

Question:

Is it possible to call a method using an android Spinner ?

I need to select the option and based on this selected option I need to send a request to the webservice , and this will return me the other Spnnier options next.

Answer:

Through setOnItemSelectedListener :

spinner.setOnItemSelectedListener(new OnItemSelectedListener() {
    @Override
    public void onItemSelected(AdapterView<?> parentView, View selectedItemView, int position, long id) {
        // SEU CÓDIGO 
    }

    @Override
    public void onNothingSelected(AdapterView<?> parentView) {
         // SEU CÓDIGO 
    }

});

Follow the documentation

Scroll to Top