1. Download our Official Android App: Forums for Android!

Apps problem on "Spinner"

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

  1. xiaojxiao

    xiaojxiao Newbie
    Thread Starter
    Rank:
    None
    Points:
    15
    Posts:
    10
    Joined:
    Sep 8, 2009

    Sep 8, 2009
    10
    0
    15
    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.
     

    Advertisement

  2. KeithG

    KeithG Well-Known Member
    Rank:
    None
    Points:
    46
    Posts:
    103
    Joined:
    Nov 15, 2009

    Nov 15, 2009
    103
    3
    46
    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
    Rank:
    None
    Points:
    15
    Posts:
    10
    Joined:
    Sep 8, 2009

    Sep 8, 2009
    10
    0
    15
    Thanks~~;)
     
  4. xiaojxiao

    xiaojxiao Newbie
    Thread Starter
    Rank:
    None
    Points:
    15
    Posts:
    10
    Joined:
    Sep 8, 2009

    Sep 8, 2009
    10
    0
    15
    Problem solved.

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

    absd Lurker
    Rank:
    None
    Points:
    6
    Posts:
    4
    Joined:
    Jul 31, 2010

    Jul 31, 2010
    4
    2
    6
    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...