Android Question How save scrollview panel in rotate?

omidaghakhani1368

Well-Known Member
Licensed User
Longtime User
Hi to all.
I Fill scrollview panel with item but when every time device rotated,scrollview reload
how prevent this action?
 

omidaghakhani1368

Well-Known Member
Licensed User
Longtime 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.
Oh yes,your reply is right but if i fill the scrollview in Activity_Create,in rotation device reloaded,is not?
 
Upvote 0

omidaghakhani1368

Well-Known Member
Licensed User
Longtime User
But Erel look at below code :
B4X:
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?
 
Upvote 0

omidaghakhani1368

Well-Known Member
Licensed User
Longtime 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
 
Upvote 0

LucaMs

Expert
Licensed User
Longtime 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

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.
 
Upvote 0

omidaghakhani1368

Well-Known Member
Licensed User
Longtime 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.
Erel please set Answered Option for each post
 
Upvote 0
Top