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: 12,994
  • Dialogs3.00.zip
    48.9 KB · Views: 2,947
  • Dialogs4.01.zip
    72.2 KB · Views: 9,560
Last edited by a moderator:

MaxApps

Active Member
Licensed User
Longtime User
How to use this to load a file?

normally I would load the text file with:
tmptxt=File.ReadString (File.DirRootExternal & "/CrN", Filename)

but this locks my to sdcard/CrN. Can I use Dialogs to load from anywhere?

tmptxt=File.ReadString (????????)


Kind regards
Jakob
 

thedesolatesoul

Expert
Licensed User
Longtime User
Andrew,
Is it possible for you to add a workaround for the TimePicker/DatePicker value sticking problem. When you enter a value using the keyboard it does not stick until focus is cleared from it. If you use a timepicker.clearfocus maybe that will do the trick and bypass this annoying feature.
Thanks.
 

thedesolatesoul

Expert
Licensed User
Longtime User
Andrew,
I have already tested this. Even after the user closes the dialog, if you do TimePicker.ClearFocus() it sets off some onChanged events, and returns the changed value.
After all, even though the dialog is not visible any more the reference to the views has not been destroyed yet.
Ofcourse, this is just a suggestion.
 

AscySoft

Active Member
Licensed User
Longtime User
Is it possible to show keyboard and dialog altogether?
I want to display a logon feature on my app, (an InputDialog with password mode set to true) like this
B4X:
Dim inputText As InputDialog
inputText.PasswordMode=True
inputText.Show("Enter password please","Log on","OK","","Exit",Null)


The only "problem" is that user must manually press into dialog field for the keyboard to be display.
Is there any chance to automate this process a little, please?:rolleyes:
 
Last edited:

specci48

Well-Known Member
Licensed User
Longtime User
Hello agraham,

I don't know if its possible but it would be nice if the dialog titles would support RichStrings instead of Strings.
I use custom dialogs to display the results of previous searches. Using own views it is easy to highlight the results with the search expressions, but if the title is part of the result the highlighting won't work at the moment.


specci48
 

alan1968

Active Member
Licensed User
Longtime User
ColorPickerDialog via CustomDialog

hello your library is formidable !

but, in my program I want to launch a ColorPickerDialog via a button in a panel of CustomDialog , but I click the button ColorDialog does not open, if I set the panel to activity, the ColorDialog opening it's ok

it's normal ?
 

boza

New Member
Licensed User
Longtime User
Is there a way to close Custom dialog?

Hi Andrew,
Is there a way to close the Custom dialog from external event?
I mean the following: I created a custom dialog with a List View embedded:

Dim bmp As Bitmap
Dim cd As CustomDialog2
Dim C1 As fgContact
Dim j As Int
ItemSelected = -1

If ( ContactsList.IsInitialized = False) Then

ProgressDialogShow("Please, wait while reading contacts:)")
For j = 1 To 5
DoEvents
Next
Try
ContactsList = Contacts.GetAllContacts( False, False )
ProgressDialogHide
Catch
ProgressDialogHide
End Try
End If



Dim lv As ListView
lv.Initialize("lv_Acc")
Dim i As Int

For i = 0 To ContactsList.Size - 1
C1 = ContactsList.Get( i )

lv.AddSingleLine2 ( C1.DisplayName, C1 )

Next



cd.AddView(lv, 77%x, 60%y)

bmp.Initialize(File.DirAssets, "android48.png")
ret = cd.Show("Contacts list", "OK", "Cancel", "", bmp)
If ( ret <> DialogResponse.CANCEL ) AND ( ItemSelected <> -1) Then
C1 = lv.GetItem( ItemSelected )
edtAccName.Text = C1.DisplayName
ContactID = C1.Id
End If



I add an event procedure:

Sub lv_acc_ItemLongClick (Position As Int, Value As Object)
ItemSelected = Position
ToastMessageShow("Click OK to select item", False )
End Sub


Is there a way in this procedure to close the dialog with a "OK" modal result?

As you see, I display a toast message to the user to Click OK to confirm the selection, but will be better to automate this process and click OK in the event.
 

sioconcept

Active Member
Licensed User
Longtime User
Crash on Android 4.0 ?

Hello :D

I work on Android 4.0 and when i push the button "ok", My activity crash :(

B4X:
   Dim Dd As DateDialog
   Dim ret As Int
   Dd.Year = DateTime.GetYear(DateTime.Now)
   Dd.Month = DateTime.GetMonth(DateTime.Now)   
   Dd.DayOfMonth = DateTime.GetDayOfMonth(DateTime.Now)
   ret = Dd.Show("A quelle date ?", "Choisissez une date", "ok", Null, Null, Null)

Maybe you can help me to resolve this problem ?

B4X:
** Activity (document) Create, isFirst = true **
** Activity (document) Resume **
java.lang.RuntimeException: MotionEvent { action=ACTION_UP, id[0]=0, x[0]=775.6156, y[0]=322.39532, toolType[0]=TOOL_TYPE_FINGER, buttonState=0, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=0, eventTime=235780619, downTime=235780518, deviceId=2, source=0x1002 } recycled twice!
   at android.view.MotionEvent.recycle(MotionEvent.java:1660)
   at android.view.ViewRootImpl.finishMotionEvent(ViewRootImpl.java:2921)
   at android.view.ViewRootImpl.deliverPointerEvent(ViewRootImpl.java:2912)
   at android.view.ViewRootImpl.handleMessage(ViewRootImpl.java:2471)
   at android.view.ViewRootImpl.processInputEvents(ViewRootImpl.java:849)
   at android.view.ViewRootImpl.handleMessage(ViewRootImpl.java:2480)
   at android.os.Handler.dispatchMessage(Handler.java:99)
   at android.os.Looper.loop(Looper.java:137)
   at android.app.ActivityThread.main(ActivityThread.java:4424)
   at java.lang.reflect.Method.invokeNative(Native Method)
   at java.lang.reflect.Method.invoke(Method.java:511)
   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
   at dalvik.system.NativeStart.main(Native Method)
 

Inman

Well-Known Member
Licensed User
Longtime User
Not sure if this will work, but I suggest 2 changes

First, you don't need to pass Null for all the arguments. Only the last one (bitmap) needs Null. For others use "" (empty double quotes).

Second, if you want the dialog to show today's date on startup, simply use Dd.DateTicks = DateTime.Now
 

sioconcept

Active Member
Licensed User
Longtime User
Thank you Inman, but no change :(

The DateDialog open nice; it's only when i push a button else i can see the dialogbox with the good day.
Strange :sign0161:

I don't find another DateDialog so nice.
 
Status
Not open for further replies.
Top