Android Question A few questions regarding different libraries and B4A

Daica

Active Member
Licensed User
Hello,
I come from a background of making Windows Application with Visual Studio, so forgive me if I have some terminologies incorrect.

1:
I am using this example as a starting point for my app: https://www.b4x.com/android/forum/threads/b4x-b4xdrawer-sliding-drawer.97828/
My app is going to have a few "screen" (?) such as a fullscreen map, settings, logs, etc.
Once I add the menu items using
B4X:
ListView1.AddSingleLine("Home")
How do I write the code to listen to those click events?

EDIT: I figured out the answer. If you're also wondering how to get the menu item click, it is the ListViewItem_Click event:

B4X:
Sub ListView1_ItemClick (Position As Int, Value As Object)
    Select Case Value
        Case "Home"
            MsgboxAsync(Value & " clicked", "")
        Case "Settings"
            MsgboxAsync(Value & " clicked", "")
    End Select
End Sub

I see people have images for those menu items, but the only option I see to add a bitmap image is to use AddTwoLines.

2:
Because the menu is going to be used to show different "screens", is switching screens similar to switching forms like Visual Studio?
For example, in Visual Studio I would do something like,
B4X:
Sub Button1_click
Form2.Show()
Form1.Hide()
End Sub

When I search the forum for having multiple Layout or "screens", people say to use a panel for each "screen" and to simply make the panel Visible = True or False.
The problem with this is, what if I have a bunch of buttons or controls (views) on each panel? Won't it get confusing and messy to work with 3+ panels that have a bunch of views on it?

For example, in the picture below, I have 1 panel with 6 buttons on it in the main window and 2 more copies on the outside.
Would I just work on these panels, making the GUI, and when I'm done just place them all on top of each other?

If I want to work with different Layouts, how would I switch between them and would the B4XDrawer still be present through the different layouts?

All I can say is I am thankful Erel made B4a because I don't think I can ever do Android App Development in Android Studio or other IDE, it's still confusing as heck
 
Last edited:

Jorge M A

Well-Known Member
Licensed User
Longtime User
Actually there are several questions for one post, and maybe it's worth starting at the beginning, which from my point of view is your number 2:
show different "screens"

Activities are somewhat similar to Windows Forms.
One major difference is that, while an activity is not in the foreground it can be killed in order to preserve memory. Usually you will want to save the state of the activity before it gets lost. Either in a persistent storage or in memory that is associated with the process.
Later this activity will be recreated when needed.

From here:
Android Process and activities life cycle

Then you can see:
Two activities example

And Better:
Using CallSubDelayed to interact between activities and services

I see people have images for those menu items

For that, you can take this approach:
Simple example B4XDrawer sliding drawer class with materialicons and fontawesome icons

I hope these will be helpful to you.
 
Upvote 0

Daica

Active Member
Licensed User
Thank you.
For the different activities, I just went with a bunch of panels and work on them away from the dark gray box.
Then when I want to bring it into view, I just set the panels .Top and .Left = the main panel's .Top and .Left and change visibility.
 
Upvote 0

Jorge M A

Well-Known Member
Licensed User
Longtime User
Terminology matters. Activities are more than just a bunch of panels.

Activities are somewhat similar to Windows Forms.

The problem with this is, what if I have a bunch of buttons or controls (views) on each panel? Won't it get confusing and messy to work with 3+ panels that have a bunch of views on it?

One solution is to deal with different activities.
 
Upvote 0
Top