Search code examples
androidspinner

Android spinner, OnItemSelectedListener is not called when selecting the same item?


For a particular reason I need my spinner's OnItemSelectedListener gets called even when user chooses the same item, but normally it doesn't. So I don't know how it is possible! Any trick or libraries that can solve my problem?


Solution

  • ok
    you can use addOnLayoutChangeListener

    yourspinner.addOnLayoutChangeListener(new View.OnLayoutChangeListener() {
        @Override
        public void onLayoutChange(View view, int i, int i1, int i2, int i3, int i4, int i5, int i6, int i7) {
            Toast.makeText(context, "item is : " + yourspinner.getSelectedItemPosition(), Toast.LENGTH_SHORT).show();
        }
    });