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,390
  • Java source - BetterDialogs.zip
    8.5 KB · Views: 766
Last edited:

JakeBullet70

Well-Known Member
Licensed User
Longtime User
First of all, really love this lib.

I have used it before without a problem but on one of my new projects the whole application just terminates.
I turned off the filter in the logs and got this:

---------------------------------------------------------------------------------------
Window 'Window{529d7ca4 u0 sadLogic.weather/sadLogic.weather.setup}' spent 14885.0ms processing the last input event: KeyEvent(action=0, deviceId=1, source=0x00000301)
Window already focused, ignoring focus gain of: com.android.internal.view.IInputMethodClient$Stub$Proxy@52957b74 attribute=null, token = android.os.BinderProxy@5299cdd0
Main:Keycode:49
eglSurfaceAttrib not implemented
out_write() limiting sleep time 44149 to 23219
out_write() limiting sleep time 35759 to 23219
out_write() limiting sleep time 27369 to 23219
DR=-2
no
Window 'Window{529d7ca4 u0 sadLogic.weather/sadLogic.weather.setup}' spent 3159.3ms processing the last input event: KeyEvent(action=0, deviceId=1, source=0x00000301)
Fatal signal 11 (SIGSEGV) at 0x00770065 (code=1), thread 15335 (adLogic.weather)
*** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
Build fingerprint: 'generic/vbox86tp/vbox86tp:4.3/JLS36G/eng.buildbot.20131113.013156:userdebug/test-keys'
Revision: '0'
pid: 15335, tid: 15335, name: adLogic.weather >>> sadLogic.weather <<<
signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 00770065
eax 00770065 ebx b7195e4c ecx b830af74 edx b830af68
esi b81100b8 edi 00000000
xcs 00000073 xds 0000007b xes 0000007b xfs 00000000 xss 0000007b
eip b7188ddf ebp b8110070 esp bfaffe50 flags 00210206
---------------------------------------------------------------------------------------


My code that makes the call is:
B4X:
Private Sub LocationDelete

    '--- delete
    Dim DR As Int
    DR = BD.Msgbox("Question","Delete this location?","Yes", "", "No", Null)
    Log("DR=" & DR)
   
    If DR = -1 Then
        '--- they want to delete
        Log("yes")
    Else
        '--- cancel
        Log("no")
    End If

End Sub

Am I missing something here? I don't quite understand why its terminating the whole program.

Any help would really be appreciated.
 

JakeBullet70

Well-Known Member
Licensed User
Longtime User
I really have no idea of what's going on. Where this function is called from? You cannot call a MsgBox directly from some events. Try to calling it with CallSubDelayed instead.

CallSubDelayed worked!!!

I am calling it from Activity_KeyPress, I changed my call to this: CallSubDelayed(Me,"LocationDelete")
Thank you so much for your help!!!
 

uhzeg

Member
Licensed User
Longtime User
Hi all
Is there any possibility to highlight the (user) selected item of a listview within CustomDialog ?

Or maybe even react on a user click event on the listview?

Thanks in advance...
 
Last edited:

JakeBullet70

Well-Known Member
Licensed User
Longtime User
Hi all

I am trying to get a seekbar to work, I see one in the sample code but I cannot get it to fire the the event.
I have declared it above: Private SeekBar1 As SeekBar
And added the event: SeekBar1_ValueChanged (Value As Int, UserChanged As Boolean)

Is there a trick to this? Or did I miss something?

thanks!
 

Informatix

Expert
Licensed User
Longtime User
Hi all

I am trying to get a seekbar to work, I see one in the sample code but I cannot get it to fire the the event.
I have declared it above: Private SeekBar1 As SeekBar
And added the event: SeekBar1_ValueChanged (Value As Int, UserChanged As Boolean)

Is there a trick to this? Or did I miss something?

thanks!
Indeed, you cannot get the event of the seekbar. In a dialog, it's not very annoying because the goal is to set a value then click on OK but I understand your concern: you can try another library like this one; depending on the method used to get the events, it might work.
 
Top