1. Are you ready for the Galaxy S20? Here is everything we know so far!

problem on "Spinner"

Discussion in 'Android Development' started by xiaojxiao, Jan 8, 2010.

  1. xiaojxiao

    xiaojxiao Newbie
    Thread Starter

    Hi~

    I have used spinner in my app. When I use "setSelection(pos)" first time, it works correctly. But if I make another calling for "setSelection(pos)" after, the spinner will always show the first position instead of showing the correct position which is not 0.
    I have checked the code, and the position value is correct.
    How to solve this problem?:thinking:

    I have google it, and the link below shows the same unsolved problem as mine.
    [android-developers] Spinner setSelection(int) problem - bryan - com.googlegroups.android-developers - MarkMail

    Thanks very much.
     


  2. KeithG

    KeithG Well-Known Member

    You could force the widget/view to redraw by invalidating it. However if this is a bug deeper within the widget draw logic, invalidating may not produce the proper result.

    But its possible that the setSelection() call didn't invalidate the view, so the framework doesn't know it needs to redraw the widget with the new value.

    Just a guess...
     
  3. xiaojxiao

    xiaojxiao Newbie
    Thread Starter

    Thanks~~;)
     
  4. xiaojxiao

    xiaojxiao Newbie
    Thread Starter

    Problem solved.

    use"setSelection(int position, boolean animate)".
     
  5. absd

    absd Lurker

    Just dropped by to say thanks.
    I was struggling with this one for quite a while before I bumped into your answer.

    Thank you!
     
Loading...

Share This Page

Loading...