I think this library is the third attempt in this forum to wrap the excellent afollestad Material Dialogs library.
The difference to the other library wrappers is that this one is (except of some minor features) a complete wrap including file- and folder choosers, color chooser and a complete wrap of the core material dialog including very well support fror custom layouts. Not wrapped are the preference dialogs (We have the Preferences library for this).
I think the library (and the API) now is quite stable. Nevertheless I call it "beta" because I might have overseen anything. Also there are a few bugs in the underlying library which I hope will be fixed soon.
Please report any bugs you find in this thread.
Your Support
Requirements
Please study the very detailed example for the usage of the dialogs. It covers most of the features of this library.
Using the CustomView method:
To display a cutom layout for your dialog use the MaterialDialogBuilder.CustomView(WrapInScrollView, Height). This adds a Panel to the dialog. The width of the dialog is defined in the material design guidelines and cannot be changed. The height can be defined freely. Optionally you can wrap your content in a ScrollView so that it is scrollable but this will add some margin to the content.
To add your content (manually or by loading a layout file) you have to use the CustomViewReady event. This event sub receives a Panel object to which your layout can be added. Here a short example for a CustomView:
Using FileChooser, FolderChooser and ColorChooser dialogs:
These dialogs work a bit different than normal dialogs because the events must be handled directly by the activity.
First step is to extend the Activity from de.amberhome.materialdialogs.MaterialDialogsActivity. Then in Activity_Create initialize the MaterialDialogsManager. This Manager raises the events for the Dialogs. Here is a complete example for the ColorChooserDialog:
Version History
V0.1
The difference to the other library wrappers is that this one is (except of some minor features) a complete wrap including file- and folder choosers, color chooser and a complete wrap of the core material dialog including very well support fror custom layouts. Not wrapped are the preference dialogs (We have the Preferences library for this).
I think the library (and the API) now is quite stable. Nevertheless I call it "beta" because I might have overseen anything. Also there are a few bugs in the underlying library which I hope will be fixed soon.
Please report any bugs you find in this thread.
Your Support
Creating libraries and wrappers for existing library projects is a lot of work. This one took an extra amouont of testing and debugging to get all the features running.
The use of this library is totally free and you even don't need to mention in your app that you use it.
But if you use this library in your projects and you think it is useful to you please consider to make a donation:
Thanks very much for your support.
Requirements
- B4A 6.0 or above
- Compatible with API version 13 and up (set minSdkVersion to 13)
- Android Support Repository
- AppCompat library should be used.
- Copy all files from the MaterialDialogsLibx_xx.zip file to your additional libraries folder. There are 6 files. 1 .xml, 1 .jar and 4 .aar files.
Please study the very detailed example for the usage of the dialogs. It covers most of the features of this library.
Using the CustomView method:
To display a cutom layout for your dialog use the MaterialDialogBuilder.CustomView(WrapInScrollView, Height). This adds a Panel to the dialog. The width of the dialog is defined in the material design guidelines and cannot be changed. The height can be defined freely. Optionally you can wrap your content in a ScrollView so that it is scrollable but this will add some margin to the content.
To add your content (manually or by loading a layout file) you have to use the CustomViewReady event. This event sub receives a Panel object to which your layout can be added. Here a short example for a CustomView:
B4X:
Sub SomeSub
[...]
Dim Builder as MaterialDialogBuilder
Builder.Initialize("CustomViewDialog")
Builder.CustomView(False, 300dip)
Builder.PositiveText("Ok").NegativeText("Cancel")
Builder.Show
[....]
End Sub
Sub CustomViewDialog_CustomViewReady (Dialog As MaterialDialog, CustomView As Panel)
'Load your layout here or add it manually to the panel.
CustomView.LoadLayout("customdialoglayout")
End Sub
Using FileChooser, FolderChooser and ColorChooser dialogs:
These dialogs work a bit different than normal dialogs because the events must be handled directly by the activity.
First step is to extend the Activity from de.amberhome.materialdialogs.MaterialDialogsActivity. Then in Activity_Create initialize the MaterialDialogsManager. This Manager raises the events for the Dialogs. Here is a complete example for the ColorChooserDialog:
B4X:
'Only needed for FileChooser, FolderChooser and ColorChooser dialogs
#Extends: de.amberhome.materialdialogs.MaterialDialogsActivity
Sub Globals
Private Manager As MaterialDialogsManager
End Sub
Sub Activity_Create(FirstTime As Boolean)
Dim primaryColor As Int
Activity.LoadLayout("layout1")
Manager.Initialize("DialogManager")
Dim ac As AppCompat
primaryColor = ac.GetThemeAttribute("colorPrimary")
Dim Builder As ColorChooserDialogBuilder
Builder.Initialize
Builder.PreSelect(primaryColor)
Builder.Show
End Sub
Sub DialogManager_ColorSelected (Dialog As ColorChooserDialog, Color As Int)
Log("Color Selected: " & Color)
End Sub
Version History
V0.1
- First public (beta) release.
- Fix: CustomViews with ScrollView should work better.
- Change: MaterialDialogs_CustomViewReady event changed its signature!
- New: Base library updated to 0.9.4.1
Attachments
Last edited: