Calling a method using Spinner selection

Asked

Viewed 195 times

3

It is possible to call a method using a Spinner android?

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

1 answer

2


Through the 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 
    }

});

Follows the documentation

  • Ossa is very similar to Listview. I will test here already validated your answer.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.