Android Question Design question - multiple pages with menu

Dave61

Member
Licensed User
Longtime User
B4A beginner here - long time .Net programmer and dabbled with a couple of Android Studio projects before purchasing B4A.

I want to develop an app with multiple pages (about 18 pages), each acting as forms - the results of each form entry will be sent to a connected device. The interface is something like the Google Photos or the Google Drive apps as far as the menus and page operations go.

I want to navigate between the different pages using a menu. My question is whether I should:
a) create an app with multiple activities, 1 for each page - and somehow figure out how to add a menu into that so the menu is visible no matter what activity I am in. Or:
b) create an app with 1 activity and a menu, with each page just downloading a new panel (or maybe a new layout?)

So far I have something using method (b) working ok, copied from the
https://www.b4x.com/android/forum/threads/ahnavigationdrawer-native-google-navigation-drawer.31461/
topic in this forum. It does work and looks nice but I am just wondering whether I am limiting myself further down the road?
Reading the general (not B4A) Android sites I came across this:
"can make a abstract base Activity that implements the menu and then extend that with your 3 concrete Activities" but I don't know if B4A can do that anyway, or whether I can or should be looking at method (a) anyway.

I am interested in any info that can lead me in the right direction.

Thanks,

Dave
 

Dave61

Member
Licensed User
Longtime User
Thanks for the reply Erel. I managed to get a class menu working with multiple activities so each menu option opens a new activity with associated views.
I got side-tracked on the rest of the project which is now going well and now can return to 1 last problem with the class menu.

My problem is that when the menu is opened on top of the activity, I can see all the view items through the menu - they are on top of the menu items. I can't see how to stop that.

Each activity calls the class menu using code like this:

Sub Activity_Resume
' Add the menu.
Dim AppMenu As ClassMenu
AppMenu.Initialize(Activity, "Weather") ' this calls ClassMenu.Initialize()
' Add an EditText view
txtWindSpeed.Initialize("")
Activity.AddView(txtWindSpeed, textLeft, lbl1.Top, textWidth, FieldHeight)
txtWindSpeed.InputType=txtWindSpeed.INPUT_TYPE_NUMBERS ' this allows only integers.
'etc​
End Sub


I have tried 2 things to fix this but both cause other side effects.

1) I tried to dim and init the menu after the EditText (and the rest of the views). This causes the menu to now appear on top of the EditText and the EditText doesn't show through. However, I cannot then action the EditText - the keyboard doesn't appear when I click on it.

2) I put the menu back before the initing of the rest of the views and played around with BringToFront and SendToBack. The AppMenu doesn't have a BringToFront method so I sent all the other controls to the back. That stops them showing through the menu, but again I cannot action the views if they are at the back.

I figure I must be doing something simple wrong - I can't imagine everyone else would allow this. I am considering maybe I need to have a panel and hide the info behind it but that seems like a nasty workaround - probably there is a better way.

How does one ensure the Views can stay behind the class menu but still be usable?

Also I don't think I really understand how Views are 'layered' if created entirely in code. Does any control initialised (or maybe added with addview) always appear on top of a previously initialised or added view?

Thanks,

Dave
 
Upvote 0

eurojam

Well-Known Member
Licensed User
Longtime User
Upvote 0

Dave61

Member
Licensed User
Longtime User
Actually that is already what I am basing my menu on. Not sure why I am seeing the activity views on top of the menu - but I had to modify the example to a class and could have done something wrong.
 
Upvote 0

Dave61

Member
Licensed User
Longtime User
I have created a small test project which demonstrates the problem - the text in the activity is visible through the menu (on top of the menu) when the menu is active.
The code is based on
http://developer.android.com/design/patterns/navigation-drawer.html and https://www.b4x.com/android/forum/threads/ahnavigationdrawer-native-google-navigation-drawer.31461/
but the menu was changed to a class so I could run multiple activities all with the same menu. I don't have any problem with the original code but something associated with putting it into a class has (presumably) caused this problem.
 

Attachments

  • Bug_TwoActivitiesWithRealMenu.zip
    73 KB · Views: 372
Upvote 0
Top