Android: setSelection having no effect on Spinner

前端 未结 11 1289
我在风中等你
我在风中等你 2020-11-27 05:24

I\'m having some problem with setSelection on a Spinner. I set the value to be pre-selected when the spinner is shown in code, but it has no effect and the first alternative

11条回答
  •  余生分开走
    2020-11-27 05:51

    In my case none of the answers worked, so I queued the setSelection through a Handler

    new Handler().postDelayed(new Runnable() {        
        public void run() {
          mSpinner.setSelection(1);
        }
      }, 100);
    

    Doing this could cause problems when running on slow devices, but I'm working for a specific device so it's ok to use this hack

提交回复
热议问题