Android Question How to make your own modal popups?

NeoTechni

Well-Known Member
Licensed User
Longtime User
I know about the custom dialog stuff, but that only lets you add 1 view, and uses Android OK/Cancel buttons. Is there a way to make a modal form, so it darkens the screen, and you can add any number of views, and have any of them close it, and return a value to the function that called it?

I've been using non-modal popups by using Question ID numbers, so I know what data I'm expecting at the end, so everything works asynchronously, but it's getting too complex/a pain to keep up...
 

deltacode

Member
Licensed User
Longtime User
Well I have achieved this effect by cheating.

I created a layout filled with a panel whos color is black but opaque is set around 30-40 giving the dimmed out effect.
Upon this i add another panel which is centered onscreen and contains all my other controls.

When calling this panel on the current activity, as the main panel is the full screen it gives the modal and dimmed out effect.
Ill add a picture later if it helps to see the effect.
 
Upvote 0

NeoTechni

Well-Known Member
Licensed User
Longtime User
I cheated that same way, but thats not really modal since it doesnt return the previous place in the stack like msgbox does
 
Upvote 0

derez

Expert
Licensed User
Longtime User
You can find several examples at my classes - ColorPalette, DEDialogs, Message, Wait.
Why do you call it cheating ? Who is cheated ?
 
Upvote 0

NeoTechni

Well-Known Member
Licensed User
Longtime User
I call it cheating cause its the exact thing I was asking not to do cause it's not as programmer-friendly. I want it to be like msgbox, returns to the point that called it.
 
Upvote 0

Informatix

Expert
Licensed User
Longtime User
I know about the custom dialog stuff, but that only lets you add 1 view, and uses Android OK/Cancel buttons. Is there a way to make a modal form, so it darkens the screen, and you can add any number of views, and have any of them close it, and return a value to the function that called it?
You should try the custom dialog of BetterDialogs. It has no such limits.
 
Upvote 0
Top