Just starting out..

hpd71

Member
Licensed User
Longtime User
Hi,
I am a vb.net developer who just purchase B4A.

I have gone through the begginer guide, but still a bit unsure of a few things and hoping somebody will help out.

I have a B4A project, and I created a number of layouts in the designer.

In my code section, in the activity_create I load one of my layouts which is my apps splash screen.

The user pressed a button on the layout and I want to dispose of it and go to my applications main layout which I call mainL.

So in my button click code I do another loadlayout("mainl"), but what happens on my screen is that I get both layouts at the same time... I can't figure out how to remove or dispose of my splash screen layout.

Am I going about the correct way here ?? Or am I doing it totally wrong..?

Thanks
 

joseluis

Active Member
Licensed User
Longtime User
The usual way people do that is to have two activities (two activity modules). The button of the first activity opens the second activity with its own layout. e.g.
B4X:
Sub MyButton_Click()
  StartActivity("MySecondActivity")
End Sub
That is much cleaner than messing around having to remove all views of the activity, and loading another layout on it.

As a side note, normally if you need to use only one activity with several layouts, for a good reason, then is also cleaner to use panels to load the layouts on them, instead directly on the activty, and then change between panels.
 
Upvote 0

hpd71

Member
Licensed User
Longtime User
splash screen

Hi,

So when it comes to having a splash screen/login screen would it be better to use activities as you mention or panels.

With the panels concept, do you mean in the designer, creating a lot of panel view, and putting the controls on them, and then just setting the panels visible property to be false/true as needed ?

Thanks for you reply...
 
Upvote 0

latcc

Banned
I think the best way to do what you want is to use a single activity and show what you need to show using multiple panels. Create a panel for the splash screen and another for your program (or several if you need them).

Make all program panels visible = false and the splash panel visible=true.

The splash panel shows on start up. When a button is pressed you set the splash panel to visible=false and set your initial/main program panel to visible= true.

You can use a timer to show the splash screen panel for a time and then hide it and display the program if you prefer.

You should use...

panel1.visible=[boolean]

panel1.bringtofront

when displaying multiple panels.
 
Last edited:
Upvote 0

klaus

Expert
Licensed User
Longtime User
I would suggest you to use different activities as joseluis already mentioned.
That's the way Android works.
The disadvantages with one activity and panels are:
- You must manage what panel is visible hide it set another to visible.
- If you change the device orientation you need to remember what panel was currently visible and display this one.
- You must manage the Back key, to display the right panel.
Working with activities, all this is automatic.

Best regards.
 
Upvote 0

Mahares

Expert
Licensed User
Longtime User
Klaus: What about one activity with one tabhost that has several tabs and a panel for each tab. Is what you suggest (several activities) more efficient than tab pages. Is so, can you please elaborate?
Thanks
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
As usual there are different ways to design a user interface and it depends also on the number of different screens you have in your application.
Personally I've never liked TabHosts, nor did I like menus. But these are personal preferences. I have always prefered toolboxes with buttons and tooltips. The advantage, for me, is that I can manage all this stuff at my convenience. Change button images, hide and show buttons according to the program configuration etc. I prefer to see only the available functions and nothing else.
Especially in Android I find that the Tabs take too much place and they are on top. The disadvatage is that when you select a tab the screen is covered by your hand or fingers. In my applications I place the buttons on bottom in portrait or on the right side in landscape (I'm a right hander) to leave the screen visible. Changing Tabs isn't easy.
For me, menus are not useful either because you cannot change menu items afterwards nor can you hide them nor do you have an overlook on what functions are available.
All these principles are not only valid for Android, I used these also in Windows programs.
But, all this is personal feeling and convenience.
Coming back to the one activity and panels or several activities subject, when I began programming with B4A, my tendency was using one activity with several panels (Windows habit with Forms) but I changed my mind and came to the several activity solution because I find it more efficient in Android.
You could have a look at the GPSExample program if you are intersted in an example of my point of view for user interface and program flow.
Anyway, as said before, that's just my point of view.

Best regards.
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…