B4A Library [Lib] BetterDialogs

I tried to improve the most useful dialogs of the Dialogs library. In my version, HTML tags are interpreted (even in the text of buttons), the InputBox uses a Masked EditText and has more options, you can check if the input is valid before closing the dialog, and the CustomDialog is fully customizable. I also solved an issue with the virtual keyboard.

MsgBox (under Gingerbread and JellyBean):

msgbox.png


InputBox (under Gingerbread and JellyBean):

inputbox.png


CustomDialog (under Gingerbread and JellyBean):

cd1.jpg


Another CustomDialog (under Gingerbread and JellyBean):

cd2.png


v1.1:
- I added a CloseDialog function;
- I added a margin parameter to the custom dialog.

v1.2:
- I fixed a bug in InputBox when there's a default value;
- I added the BackKeyPressed event for custom dialogs.

v1.3:
- I added a PasswordMode option to the InputBox;
- I added a CancelOnTouchOutside option.

v1.4:
- I added a CursorPosition option to the InputBox.

v2.0:
- I moved the CustomDialog parameters to the BD_CustomDlgParams class.
- I added two new parameters: Duration and DialogGravity.
- I removed the Margin parameter and added the MarginHeight parameter (to be used when Gravity is set to TOP).
- The BodyWidth and BodyHeight parameters defines now accurately the size of the dialog body.

v2.1:
- I added a "closing" event raised just before a custom dialog is dismissed. You can cancel the closure by returning False.

v2.11:
- I added the "DlgResponse" parameter to the Closing event.

This library does not work with Android versions < 2.
It requires another library: Masked EditText
 

Attachments

  • BetterDialogs v2.11.zip
    55.6 KB · Views: 2,243
  • Java source - BetterDialogs.zip
    8.5 KB · Views: 671
Last edited:

yuhong

Member
Licensed User
Longtime User
I want to define a dialog use BD, include use bmp at title, ok button use bmp.
QQ图片20130718093434.jpg

Can u help me?
thanks!
 

Informatix

Expert
Licensed User
Longtime User
I want to define a dialog use BD, include use bmp at title, ok button use bmp.
View attachment 18459
Can u help me?
thanks!

I can't see where are the bitmaps in your screenshot. Anyway, to add a bitmap to the title, either use the Icon parameter of the MsgBox function, or create your own title (with an ImageView or a Panel) and pass it to a CustomDialog. For the Ok button, unfortunately, there's no easy way to set a bitmap with the current version, BUT there's a possible workaround: place your buttons in the dialog body (thus you're free to use any view for them) of the CustomDialog and set no buttons.
 

GMan

Well-Known Member
Licensed User
Longtime User
Très bien fait :)
 

luke2012

Well-Known Member
Licensed User
Longtime User
First of all my compliments for the library!

I have a problem using "LoadDrawable" sub and more in detail I got a app crash running the following line :

Return r.RunMethod2("getDrawable", ID_Drawable, "java.lang.int")

I'm running the app on Android JB 4.3
 

Informatix

Expert
Licensed User
Longtime User
First of all my compliments for the library!

I have a problem using "LoadDrawable" sub and more in detail I got a app crash running the following line :

Return r.RunMethod2("getDrawable", ID_Drawable, "java.lang.int")

I'm running the app on Android JB 4.3
Sorry but there's nothing in your message that helps me. I don't know what's the error, I don't know what you did exactly and whether you just tried the example (that would be surprising because it runs fine with JB 4.3). Did you use the latest version? What says the log?
 

PSEAD

Member
Licensed User
Longtime User
Maybe in a future version.
Or you can create a custom dialog and get the input with a Masked EditText.
Thanks.
I am using the validation callback which works nicely for a password, just that it would also be good to hide the chars too.
 

obscure

Member
Licensed User
Longtime User
Hi Informatix!

I just discovered this library.
Unfortunately running your example brings up the following error as soon as the InputBox should
pop up:

HTML:
main_activity_resume (java line: 282)
java.lang.NoClassDefFoundError: flm.b4a.maskededittext.MaskedEditTextWrapper
    at flm.b4a.betterdialogs.BetterDialogs.InputBox(BetterDialogs.java:367)
    at flm.b4a.testdialogs.main._activity_resume(main.java:282)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:521)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:167)
    at anywheresoftware.b4a.BA.raiseEvent(BA.java:151)
    at flm.b4a.testdialogs.main.afterFirstLayout(main.java:91)
    at flm.b4a.testdialogs.main.access$100(main.java:16)
    at flm.b4a.testdialogs.main$WaitForLayout.run(main.java:72)
    at android.os.Handler.handleCallback(Handler.java:587)
    at android.os.Handler.dispatchMessage(Handler.java:92)
    at android.os.Looper.loop(Looper.java:123)
    at android.app.ActivityThread.main(ActivityThread.java:4627)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:521)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
    at dalvik.system.NativeStart.main(Native Method)

Maybe you have an idea what causes this?

Thanks!

cheers,
obscure
 

obscure

Member
Licensed User
Longtime User
Hey Informatix.

Thanks for your reply!
Sure, I've read and understand the error message.
The scary thing is, I do have the latest version of Masked EditText
installed, so the error doesn' make too much sense, does it? ;)
Any other idea?
It's not that important though. I modified Andrew Graham's library to do
what I need. I might need your library for a future project.
By the way, good job!

Cheers,
obscure
 
Last edited:

Informatix

Expert
Licensed User
Longtime User
Hey Informatix.

Thanks for your reply!
Sure, I've read and understand the error message.
The scary thing is, I do have the latest version of Masked EditText
installed, so the error doesn' make too much sense, does it? ;)
Any other idea?
It's not that important though. I modified Andrew Graham's library to do
what I need. I might need your library for a future project.
By the way, good job!

Cheers,
obscure

I don't see any other explanation.

Do you see the MaskedEditText lib in the Libs tab of your IDE? What are the displayed versions of the two libraries?
 

NeoTechni

Well-Known Member
Licensed User
Longtime User
How can I get rid of the border around the buttons, and put some space in between them? And get the text to center properly vertically? (they're a bit too high)
 

Attachments

  • screenshot.jpg
    screenshot.jpg
    45.7 KB · Views: 302

NeoTechni

Well-Known Member
Licensed User
Longtime User
How i get them to act as ok/cancel/positive then?

I think i can do what i need if you give me the formula you use to calculate their width/height. Then i can draw what i need at the correct size instead and make it look better
 

NeoTechni

Well-Known Member
Licensed User
Longtime User
I'm trying to use panels instead of buttons to get rid of the border, and bitmapdrawables instead of colordrawables, but it's not adding them...
 

Informatix

Expert
Licensed User
Longtime User
How i get them to act as ok/cancel/positive then?

With CloseDialog.

I think i can do what i need if you give me the formula you use to calculate their width/height. Then i can draw what i need at the correct size instead and make it look better

There's no formula. I just replace the standard buttons with the user's buttons.
 

NeoTechni

Well-Known Member
Licensed User
Longtime User
Fascinating, this is a lot less complex/more powerful than I thought. Thank you.
 
Top