1. *** New version of B4J is available ***
    B4J v7.8
    Dismiss Notice

B4A Library MultiSelect

Discussion in 'Additional libraries, classes and official updates' started by T201016, Sep 9, 2019 at 2:21 PM.

Tags:
  1. T201016

    T201016 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.


    Code:
    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. [​IMG]
    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)).
     

    Attached Files:

  2. T201016

    T201016 Member Licensed User

    cd.. Missing example:

    Code:
    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 StringAs 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: Sep 14, 2019 at 8:01 AM
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice