Android Question Program Structure Correct??

marcel

Active Member
Licensed User
Longtime User
Hi,

I am struggling with the correct program structure as I am comming from DotNet developer and IOS. Could someone take a look to this if this is a clear setup before I run into trouble later one :)

I am using the sliding menu (jfeinstein10 SlidingMenu library) which you can find here: https://www.b4x.com/android/forum/threads/jfeinstein10-slidingmenu-library.36482/.

I want to be sure that this is a good setup of the program (see attached project). The menu calls and activity and above every view you need to have a panel with a menu button (three stripes) that activates the sliding menu. When using the back key the activity must be closed? Or hidden? What is normal and at what activity is the program closing and what is the logic to do this best.

Do you need to check the back key in every activity and close the app?? What would be the logic here.

And is the way I setup loading the menu and the header ok?

Thanks for helping me out..
 

Attachments

  • TestSideMenuTryOut.zip
    284.2 KB · Views: 191
Last edited:

Douglas Farias

Expert
Licensed User
Longtime User
i sugest to you to use panels and not activitys.
u can put your panel invisible and when you want to open only give a panel.visible = true
and add all your views, buttons etc on the panels, call this for example
panel main
panel register
etc....
 
Upvote 0

SteveTerrell

Active Member
Licensed User
Longtime User
i sugest to you to use panels and not activitys.
u can put your panel invisible and when you want to open only give a panel.visible = true
and add all your views, buttons etc on the panels, call this for example
panel main
panel register
etc....

Panels also work well for me.
I have a service handling bluetooth serial data for my app. I originally had several activities, one for each of the different things that the user could do (setting up, diagnostics, data transfer), that seemed to be the way Android software was supposed to be organised.
It was becoming quite complicated to keep track of which activity the service should communicate with, especially when something unexpected happened (disconnect, pause, resume etc.).
Panels have the great advantage, in my case, of all being in one activity. I have found it much simpler to use a state machine working with the panels in one activity. The state machine remembers which panel is active and knows what options are available from that panel and which panel to show next when something unexpected happens.
 
Upvote 0

Douglas Farias

Expert
Licensed User
Longtime User
the only problem of panels is the organization xD
for example my last project
qq.png


:):)
 
Upvote 0

SteveTerrell

Active Member
Licensed User
Longtime User
Fill a activity of panels is not a good choice.



(Global) Public CurrentActivity As Activity
CurrentActivity = Main

in a Code Module ;)

The problems I had were at a different level.
The service not only had to check which activity to send data to (that was simply a matter of putting the requesting activity name in the original data request sent to the service) but it also had to avoid running the requesting activity via a callSubDelayed if the app was actually paused by something beyond the control of the user.
That does lead to the problem of when does the service actually pass on the data (or tell something that the data was received and not used) and what does it tell.
One activity at least answers the question of what to send to and what to tell but of course the application needs different screens for different functions hence multiple panels.
 
Upvote 0

LucaMs

Expert
Licensed User
Longtime User
I use some panels (few) for each activity (I would use a larger number of panels for a grid or a board, for example and perhaps).

To test them I use emulators, of course, I could not have 100 devices (also, I own only one, hoping that it does not die :D).
 
Upvote 0

SteveTerrell

Active Member
Licensed User
Longtime User
I use the StdActionBar library where each panel associated with a tab has its own layout as in Erel's example. Some panels have overlaid sub-panels covering part of the tab panel, the sub-panels are all in the tab panel layout file and are created with the designer

The user controls what is happening by selecting a tab on the action bar which brings the selected panel to the front and sets up some labels, spinners etc. In some cases the code also re-sets the tabs on the action bar to offer context sensitive tabs. The sub-panels are brought to the front by touching buttons on the tab panel or currently visible sub-panel.

The StdActionBar example includes some code to handle different size screens.

The "BetterSlidingPanels" tutorial is also worth looking at.
 
Upvote 0

ciarli

Member
Licensed User
Longtime User
the only problem of panels is the organization xD
for example my last project


:):)
Hi Douglas, can you post a simple example with a jslidingmenu on the left with two menu items and theirs management (panel,slidingpanel, etc...) like your application? Best regards.
 
Upvote 0
Top