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

Informatix

Expert
Licensed User
Longtime User
very nice informatix

what i am missing is to load the inputbox with a text allready typed
i want to give the user the possibility to change/edit a text for a control and would like to put the text in the inputdialog inside so if he want to make a small correction he dont need to add all text again

like he typed: Work Nr10 instead of Work Nr1 so if i could start the inputbox with the text from the label the user dont need to enter everything again

is this possible? or its not icluded?

thank you very much for this lib
Set the Default property with your initial text.
 

ilan

Expert
Licensed User
Longtime User
i am working on a very nice app and i am using lots of your libs (ULV, Betterdialogs, AnimationPlus,...) so you better open a new bankaccount in "Suisse" because i do not forget those who helped me ;)
 

Thraka

Member
Licensed User
Longtime User
How do you resize the contents of a custom dialog to fit the size of the dialog? For example, in the dialog designer it says my panel is 480x270, if I put the size of the dialog (using .CustomDialog) as 480 and 270 it cuts things off. I would rather use anchors in the designer and then have it automatically resized to fit the dialog.
 

Informatix

Expert
Licensed User
Longtime User
How do you resize the contents of a custom dialog to fit the size of the dialog? For example, in the dialog designer it says my panel is 480x270, if I put the size of the dialog (using .CustomDialog) as 480 and 270 it cuts things off. I would rather use anchors in the designer and then have it automatically resized to fit the dialog.
Please read this post and this one.
 

Thraka

Member
Licensed User
Longtime User
Argg I lost my post... Anyhow I'll have to rewrite it.

So I already had set the margin to 20dip.

I changed the panel I'm loading to have the horizontal and vertical anchors to BOTH. Then I loaded the panel, and configured the dialog for width/height 100%. It fills the entire screen but the panel itself is stretched past the bounds of the dialog. The top/left of the panel seems to be displaying properly.
 

Informatix

Expert
Licensed User
Longtime User
Argg I lost my post... Anyhow I'll have to rewrite it.

So I already had set the margin to 20dip.

I changed the panel I'm loading to have the horizontal and vertical anchors to BOTH. Then I loaded the panel, and configured the dialog for width/height 100%. It fills the entire screen but the panel itself is stretched past the bounds of the dialog. The top/left of the panel seems to be displaying properly.
I don't know what code is behind the anchors but it does not work in this case. Your only solution for now is to write a script to position and size each view as you wish. For example, if you add this to the script of the corps layout in my demo, then you will have the same result as with anchors:
EditText1.Height = 100%y - 170dip - EditText1.Top
 

brunnlechner

Member
Licensed User
Longtime User
Hallo Informatix,
i am looking for a inputbox with drop spinner of the last entries.
Is this possible withe the BetterDialogs Inputbox.

Thank You
 

MMORETTI964

Member
Licensed User
Longtime User
Hallo @Informatix,
I use with success BetterDialog.
But now I need to create an edittext runtime inside the dialog with loadxmllayout (I have to change the cursor text color and there is the only way I found).

This tecnique works perfect in other forms while called after his parent is painted on the screen (when the control is on a "normal" activity), but (obviously) can't work with BetterDialog.

I've tried callsubdelayed before starting dialog but seems don't work.
Have you some idea?
Thank you in advance.
 
Last edited:

Informatix

Expert
Licensed User
Longtime User
Hallo @Informatix,
I use with success BetterDialog.
But now I need to create an edittext runtime inside the dialog with loadxmllayout (I have to change the cursor text color and there is the only way I found).

This tecnique works perfect in other forms while called after his parent is painted on the screen (when the control is on a "normal" activity), but (obviously) can't work with BetterDialog.

I've tried callsubdelayed before starting dialog but seems don't work.
Have you some idea?
Thank you in advance.
I have no experience with that (and no idea), so if you find a solution, please report it here.
 

MMORETTI964

Member
Licensed User
Longtime User
Hi @Informatix, I create the Panel (hidden) inside my activity, then I remove it before working on BD and now it works perfectly.

I've found other two things:
1. I try the dialog with a professional device (more LARGE than HIGH by default, it's landscape). The dialog position itself in the middle of the screen (as it was portrait).
After a quick try on another smartphone (2,8") we see that the problem was in the offset too high from the top of the screen. There is a way to change it (or to center my dialog based on width/height I passed it?)

SC20141015-152535.png SC20141015-152550.png


2. There is a way to move dialog with finger?

Thank you very much in advance.
 
Last edited:

TheMightySwe

Active Member
Licensed User
Longtime User
Hi,

I'm trying to do what we discussed before, i had no time to do it then. But now i have.

Im trying to do a nice Listview with a ScrollView and radiobuttons as you suggested some time ago in this thread.

But i can't get the radiobuttons to show on the scrollview.


B4X:
    Dim DialogPanel As ScrollView
    DialogPanel.Initialize(Cursor1.RowCount * 60dip)
   
    Dim DataEntry(Cursor1.RowCount) As RadioButton
       
        For i = 0 To Cursor1.RowCount - 1
            Cursor1.Position = i
            DataEntry(i).Initialize("DataEntryRadioButton")
            DialogPanel.Panel.AddView(DataEntry(i),0,60dip*i,400dip,60dip)
            If Cursor1.GetString("id") = Default Then DataEntry(i).Checked = True
            DataEntry(i).Text = Cursor1.GetString("name")
            DataEntry(i).Tag = Cursor1.GetString("id")
            DataEntry(i).TextColor = Colors.Black
        Next
       
    Cursor1.Close

Do i need to do something more before i pass it to the Dialog.CustomDialog?

Also, can you in some way know the size of the panel before you send it to Dialog.CustomDialog?
 

TheMightySwe

Active Member
Licensed User
Longtime User
I found the problem, i had switched the "Margin" and "Width" so the View was only 5dip. Sorry!
 

Informatix

Expert
Licensed User
Longtime User
Hi @Informatix, I create the Panel (hidden) inside my activity, then I remove it before working on BD and now it works perfectly.

I've found other two things:
1. I try the dialog with a professional device (more LARGE than HIGH by default, it's landscape). The dialog position itself in the middle of the screen (as it was portrait).
After a quick try on another smartphone (2,8") we see that the problem was in the offset too high from the top of the screen. There is a way to change it (or to center my dialog based on width/height I passed it?)

View attachment 28329 View attachment 28328


2. There is a way to move dialog with finger?

Thank you very much in advance.
Via my library, you're limited to what you get. You cannot move the dialog or size it differently. But there are possible improvements. After my current projects, I will see if I can improve something. I don't think that I will implement the possibility to move it with the finger (I don't really think that's possible; it's not a simple panel).
 

Informatix

Expert
Licensed User
Longtime User
Hi @Informatix, I create the Panel (hidden) inside my activity, then I remove it before working on BD and now it works perfectly.

I've found other two things:
1. I try the dialog with a professional device (more LARGE than HIGH by default, it's landscape). The dialog position itself in the middle of the screen (as it was portrait).
After a quick try on another smartphone (2,8") we see that the problem was in the offset too high from the top of the screen. There is a way to change it (or to center my dialog based on width/height I passed it?)

View attachment 28329 View attachment 28328


2. There is a way to move dialog with finger?

Thank you very much in advance.
Another used has created a dialog library: XtraViews. Did you try it? It has different features.
 

MMORETTI964

Member
Licensed User
Longtime User
Thank you. A.F.A.Y.K. a timer or a subdelayed called before BD should work inside BetterDialog? Maybe you could implement a sort of "nil" event to give the calling making something on video (like remove unwanted keyboard, ...).
When you want to start deploy if you need some help let me know, I'm waiting for you.
 

MMORETTI964

Member
Licensed User
Longtime User
Another used has created a dialog library: XtraViews. Did you try it? It has different features.

Unfortunately, is not what I need.
The two possibly improvements on BD I could see:
1. Position starting the dialog on my needs.
2. Having a "dialogtimer" event (like the "nil" event for who remembers old Palm-Metrowerks :eek:).

I've seen moving a DialogFragment is impossible, the ontouchlistener needs an Activity, having an Activity acts as a Dialog is another story (I think)...
Thank you for your support.
 

Informatix

Expert
Licensed User
Longtime User
I rewrote some parts of the CustomDialog and moved its parameters to the BD_CustomDlgParams class. Now, you can set the gravity and duration of the dialog, and you no longer need to bother with the margin parameter (another margin parameter, MarginHeight, has been added, but it is for the case where the top of the dialog is hidden, which happens when you set the gravity to TOP). The size that you define via BodyHeight and BodyWidth is now the exact size of the dialog body so you can place and size accurately all views. Thus, if you set the body width to 100%x - 30dip (the maximum width), you can use the same value to set the maximum width in your designer scripts, e.g.:
B4X:
MaxWidth = 100%x - 30dip
CheckBox1.Right = MaxWidth - 10dip '10dip from the right edge
These changes break the existing code for all custom dialogs.
 
Last edited:
Top