Rotation

etLux

Member
Licensed User
Longtime User
1.)

In a little mediaplayer app I'm doing I have a SeekBar.
In the initial layout it is set to a .Value of 50. [This
is used to control mediaplayer volume.]

During play in portrait mode, I drag it to, oh, say,
a value of 83.

When I rotate to landscape mode, the SeekBar.Value
immediately sets itself back to 50 (the initial design
setting).

I tried setting:
If UserChanged = False Then Return
in the SeekBar_ValueChanged Sub -- but that does
not do it.

I assume that this is because the layout is reloaded.
How do I get around this?

2.)

Just in general, is there a way to detect when
rotation takes place?

Thanks!


David
-----
David Sosnowski
The Music of David Sosnowski
 

derez

Expert
Licensed User
Longtime User
David
All views are recreated when you rotate the device, so to keep the value of the seekbar you have to store the value before the rotation takes place - by a process global variable in activity_pause sub. Then in Activity_resume you can re-allocate the value of the seekbar to the stored value.
You don't need to know when the rotation happens because the activity_pause is fired when it happens.
 
Upvote 0

etLux

Member
Licensed User
Longtime User
Thank you, David!

With a little tinkering, got it -- set up the globals,
set a few variables to values in FirstTime, then
manage it with the _Pause and _Resume. Works
fine.

Which, of course, leads me to additional questions
... lol.

Let's say I need two different layouts -- would I
not need to know that rotation occurred (and to
which orientation) in order to load the new layout
for that new orientation?

My best,



David
-----
David Sosnowski
The Music of David Sosnowski
 
Upvote 0
Top