Android Question Visibility of panels and label...

Luis Felipe

Member
Licensed User
Longtime User
Hello everybody,

Improving my first app with B4A some things that was working, are not working now.

I added a new Module/Activity, moving my first activity/screen as the second one.
The problem is that when I clicked a button on the first screen, the 2nd one doesn't appear on screen.
I tried with the ".visibility" property but it doesn't work.

Probably I'm going to have the same problem when I'd like to go from my second screen (to create a survey, with a lot of panels !) to the first one (a menu with the counter and the button to go to the second screen)

Another problem is that I'm doing a "select count(*)" in my DB (sqlite) in order to know the number of surveys not send but the variable used to show the number doesn't work and I don't know why.

Thank you for your time...

Lou
 

Attachments

  • SurveyTravel2.zip
    21.5 KB · Views: 115

Luis Felipe

Member
Licensed User
Longtime User
I think that you are confusing layout files with activities.

They are not really related.

You need to call StartActivity(MenuPrincipal) to show this activity.

May'be you're right Erel : I'm using an example from the forun called "ScrollViewBigPanel" and I modified it.
The problem is not "MenuPrincipal" which I can see, the problem is "EncuestaViajeros" and with that one I'm using that code:
B4X:
Sub btnEncViajeros_Click
    pnlMenuPrincipal.Visible = False
    StartActivity("EncuestaViajeros")
End Sub
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
What exactly do you want to do ?
You load the MenuPrincipal layout file in the Main Activity onto scvTest.Panel.
Then you have defined a new Activity MenuPrincipal where you load also the MenuPrincipal layout file ?
But you never start MenuPrincipal activity.
Sorry, but I don't understand the logic behind this.
You must explain in detail what exactly you want to do.
 
Upvote 0

Luis Felipe

Member
Licensed User
Longtime User
What exactly do you want to do ?
You load the MenuPrincipal layout file in the Main Activity onto scvTest.Panel.
Then you have defined a new Activity MenuPrincipal where you load also the MenuPrincipal layout file ?
But you never start MenuPrincipal activity.
Sorry, but I don't understand the logic behind this.
You must explain in detail what exactly you want to do.
Hi Klaus,
you're exactly right, I've to explain you what I need to do.
Sorry for the mess, I've used the example "ScrollViewBigPanel" thinking it was what I need and then I had to modify it because my boss wanted more things.
Anyway here is the workflow:
- The first screen which is the layout MenuPrincipal that is divided it in 2 parts/panel:
* the first one pnlMenuPrincipal has one button (later 3 more) in order to go to a survey (in that case the screen/module called EncuestaViajeros).
* the second, called pnlAdminEncuestas is a label that is made to show how many records are in the sqlite db that are not sent (with the field ca_enviado='N'). Later I've to put a button in order to create a text file with all that records to send it by mail (but I haven't done it yet)

- The second screen with the layout ScrollViewLayout in the screen/module "EncuestaViajeros" is a large survey (800x2400 pixeles) with a lot of questions. That why I'd like to use a lot of panels (because there are a lot of groups of radiobuttons) in a scrollview. When the button "btnValidar1" is clicked all the values of the radiobuttons, editText fields are saved in the latbus.db database (I can't see if it's well done BTW) and then I'd like to "go back" to the First Screen where I can see that there is one more record. Of course when I'm going to the second screen I'd like to see all the fields un-selected.
I hope that's more clear...
Merci.
Best regards,
Lou
 

Attachments

  • SurveyTravel4.zip
    20.9 KB · Views: 107
Upvote 0

klaus

Expert
Licensed User
Longtime User
In Main remove this line pnlMenuPrincipal.Visible = False, you dont need to set pnlMenuPrincipal invisible.
In EncuestaViajeros you should replace Activity.LoadLayout("ScrollViewLayout") by Activity.LoadLayout("Main") to load the ScrollView !
You must be consistent in your layout variants.
Main : 600 / 913
MenuPrincipal : 800 / 1216
ScrollViewLayout : 800 / 1216
 
Upvote 0

Luis Felipe

Member
Licensed User
Longtime User
In Main remove this line pnlMenuPrincipal.Visible = False, you dont need to set pnlMenuPrincipal invisible.
In EncuestaViajeros you should replace Activity.LoadLayout("ScrollViewLayout") by Activity.LoadLayout("Main") to load the ScrollView !
You must be consistent in your layout variants.
Main : 600 / 913
MenuPrincipal : 800 / 1216
ScrollViewLayout : 800 / 1216
Thank you for your time Klaus. I made the changes but now the app does not even launch.
It's seems to have a problem with that line:
B4X:
SQLResult = SQL1.ExecQuerySingleResult("SELECT COUNT(*) FROM viajeros WHERE ca_enviado ='N'")
:-(
 

Attachments

  • SurveyTravel5.zip
    21 KB · Views: 120
Upvote 0

klaus

Expert
Licensed User
Longtime User
You need to give more information !
What error do you get ?
The first run when there is no database the program runs OK.
The second time whwn the database does exist, you don't initialize the database !
I suppose that you copied the initialization of the database from the SQLiteLit1 project, but you didn't copy all you need.
You missed a part of the code in Activity_Resume.
Add in Activity_Resume:
B4X:
Sub Activity_Resume
   ' If the database is not initialized we initialize it
   If SQL1.IsInitialized = False Then
     SQL1.Initialize(File.DirInternal, "persons.db", True)
   End If
   ContarEncuestas
End Sub
If you modify the database in another activity I suggest you to move ContarEncuestas from Activity_Create to Activity_Resume to make sure that the display is updated.
 
Upvote 0

Luis Felipe

Member
Licensed User
Longtime User
You need to give more information !
What error do you get ?
The first run when there is no database the program runs OK.
The second time whwn the database does exist, you don't initialize the database !
I suppose that you copied the initialization of the database from the SQLiteLit1 project, but you didn't copy all you need.
You missed a part of the code in Activity_Resume.
Add in Activity_Resume:
B4X:
Sub Activity_Resume
   ' If the database is not initialized we initialize it
   If SQL1.IsInitialized = False Then
     SQL1.Initialize(File.DirInternal, "persons.db", True)
   End If
   ContarEncuestas
End Sub
If you modify the database in another activity I suggest you to move ContarEncuestas from Activity_Create to Activity_Resume to make sure that the display is updated.

That's right Klaus, I copied code from the SQLiteLit1 project.
There is no error message, the app just exit.
And I noticed that if I comment in the code ContarEncuestas the app does not exit, but I need that function when the first screen/activity appears in order to show of much survey are not already sent...
Thank you for your help.
 
Upvote 0
Top