B4A Library MSMaterialDialogs

Looking to theme your app to Material Design? Or even ensure Holo?
This library will make your dialogs look either Material or Holo on every Android version.
This is a port of THIS repo

One thing to note these are NOT modal dialogs. Code execution will continue in the background.

It is very easy to use.

Screenshots
29puhr7.jpg

2wn32fk.jpg

28c1vr8.jpg

2sajn2b.jpg


Example
Quick Alert Dialog:
B4X:
Sub btn3_Click
    Dim MB As MSQuickDialogs 
    MB.ShowMaterialDarkMessageBox("Title","QuickDialog2","QD2")
End Sub

Sub QD2_DialogResponse(Response As Int)
    Msgbox("QD2","Old Messagebox!")
End Sub

Showing a listdialog:
B4X:
    Dim itemList As List = Array As String("Organes", "Nabanabas", "Appels", "Drapes", "BawSterries", "Lemlons")
    Dim builder As MSDialogBuilder 
    builder.Initialize("MyDialog")
    builder.setTitle("Material List Dialog").setMessage("This is a List dialog").setThemeColor(Colors.Green)
    builder.setButton(DialogResponse.POSITIVE , "OK")
    builder.setCancelable(True)
    builder.setDesign(builder.DESIGN_MATERIAL_DARK)
    builder.setListStyle(itemList)
    builder.show

Usage
Copy the res files to a location on your HDD, and in your project you need to use #AddtionalRes to point to these files.

Limitations
Currently cannot do custom dialogs. Might work on that later if worthwhile.


Download
Demo APK
Library+Sample+Res
 

Anser

Well-Known Member
Licensed User
Longtime User
The sample is working fine on my phone. When I tried to include MsMaterialDialogs in my existing project that already use AppCompat and MsMaterialDrawer, my app quit abnormaly.

It throws the error message "Unfortunately, 'MyAppName' has stopped"

B4X:
Sub AskHMR_Reading(cHmrReading As String)
    Dim dumy As EditText
    Msgbox(cHmrReading,"HMR Reading")
   
    Dim builder As MSDialogBuilder
    builder.Initialize("MyDialog")
    builder.setTitle("Change HMR Reading").setMessage("Please type the HMR Reading").setThemeColor(Colors.Yellow)
    builder.setButton(DialogResponse.POSITIVE , "OK")
    builder.setCancelable(True)
    ' I tried DESIGN_MATERIAL_LIGHT, DESIGN_HOLO_DARK etc
    builder.setDesign(builder.DESIGN_MATERIAL_DARK)
    builder.setEditTextStyle(cHmrReading, "HMR Reading",Colors.Black,Colors.Gray,dumy.INPUT_TYPE_NUMBERS)
    builder.showKeyboardOnDisplay(True)

    ' Till here it works fine. The next line makes my app quit abnormally
    builder.show   
End Sub

Sub MyDialog_DialogResponse(Buttonclicked As Int) As Boolean
    Log(Buttonclicked)
    Return True
End Sub

'Return path for EditText dialogs
Sub MyDialog_TextAccepted(SelectedText As String)
    Log(SelectedText)
    Msgbox(SelectedText,"SelectedText")
End Sub

The following line
builder.setDesign(builder.DESIGN_MATERIAL_LIGHT) throws the error message "Unfortunately, 'MyAppName' has stopped"
builder.setDesign(builder.DESIGN_MATERIAL_DARK) throws the error message "Unfortunately, 'MyAppName' has stopped"

when I change that line to
builder.setDesign(builder.DESIGN_HOLO_DARK) or if I comment out this line then
I get error at the following line
builder.setEditTextStyle(cHmrReading, "HMR Reading",Colors.Black,Colors.Gray,dumy.INPUT_TYPE_NUMBERS)

The error message is
An error has occured in sub:calldetails_askhmr_reading (java line: 432)
java.lang.ClassCastException:
android.graphics.drawable.InsetDrawable cannot be cast to android.graphics.drawable.StateListDrawable


As I mentioned above, the sample app that was bundled along with the lib is compiling and running perfect on my phone. I assume that the problem may be this lib is not compatible with AppCompat, MsMAterialDrawer ? Just a wild guess.

Any help will be appreciated.

Regards

Anser
 

zani

Member
Licensed User
Longtime User
Looking to theme your app to Material Design? Or even ensure Holo?
This library will make your dialogs look either Material or Holo on every Android version.
This is a port of THIS repo

One thing to note these are NOT modal dialogs. Code execution will continue in the background.

It is very easy to use.

Screenshots
29puhr7.jpg

2wn32fk.jpg

28c1vr8.jpg

2sajn2b.jpg


Example
Quick Alert Dialog:
B4X:
Sub btn3_Click
    Dim MB As MSQuickDialogs
    MB.ShowMaterialDarkMessageBox("Title","QuickDialog2","QD2")
End Sub

Sub QD2_DialogResponse(Response As Int)
    Msgbox("QD2","Old Messagebox!")
End Sub

Showing a listdialog:
B4X:
    Dim itemList As List = Array As String("Organes", "Nabanabas", "Appels", "Drapes", "BawSterries", "Lemlons")
    Dim builder As MSDialogBuilder
    builder.Initialize("MyDialog")
    builder.setTitle("Material List Dialog").setMessage("This is a List dialog").setThemeColor(Colors.Green)
    builder.setButton(DialogResponse.POSITIVE , "OK")
    builder.setCancelable(True)
    builder.setDesign(builder.DESIGN_MATERIAL_DARK)
    builder.setListStyle(itemList)
    builder.show

Usage
Copy the res files to a location on your HDD, and in your project you need to use #AddtionalRes to point to these files.

Limitations
Currently cannot do custom dialogs. Might work on that later if worthwhile.


Download
Demo APK
Library+Sample+Res
e:\b4asource\test\res1\layout\layout_holo_dialog.xml:2: error: No resource identifier found for attribute 'layout_marginStart' in package 'android'
e:\b4asource\test\res1\layout\layout_holo_dialog.xml:2: error: No resource identifier found for attribute 'layout_marginEnd' in package 'android'
hi i have this error
 

chrjak

Active Member
Licensed User
Longtime User
Crashes since upgrading targetsdk to 28

android.view.InflateException: Binary XML file line #2: Binary XML file line #2: Error inflating class com.andexert.library.RippleView
Caused by: android.content.res.Resources$NotFoundException: Resource ID #0x7f040004

rFile:
public static final int TextAppearance_Compat_Notification_Title_Media=0x7f040004;

I can't get behind it - also tried editing the only android:src of the xml res to app:srcCompat
 
Top