Android Question Screen Orientation

Kiumbe

Member
Licensed User
Hello,

Am still learning B4A and so far, it’s a fascinating language, very intuitive and fun. Thanks to Erel and the whole team. I have realized when working with my app, if the layout has an edittext view with content already keyed, when I change the phone orientation, the edittext clears all the content and I have to enter text again, how do I change this to avoid losing entered content on an Edittext view?

Thanks Members
 

zed

Active Member
Licensed User
I can't reproduce the error.
Without knowing the code, it is not possible to correct the error.
 
Upvote 0

GMan

Well-Known Member
Licensed User
Longtime User
We had this Theme some days ago.
AFAIK Erel told that this is a system function and can not be manipulated
 
Upvote 0

FrostCodes

Active Member
Licensed User
Longtime User
Hello,

Am still learning B4A and so far, it’s a fascinating language, very intuitive and fun. Thanks to Erel and the whole team. I have realized when working with my app, if the layout has an edittext view with content already keyed, when I change the phone orientation, the edittext clears all the content and I have to enter text again, how do I change this to avoid losing entered content on an Edittext view?

Thanks Members
Save the text to a global variable on activity_paused and load it back on activity_resume
 
Upvote 0

walt61

Active Member
Licensed User
Longtime User
Some tips:
- The Activity is re-created when the orientation changes; all views are re-initialised
- Have a look at the Android activity lifecycle and at @Erel 's additional comments
- As @FrostCodes mentioned, you could save and restore the data; the StateManager class used to be useful, but as @Erel added to that thread: this is old code; use B4XPages + KVS2 instead
- Use B4Xpages (it makes things a lot easier); the orientation is normally locked in a B4XPages app, but search the forum for 'B4XPages orientation' and some potentially interesting threads will appear
- B4XPages also makes it a lot easier to write cross-platform code
 
Upvote 1

Kiumbe

Member
Licensed User
Thanks all for your information, saving and restoring data from a global variable could help if maybe I had 1 edittext with data, but if I have several edittext boxes for data entry, it makes the code long with variables. So their is currently no fix for this with B4A, let me try and reduce the number of edittext views to save on variables that may confuse me. Anyway, am grateful for your valuable assistance.
 
Upvote 0

John Naylor

Active Member
Licensed User
Longtime User
Thanks all for your information, saving and restoring data from a global variable could help if maybe I had 1 edittext with data, but if I have several edittext boxes for data entry, it makes the code long with variables. So their is currently no fix for this with B4A, let me try and reduce the number of edittext views to save on variables that may confuse me. Anyway, am grateful for your valuable assistance.
It's not an issue with B4A it's to do with Android itself. You can iterate through all controls to make saving easier or better still, switch to B4XPages.

[Edit] If you insist on using activities you can use State Manager to make the transition between orientations easy.
 
Last edited:
Upvote 0

Cableguy

Expert
Licensed User
Longtime User
I may be asking a "tree behind the forest " kind of question here but, are you using b4pages? Isn't b4pages supposed to manage that and many other scenarios that would otherwise need in fact the saving upon pause and read on resume?
 
Upvote 0
Top