problem on "Spinner"


Last Updated:

  1. xiaojxiao

    xiaojxiao Member This Topic's Starter

    Joined:
    Sep 8, 2009
    Messages:
    10
    Likes Received:
    0
    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?:confused:

    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.
     

    Advertisement
  2. KeithG

    KeithG Well-Known Member

    Joined:
    Nov 15, 2009
    Messages:
    103
    Likes Received:
    3
    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 Member This Topic's Starter

    Joined:
    Sep 8, 2009
    Messages:
    10
    Likes Received:
    0
    Thanks~~;)
     
  4. xiaojxiao

    xiaojxiao Member This Topic's Starter

    Joined:
    Sep 8, 2009
    Messages:
    10
    Likes Received:
    0
    Problem solved.

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

    absd New Member

    Joined:
    Jul 31, 2010
    Messages:
    4
    Likes Received:
    2
    Just dropped by to say thanks.
    I was struggling with this one for quite a while before I bumped into your answer.

    Thank you!
     

Share This Page

Loading...