B4A Library Dialogs library

Status
Not open for further replies.
This library contains several modal, that is blocking, dialogs by which the user can enter data. Presently they are an InputDialog for numbers and text, a TimeDialog for times and and a DateDialog for dates.

Note that modal dialogs can close unexpectedly and not return to your code if the Activity needs to close, most likely because the user rotated the device. There is a brief discussion of this in the overall library help in the xml. This can also occur with the Basic4android modal dialogs InputList, InputMultiList, Msgbox and Msgbox2 whose modal mechanism is used by the dialogs in this library.

Edit : - Version 1.1 posted with minor bug fix. See post #6 for details.

Edit : - Version 1.2 posted with Color dialogs. See post #16 for details.

Edit : - Version 1.3 posted with bug fix. See post #19 for details.

Edit : - Version 1.4 posted with a Number dialog. See post #20 for details.

Edit : - Version 1.5 posted with some enhancements. See post #28 for details.

Edit : - Version 1.6 posted with a File Dialog. See post #30 for details.

Edit : - Version 1.7 posted with a minor UI change. See post #33 for details.

Edit : - Version 1.8 posted with a Custom dialog. See post #37 for details.

Edit : - Version 1.9 posted with a bug fix. See post #42 for details.

Edit : - Version 2.0 posted with a bug fix. See post #48 for details.

Edit : - Version 2.1 posted with a second Custom dialog. See post #68 for details.

Edit : - Version 2.2 posted. See post #75 for details.

Edit : - Version 2.3 posted. See post #90 for details.

Edit : - Version 2.4 posted. See post #135 for details.

Edit : - Version 2.5 posted. See post #148 for details.

Edit : - Version 2.6 posted. See post #155 for details.

Edit : - Version 2.7 posted. See post #168 for details.

Edit : - Version 2.8 posted. See post #206 for details.

Edit :- Version 2.91 posted by Mildev. See post #317 for details. His version 2.91 is based on my unpublished v2.9 which set the text box in FileDialog to SingleLine mode.

Edit : - Version 2.92 posted. See post #341 for details.

Edit (Erel): Version 3.00 posted. Developers using B4A v6.80+ should use this version.

V4.01 is released with several improvements: https://www.b4x.com/android/forum/t...-dialogs-and-async-methods.80204/#post-507930

B4A version | Dialogs library version
------------------------------------
7.0+ 4+
6.8 3.00
<6.8 2.92
 

Attachments

  • Dialogs2.92.zip
    59.4 KB · Views: 13,033
  • Dialogs3.00.zip
    48.9 KB · Views: 2,974
  • Dialogs4.01.zip
    72.2 KB · Views: 9,647
Last edited by a moderator:

fziebell

Member
Licensed User
Longtime User
Very good and interesting question.

I bought b4a few years ago. And think , this is my support expired.

Before I buy a new license , I wanted to test certain functions , whether b4a for me makes sense .

I have already pointed out that I use the trial version and am a little surprised that Erel has no such restrictions .

But OK. Then I have to I make up my mind if I try to purchase a full version .

Thank you.
 

fziebell

Member
Licensed User
Longtime User
Ok. I have a new license . Everything is going well , the dialog lib also.

It would have saved me two days if the test would have pointed to the limitation version .

Thanks to the forum

...continue testing b4a.

Special Thanks to corwin42
 
Last edited:

demasi

Active Member
Licensed User
Longtime User
I want to create a class for my dialogs, but I don't know how to get the result of my dialog, from the class to the activity like in this code, from the dialogs lib demo. As you can see, the result is in the same sub, like a return from a function:

B4X:
Sub btnInput_Click
    Dim Id As InputDialog
    Id.Input = ""
    Id.Hint = "Enter some text!"
    Id.HintColor = Colors.ARGB(196, 255, 140, 0)
    ret = DialogResponse.CANCEL
    ret = Id.Show("Input the required text", "B4A Input Dialog", "Yes", "No", "Maybe", Bmp)
    ToastMessageShow(ret & " : " & Id.Input, False)  
End Sub

I don't know how to code this in a class.Can someone give-me a clue?

I can get a result like this using this code, not recommended as it stops the thread at the while loop. But it does what I need. Wrong way.

B4X:
public Sub show
    pnl.Initialize("pnl")
    pnl.Color=Colors.White
    ed.Initialize("")
    ed.TextColor=Colors.Black
    Dim b1 As Button
    b1.Initialize("b1")
    pnl.AddView(ed,10dip,10dip,200dip,60dip)
    pnl.AddView(b1,10dip,100dip,100dip,50dip)
    mActivity.AddView(pnl,5%x,25%x,90%x,50%x)
    btt=0 'this is defined at class globals
    Do While btt=0
        DoEvents
    Loop
    Return ed.Text
End Sub

Sub b1_click
    Dim w As Button
    w=Sender
    ret = ed.Text
    pnl.RemoveView
    btt=1
End Sub

If I try to code the correct way, without blocking the thread, it would like this:

B4X:
public Sub show
    pnl.Initialize("pnl")
    pnl.Color=Colors.White
    ed.Initialize("")
    ed.TextColor=Colors.Black
    Dim b1 As Button
    b1.Initialize("b1")
    pnl.AddView(ed,10dip,10dip,200dip,60dip)
    pnl.AddView(b1,10dip,100dip,100dip,50dip)
    mActivity.AddView(pnl,5%x,25%x,90%x,50%x)
    btt=0 'this is defined at class globals
End Sub

Sub b1_click
   ret = ed.Text
   pnl.RemoveView
   CallSub(Main,"Message")
End Sub

"Message" is a sub at the Main activity:

B4X:
...
Dim class as MyClass
...
class.initialize()
...

Sub Message()
    Log(class.ret)
End Sub

This way it works, but the program flow is more complicated, because the return is in another sub.
I want to use like in the Dialogs lib, or my example above, with the loop, where the return of the class is is the same sub, top down.
How can I make this?

Thank you for any help.
 

wineos

Member
Licensed User
Longtime User
Hi,

I tried the attached Dialogs Demo, DateDialog and TimeDialog, and get the 2 screens (see the attachments): demo - date, demo - time

demo - date.png demo - time.png

Then, I copied the code and modify it, but my app get different screens (see the attachments): app - date, app - time

app - date.png app - time.png

Why I cannot get the screen like the demo ones? Can anybody help?

Thanks a lot!
 

demasi

Active Member
Licensed User
Longtime User
Look at the manifest.
Go to Project / Manifest Editor
Look for a line like this:

B4X:
SetApplicationAttribute(android:theme, "@android:style/Theme.Holo.Light")

You can change the theme. Maybe this is the case.
Try to erase ".Light" and you'll have a dark theme.

Or you can comment or erase this theme line, and you'll get the default theme for the mobile.

The dialogs demo does not use this theme line.
 

wineos

Member
Licensed User
Longtime User
Thank you demasi. But whatever I modify or erase this theme line, the screens are still different.

I really want to get the datedialog and timedialog looks as the demo one.

Please help. Thanks a lot!

:(
 

warwound

Expert
Licensed User
Longtime User
Thank you demasi. But whatever I modify or erase this theme line, the screens are still different.

I really want to get the datedialog and timedialog looks as the demo one.

Please help. Thanks a lot!

:(

Compare the demo manifest with your project's manifest.
Are there different android sdk levels in each manifest?
 

demasi

Active Member
Licensed User
Longtime User
I see.
I think the problem is the Android version in your cell or emulator.
Android 5 shows like your first two screens.
Android 4 or less shows the other way.
 

wineos

Member
Licensed User
Longtime User
Thank you warwound and demasi. I compare both Demo's and myapp's Android Manifest file, and find the code of @android:style, so I manually remove it.

Then, just as demasi said, I found that I can only have Demo's style on API level 21 and higher: http://stackoverflow.com/questions/3712710/android-calendar-view-for-date-picker

A bit disappointed, but now I can get the Demo's style on my Nexus 7 with Android 5.1.1.

Thank you both of you. :)
 

imgsimonebiliato

Well-Known Member
Licensed User
Longtime User
Hello,
I want to create a class that show a custom panel.
But I want to show this panels, like your dialogs. So I want to call the method Show without any params like yours...
Please, can you help me, with some example code?
 

rleiman

Well-Known Member
Licensed User
Longtime User
This library contains several modal, that is blocking, dialogs by which the user can enter data. Presently they are an InputDialog for numbers and text, a TimeDialog for times and and a DateDialog for dates.

Hi,

Your library is very nice. Can you alter your library to display the KitKat time picker instead of the outdated wheel type time picker when a user chooses TimeDialog ?

I found out that users who have Lollipop installed get the KitKat time picker displayed when TimeDialog is called. If the phone has KitKat installed and the TimeDialog is called, the outdated one is displayed.

I used the sample app that came with the Dialogs library to see which time picker would be displayed.

I also used this in the manifest:

B4X:
'This code will be applied to the manifest file during compilation.
'You do not need to modify it in most cases.
'See this link for for more information: http://www.b4x.com/forum/showthread.php?p=78136
AddManifestText(
<uses-sdk android:minSdkVersion="10" android:targetSdkVersion="14"/>
<supports-screens android:largeScreens="true"
    android:normalScreens="true"
    android:smallScreens="true"
    android:anyDensity="true"/>)
SetApplicationAttribute(android:icon, "@drawable/icon")
SetApplicationAttribute(android:label, "$LABEL$")
'End of default text.

I also compiled the app with API 23 but still the outdated pre-KitKat time picker is displayed.

The attached photos show the outdated and KitKat time pickers.

Thanks.
Google Calendar time picker.png
 

Attachments

  • outdated time picker.png
    outdated time picker.png
    94.1 KB · Views: 243
Last edited:

DonManfred

Expert
Licensed User
Longtime User
Can you alter your library to display the KitKat time picker instead of the outdated wheel type time picker when a user chooses TimeDialog ?
First agraham is no more a active user so i guess there will be no update.
Second i´m sure the lib just call the same methods as in 2011 there do not exist such a picker in android.
The RESULT is based on the Android Version you are using (Device). Update to Lollipop and it will show up the nice picker instead of the old one.
 

rleiman

Well-Known Member
Licensed User
Longtime User
Hi Don,

Is there a way to do the same thing that Google does with the Google calendar in B4A? They use a KitKat time picker but I don't know how to do it with B4A. If Google does it, I'm sure it can be done with B4A (at least I hope since many people are still using KitKat like myself :confused:)

My current device can't be upgraded since that functionality is locked by the device manufacturer. In the worst case, I will use it and know that anyone who has Lollipop will see the nicer time picker. Well, that's what I will assume since I can't see the change on my device.
 
Last edited:
Status
Not open for further replies.
Top