B4A Library MultiSelect

T201016

Active Member
Licensed User
Hello!
The library MultiSelect v.1.02 created below for own needs has the ability to select several items from the list in the following example POIs. Interestingly, the "All Select" selection bar always remains visible when scrolling through the list. I am interested in your opinions :)

Of course, at a later time I will also add a way to build a list of elements.


B4X:
Example:
1. Add to Files Manager: dialog_transparent.bal and app_ico.png

Sub Globals
    Dim mss As MultiSelect
    Dim bmp As Bitmap = LoadBitmap(File.DirAssets, "app_ico.png")
    ...
End Sub

'An example of calling the MultiSelect dialog
mss.Initialize
mss.InputDialog(True,Me,Activity,"Available Categories in\n'"&fd.ChosenName&"'","Select All",bmp,"mss")
mss.Show

Sub Activity_KeyPress(KeyCode As Int) As Boolean
    ' Not mandatory, it depends on your app and device
    Private Menu As Reflector

    Select KeyCode
      Case KeyCodes.KEYCODE_BACK
        If mss.IsInitialized Then
            If mss.IsShowDialog Then
                mss.Hide '------------------------- > Close MultiSelect window.
            End If
        End If
        Return True
      Case KeyCodes.KEYCODE_MENU
        Menu.Target = Menu.GetActivity
        ' clear the menu items, the original menu itself still exists
        Menu.SetField2("menuItems", Null)
        ' add the required menu items
        '
       
        ' rebuild the menu
        Menu.RunMethod("invalidateOptionsMenu")
    End Select
    Return False
End Sub

Sub mss_Response(Response As Int)
    ToastMessageShow("Dialogresponse: " & Response, False)
End Sub
This library is Donationware.
You can download the library, you can test the library.
But if you want to USE the library in your App you need to Donate for it.
Please click here to donate (You can donate any amount you want to donate for the library (or my work)).
 

Attachments

T201016

Active Member
Licensed User
cd.. Missing example:

B4X:
Sub Globals
    Dim mss As MultiSelect
    ...

Sub Activity_Create(FirstTime As Boolean)
    If FirstTime Then MSVariable.Initialize
    ...
 
'MSVariable.SelectedStrings - Wybrane elementy z listy
Sub Activity_Resume
    If MSVariable.SelectedStrings.IsInitialized Then
        If MSVariable.SelectedStrings.Size > 0 Then
            MSVariable.Initialize
              '  don't do anything!
        End If
    End If
End Sub
    ...
 
Dim ret As Boolean = True
ret = GetFile(fd.FilePath, fd.ChosenName) 'ChosenName = 'Favorites.txt'

Sub GetFile(FilePath As String, ChosenName As String) As Boolean
    Private FileToStr As List = GetList(FilePath, ChosenName)
    Private Suffix As String

    Try
        MSVariable.Initialize

        If FileToStr.Size > 0 Then
            MSVariable.SelectAllOnFirst = False
            For i = 0 To FileToStr.Size - 1
                Suffix = FileToStr.Get(i)
                If (Suffix.IndexOf("geo:") = -1 And Suffix.IndexOf(": ") = -1 And Suffix.Length > 2)  Then
                    If Suffix.ToUpperCase.CompareTo("MY FAVORITES") <> 0 Then MSVariable.Category.Add(Suffix)
                End If
            Next
            If MSVariable.Category.Size > 1 Then
                mss.Initialize
                mss.InputDialog(True,Me,Activity,"Available Categories in\n'"&fd.ChosenName&"'","Select All",bmp,"mss")
                mss.Show
            End If
        End If
        Return True
    Catch
        ToastMessageShow(LastException.Message, True)
        Return False
    End Try
End Sub
 
Last edited:
Top