Android Question Modal Dialog with layout in b4a

gezueb

Active Member
Licensed User
Longtime User
Hi, I have an app developped with b4j using a layout to ask for some user choices with the "showandwait" feature. I want to port this app to b4a. However modal dialogs seem to be a bit of a problem in android. I can work with a loop in the main code waiting for a handshake flag until the choices layout is raising this flag when exited, but this is rather a crude method. I am sure there are better solutions.
Thank you for advice, Georg
 

gezueb

Active Member
Licensed User
Longtime User
Thank you, but no, that's not really a solution to my problem. For the mentioned choices I need a real layout with panel and buttons which i can configure with the designer. It should leave part of the original layout free, because the choices will depend on the things shown at the bottom of a landscape screen. For the same reason, I cannot use the "inlist" feature because that would cover those things that should still be visible. Msgboxes cannot be used for this as they cover items that should be visible and as they do not allow for more than 3 different answers. But thank you anyway !
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
You can use a a full screen transparent Panel to hold the layout and define an empty Click event routine to consume the Panel events.
It does not work exactly like a modal dialog, because the program doesn't hold on waiting for the answer.
You need to handle a return event.
 
Upvote 0

udg

Expert
Licensed User
Longtime User
Hi,
Klaus was quicker than me! I too suggest a transparent panel on which you show your options, avoidint to cover the main panel's areas you need to keep visible.
One additional note: in case you have many options, you could add to the transparent panel a CustomListView so to have a scrolling object showing many options in a limited available space. BTW, CLV let's you configure its items (panels) through existing layouts.

udg
 
Upvote 0

gezueb

Active Member
Licensed User
Longtime User
Thanks to you all for your suggestions, but maybe a I did not state the problem properly in my original question: It is vital that the dialog with the questions is MODAL. The call for the layout is in an 'if then else' structure, the if branch with manual input, the else branch an automated choice. If the questionaire layout does not hold the main code, then after the if .. then ..else I will not have the data complete in both cases and the program will not execute properly.

At present the code works okay, but after loadlayout "Questionaire" I coded a do while loop waiting for a handshake (proceed) from the questionaire and a doevents.
Do while proceed = false
doevents
loop
proceed is set to true in the questionare exit.
I can live with that, but it may be bad practise to do so.
 
Upvote 0

gezueb

Active Member
Licensed User
Longtime User
Thank you Erel, but that seems to leave me with either a bad solution or a worse one. I could stop the program flow with an extra messagebox but I was hoping for something more adequate. Anyway, I have learned that there obviously is no easy way to do modal dialogs on Android and stop dreaming about it:)
 
Upvote 0
Top