MaterialSpinner icon indicating copy to clipboard operation
MaterialSpinner copied to clipboard

How to reset the MaterialSpinner?

Open bsoto24 opened this issue 6 years ago • 3 comments

I have 4 spinners whose values ​​depend on the selection of the others, when I select a value of the first spinner I update the value of the other spinner, I am working with the adapters to update the data and it does but visually the spinner does not reset to its value by default (with the hint). This is my code:

    @Override
    public void showDepartamentos(List<LocalidadTO> departamentos) {
        adapterDepartamentos.clear();
        adapterProvincias.clear();
        adapterDistritos.clear();
        adapterComplejos.clear();

        this.departamentos = departamentos;
        for (LocalidadTO l : departamentos) {
            adapterDepartamentos.add(l.getNombre());
        }

        adapterDepartamentos.notifyDataSetChanged();
        adapterProvincias.notifyDataSetChanged();
        adapterDistritos.notifyDataSetChanged();
        adapterComplejos.notifyDataSetChanged();

    }

My data is shown in the spinner but I just want the spinner to be visually reset by default with the hint

bsoto24 avatar Mar 06 '18 15:03 bsoto24

I have the same problem, I also set a new adapter on the spinner and is not working.

JorgeBazarte avatar Mar 07 '18 21:03 JorgeBazarte

The .setSelection(position); for the current adapter on the spinner doesn't reset the initial spinner position.

Briciovh avatar Mar 07 '18 21:03 Briciovh

@pepitofriki I just found a solution, just set your selected position to 0 before clear the adapter.

JorgeBazarte avatar Mar 07 '18 23:03 JorgeBazarte