Android Question How save scrollview panel in rotate?

Discussion in 'Android Questions' started by omidaghakhani1368, Oct 12, 2014.

  1. omidaghakhani1368

    omidaghakhani1368 Well-Known Member Licensed User

    Hi to all.
    I Fill scrollview panel with item but when every time device rotated,scrollview reload
    how prevent this action?
     
  2. LucaMs

    LucaMs Expert Licensed User

    Do you mean that you lose your data or you lose the views contained in the ScrollView?

    In the first case, you should use KeyValueStore.

    In the second case, you should fill the Scrollview in the Activity_Create.
     
  3. omidaghakhani1368

    omidaghakhani1368 Well-Known Member Licensed User

    Oh yes,your reply is right but if i fill the scrollview in Activity_Create,in rotation device reloaded,is not?
     
  4. Erel

    Erel Administrator Staff Member Licensed User

    That is correct. The activity is recreated when the orientation changes. However if you are loading any large objects such as bitmaps then you can store them in memory and reuse them.
     
  5. omidaghakhani1368

    omidaghakhani1368 Well-Known Member Licensed User

    But Erel look at below code :
    Code:
    Activity_Create(FirstTime as Boolean)
    dim top as int
    for i = 0 to 10
       
    dim k as button
       k.initialize(
    "")
       scrollview1.Panel.addview(k,
    0,top,150dip,50dip)
       top = top + 
    51dip
    next
    End sub
    now if activity create reload then scrollview load buttons,isn't?
     
  6. Erel

    Erel Administrator Staff Member Licensed User

    Yes. You need to recreate these buttons. However creating 10 buttons is a very quick operation.
     
    omidaghakhani1368 likes this.
  7. omidaghakhani1368

    omidaghakhani1368 Well-Known Member Licensed User

    ok ok but my item (button and imageview) is over 50 count
    my project is shop
    i load product list from database that is over 50 item
    and add it into scrollview panel
    now if activity rotated,then again load product from database
     
  8. LucaMs

    LucaMs Expert Licensed User

    You should fill the items while scrolling (i don't know how, but there are some posts on site about this).

    However, you could read the data from the DB and store them in a global map or in a file or by using KeyValueStore.
     
    omidaghakhani1368 likes this.
  9. omidaghakhani1368

    omidaghakhani1368 Well-Known Member Licensed User

    Erel please set Answered Option for each post
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice