B4A Library MaterialDialogsV7

DonManfred

Expert
Licensed User
This is a wrap for the android.support.v7.app.AlertDialog.Builder

Requirements:
- B4A 6+
- Your app needs to be AppCompat ready.

MaterialDialogsV7
Author:
DonManfred (wrapper)
Version: 1
  • AlertDialogBuilder
    Events:
    • onCancel ( As )
    • onClick (button As Int, index As Int)
    • onDismiss ( As )
    • onItemClick (index As Int, selected As Boolean)
    • onKey (key As Int, keyevent As Int)
    Methods:
    • GetApplicationDrawableID (DrawableName As String) As Int
      Get a Drawable from the Application Resources.
      Returns Null if the Drawable is not found.
    • Initialize (EventName As String)
    • IsInitialized As Boolean
    • SetOnCancelListener As AlertDialogBuilder
    • SetOnDismissListener As AlertDialogBuilder
    • SetOnItemSelectedListener As AlertDialogBuilder
    • SetOnKeyListener As AlertDialogBuilder
    • create As AlertDialogBuilder
    • setAdapter (adapter As ListAdapter) As AlertDialogBuilder
    • setCancelable (cancelable As Boolean) As AlertDialogBuilder
    • setCursor (cursor As Cursor, labelColumn As String) As AlertDialogBuilder
    • setIcon (icon As String) As AlertDialogBuilder
    • setIcon2 (icon As Drawable) As AlertDialogBuilder
    • setItems (items() As String) As AlertDialogBuilder
    • setMessage (message As CharSequence) As AlertDialogBuilder
    • setMultiChoiceItems (items() As String, checkedItems() As Boolean) As AlertDialogBuilder
    • setMultiChoiceItemsCursor (cursor As Cursor, isCheckedColumn As String, labelColumn As String) As AlertDialogBuilder
    • setNegativeButton (text As CharSequence) As AlertDialogBuilder
    • setNeutralButton (text As CharSequence) As AlertDialogBuilder
    • setPositiveButton (text As CharSequence) As AlertDialogBuilder
    • setSingleChoiceItems (cursor As Cursor, checkedItem As Int, labelColumn As String) As AlertDialogBuilder
    • setSingleChoiceItems2 (items() As CharSequence, checkedItem As Int) As AlertDialogBuilder
    • setTitle (title As CharSequence) As AlertDialogBuilder
    • setView (view As View) As AlertDialogBuilder
    • setView2 (view As View, viewSpacingLeft As Int, viewSpacingTop As Int, viewSpacingRight As Int, viewSpacingBottom As Int) As AlertDialogBuilder
    • show As AlertDialogBuilder

B4X:
Sub Globals
    'These global variables will be redeclared each time the activity is created.
    'These variables can only be accessed from this module.
    Dim dialog As AlertDialogBuilder
    Private Button1 As Button
End Sub

Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Sub Activity_Create(FirstTime As Boolean)
    'Do not forget to load the layout file created with the visual designer. For example:
    Activity.LoadLayout("Layout1")
    dialog.Initialize("AlertDialog")
End Sub
Sub Button1_Click
    dialog.setCancelable(True).setNegativeButton("No").setPositiveButton("Yo").setTitle("DonManfred presents").setMultiChoiceItems(Array As String("1","2","3","4","5"),Array As Boolean(True,False,False,True,False,False)).show
End Sub
Sub AlertDialog_onCancel()  
    Log($"onCancel()"$)
End Sub
Sub AlertDialog_onClick(button As Int, index As Int)  
    Log($"onClick(${button},${index})"$)
End Sub
Sub AlertDialog_onDismiss()  
    Log($"onDismiss()"$)
End Sub
Sub AlertDialog_onItemClick(index As Int,selected As Boolean)  
    Log($"onItemClick(${index},${selected})"$)
End Sub
Sub AlertDialog_onKey(key As Int, keyevent As Int)  
End Sub
 

Attachments

Last edited:
Top