Problem with ScrollView after returning from Home key press

U

unba1300

Guest
Hi. I have an activity that loads a layout which contains a scrollview, and then with code, I add ten edittexts and populate their values from a list. This works well with the exception of going back to the app after the Home key was pressed. Depending on if I initialize the scrollview and load the layout in Activity_Create or Activity_Resume, the results are different, and both undesirable. The first attachment shows what the activity normally looks like, the second after returning from home with the init and load in Activity_Create (the outline around the edittext that has focus is incomplete and FocusChanged no longer selects the text), and the third after returning from home with the init and load in Activity_Resume (the instructions in the label become more and more 'bold' each time and notice the ghosting in the edittext near the top). Could someone please help shed some light on what is wrong? (I had to crop the images to get the size down for posting).
B4X:
Sub Activity_Create(FirstTime As Boolean)
  svPeople.Initialize(500dip)
  Activity.LoadLayout("LayoutPeople")
End Sub
B4X:
Sub Activity_Resume
  ' svPeople.Initialize(500dip)
  ' Activity.LoadLayout("LayoutPeople")
  For i = 9 To 0 Step -1
    Dim et As EditText
    et.Initialize("et")
    svPeople.Panel.AddView(et,5dip, 5dip+i*50dip, 310dip, 40dip)
    et.SingleLine = True
    et.Tag = i
    If statePaused = False Then
      If i < Main.lstupeople.Size Then
        et.Text = Main.lstupeople.Get(i)
      End If
    Else
      et.Text = Main.lsttemp.Get(i)
    End If
  Next
End Sub
I do not have a problem when the emulator is rotated.
B4X:
Sub Activity_Pause (UserClosed As Boolean)
  If UserClosed = False Then
    statePaused = True
    Dim et As EditText
    Main.lsttemp.Initialize
  For i = 9 To 0 Step -1
    et = svPeople.Panel.GetView(i)
    Main.lsttemp.Add(et.text)
  Next
  Else
    statePaused = False
    Activity.Finish
  End If 
End Sub
 

Attachments

  • People - normal 2.jpg
    People - normal 2.jpg
    13.7 KB · Views: 222
  • People - code in Create 2.jpg
    People - code in Create 2.jpg
    13.3 KB · Views: 189
  • People - code in Resume 2.jpg
    People - code in Resume 2.jpg
    18.6 KB · Views: 228
Last edited by a moderator:
U

unba1300

Guest
I've read that four times already. Still having a hard time grasping some things. Anyway, I moved all the code from Resume to Create and it works okay now (as far as I've seen). It seems that when returning after pressing the Home key, there is no need to do anything in the code - it just goes back to where it was; which is good. But still seems odd to me now that nothing is in Resume. I'll keep trying and learning. Thanks.
 
Last edited by a moderator:
Upvote 0
Top