Android Question [Solved] Sub_Resume causes startup problem

anOparator

Active Member
Licensed User
Longtime User
I finally get Pause and Resume to manage the views on a screen rotation but now ImageVeiw2 does not display when the app starts up. (Because of the last line in Resume).
B4X:
Sub Process_Globals
   Public VisiBL As Boolean
   Public notVisiBL  As Boolean
End Sub
Sub Activity_Resume
     Label1.Visible = VisiBL
     ImageView1.Visible=VisiBL
     ImageView2.Visible = notVisiBL       ' This stops ImageView2 being visible on startup only.
End Sub

Sub Activity_Pause (UserClosed As Boolean)
If Label1.Visible = True Then
     VisiBL = True
     notVisiBL = False
     Label1.Visible = VisiBL
     ImageView1.Visible = VisiBL
     ImageView2.Visible = notVisiBL
Else
     VisiBL = False
     notVisiBL = True
     Label1.Visible = notVisiBL
     ImageView1.Visible = notVisiBL
     ImageView2.Visible = VisiBL
End If
End Sub
I read something about Designer Scripts but since Sub_Resume is the last thing that happens the problem remains.

How can I get ImageVeiw2 to display at startup?

thanks for all pointers.
 

Attachments

  • startupFail.zip
    150 KB · Views: 334

mangojack

Expert
Licensed User
Longtime User
This in no way solves your problem .. But I found it difficult to study your code ie.
B4X:
If Label1.Visible = TrueThen
   VisiBL = True
   notVisiBL = False
   Label1.Visible = VisiBL
   ImageView1.Visible = VisiBL
   ImageView2.Visible = notVisiBL
Else
   VisiBL = False
   notVisiBL = True
   Label1.Visible = notVisiBL         '@@  initially I thought Label1 was NOT visible ...  But notVisiBL = True .. so it Is Visable
   ImageView1.Visible = notVisiBL     ' same here
   ImageView2.Visible = VisiBL        'The reverse here .. ImageView2 is Visable ... No it is NOT Visible.
End If

Personally I would remove the Process Globals and just set the views.Visible property True or False.

Maybe look at State Manager to Save and Reset the UI on Pause and Resume ..
https://www.b4x.com/android/forum/t...applications-settings-and-state.9777/#content
 
Upvote 0

mangojack

Expert
Licensed User
Longtime User
Looking at your code further .. You repeat the code in Activity Pause .
B4X:
If Label1.Visible = True Then
     VisiBL = True
     notVisiBL = False
     Label1.Visible = VisiBL          'True
     ImageView1.Visible = VisiBL      'True
     ImageView2.Visible = notVisiBL   'False

Else
     VisiBL = False                
     notVisiBL = True
     Label1.Visible = notVisiBL       'True
     ImageView1.Visible = notVisiBL   'True
     ImageView2.Visible = VisiBL      'False
End If
 
Upvote 0

anOparator

Active Member
Licensed User
Longtime User
This in no way solves your problem .. But I found it difficult to study your code ie.
B4X:
If Label1.Visible = TrueThen
   VisiBL = True
   notVisiBL = False
   Label1.Visible = VisiBL
   ImageView1.Visible = VisiBL
   ImageView2.Visible = notVisiBL
Else
   VisiBL = False
   notVisiBL = True
   Label1.Visible = notVisiBL         '@@  initially I thought Label1 was NOT visible ...  But notVisiBL = True .. so it Is Visable
   ImageView1.Visible = notVisiBL     ' same here
   ImageView2.Visible = VisiBL        'The reverse here .. ImageView2 is Visable ... No it is NOT Visible.
End If

Personally I would remove the Process Globals and just set the views.Visible property True or False.

Maybe look at State Manager to Save and Reset the UI on Pause and Resume ..
https://www.b4x.com/android/forum/t...applications-settings-and-state.9777/#content
since ImageView and Label aren't UI views StateManager isn't the ticket, so I'm still at it. Am removing the Process_Globals and trying to make a variable that solves this. thanks.
 
Upvote 0

mc73

Well-Known Member
Licensed User
Longtime User
Haven't checked your project but couldn't you just set in your process_globals
B4X:
Public notVisiBL As Boolean=true
?

I ask this because I see that visiBL and notVisiBl both start with false, while in your subs I see that they get the opposite value.
 
Upvote 0

anOparator

Active Member
Licensed User
Longtime User
Haven't checked your project but couldn't you just set in your process_globals
B4X:
Public notVisiBL As Boolean=true
?

I ask this because I see that visiBL and notVisiBl both start with false, while in your subs I see that they get the opposite value.
I hope everyone enjoys the day because I've just read about how a Boolean defaults to False.
Thanks mc73 , it works like a charm.
 
Upvote 0

anOparator

Active Member
Licensed User
Longtime User
Looking at your code further .. You repeat the code in Activity Pause .
B4X:
If Label1.Visible = True Then
     VisiBL = True
     notVisiBL = False
     Label1.Visible = VisiBL          'True
     ImageView1.Visible = VisiBL      'True
     ImageView2.Visible = notVisiBL   'False

Else
     VisiBL = False                
     notVisiBL = True
     Label1.Visible = notVisiBL       'True
     ImageView1.Visible = notVisiBL   'True
     ImageView2.Visible = VisiBL      'False
End If
point well taken, I should have been generating Log entries for the variables.
 
Upvote 0
Top