B4A Library MultiSelect

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

  • MultiSelect v1.02.zip
    17.7 KB · Views: 350
  • Screenshot_2019-09-09-14-32-04.png
    Screenshot_2019-09-09-14-32-04.png
    229.5 KB · Views: 584
  • Screenshot_2019-09-09-14-32-11.png
    Screenshot_2019-09-09-14-32-11.png
    253.1 KB · Views: 591
  • Screenshot_2019-09-09-14-32-22.png
    Screenshot_2019-09-09-14-32-22.png
    246.4 KB · Views: 526

T201016

Active Member
Licensed User
Longtime 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:

Steini1980

Active Member
Licensed User
Longtime User
Hello!
The library MultiSelect v.1.02 ...
After adding Reference to your Library I get this error while compiling:

Kompiliere generierten Java Code. Error
Nicht gefunden: C:\Program Files (x86)\Anywhere Software\Basic4android\libraries\selectiontext.jar
 

DonManfred

Expert
Licensed User
Longtime User
Kompiliere generierten Java Code. Error
Nicht gefunden: C:\Program Files (x86)\Anywhere Software\Basic4android\libraries\selectiontext.jar
These imports are defined in dependson so they must be present. Download them and put them into the additional libs folder. Only if they are not internal libraries ;-)

B4X:
<dependsOn>stringutils</dependsOn>
  <dependsOn>reflection</dependsOn>
  <dependsOn>selectiontext</dependsOn>
  <dependsOn>richstring</dependsOn>
 
Top