Android Question Preserving EditText State - Create/Resume/Pause

RichardN

Well-Known Member
Licensed User
Longtime User
I have a single activity app with four EditText fields. To enhance the user experience the content of each view (and cursor position) must be preserved every time the app goes to the background or terminates. Easy enough I thought.... use KVS to save and reload the fields every time the app Resumes or Pauses.

This method does most of the job as when the app is simply sent to the background it can be recalled by the user and sure enough the focus remains with the last used EditText. Unfortunately as I have re-populated the EditText.Text from KVS in the Resume Event it is repopulated correctly but the cursor is repositioned to the beginning of the field instead of where the user left it.

What is the smartest method of restoring each of the four EditText fields exactly as the user left them in terms of content and focus whilst catering for the Create/Resume/Pause/OS terminate lifecycle?
 

teddybear

Well-Known Member
Licensed User
What is the smartest method of restoring each of the four EditText fields exactly as the user left them in terms of content and focus whilst catering for the Create/Resume/Pause/OS terminate lifecycle?

You can bind the same foucs event (EditText_FocusChanged) to the four EditText fields, and then put the current foucs item into kVS
 
Upvote 0
Top