Error spinner android

Asked

Viewed 127 times

0

The method setOnItemSelectedListener is not called. I am trying to get a value of an item by means of a spinner, but when I click on the item I want, nothing happens.

I created a TAG to check if the method is being called and I did not get any results. Follow the code:

adapter = new ArrayAdapter < String > (this, android.R.layout.simple_spinner_dropdown_item, listColab);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spinnerProf.setAdapter(adapter);

spinnerProf.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
    @Override
    public void onItemSelected(AdapterView << ? > adapterView, View view, int i, long l) {
        Log.i(TAG, adapterView.getItemAtPosition(i).toString());
    }

    @Override
    public void onNothingSelected(AdapterView << ? > adapterView) {
        Log.i(TAG, "teste");

    }
});

1 answer

0

I think I found the problem, it was in my arrayList composed of data from a Webservice, I just can’t explain well the reason why the data was displayed as expected in my spinner, when creating another array and filling it with fixed data the problem did not occur, if you discover the reason for the error I will return to complement the answer.

Browser other questions tagged

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