B4J Library [B4X] [XUI] SD_xComboBox

At the request of my friend @Mashiane , I created a combobox that has the graphics of my IconTextView that is Multiplatform (B4X, B4J, B4i)

NOTE: You can use this library for personal and commercial use. Include it in your projects.. Attention, even if it is a B4XLib library, it is not allowed to decompress it, modify it, change its name or redistribute it without the permission of the author


SD_xComboBox

Author:
Star-Dust
Version: 0.16
  • SD_xComboBox
    • Events:
      • ItemClick (Position As Int, Value As Object)
      • OpenList
    • Fields:
      • ItemHeight As Int
      • mBase As B4XView
      • OpenDropDownOnFocus As Boolean
      • Tag As Object
    • Functions:
      • Add (Text As String, ReturnValue As Object)
        Add Item
      • AddAll (L As List)
        Add List of Item, Return Value is a Text
      • Clear
      • CloseDropDown
      • DesignerCreateView (Base As Object, Lbl As Label, Props As Map)
        Base type must be Object
      • GetBase As B4XView
      • GetItem (Position As Int) As String
      • GetValue (Position As Int) As Object
      • Initialize (Callback As Object, EventName As String)
      • isDropDownOpen As Boolean
      • OpenDropDown
      • SetSelection(Start As Int, Length As Int)
      • Size As Int
    • Properties:
      • Enabled As Boolean
      • Hint As String
      • HintFont As B4XFont
      • SelectedIndex As Int
      • SelectedTextItem As String
      • SelectOnlyFromList As Boolean
      • SelectedValueItem As Object
      • SelectionLenght As Int [read only]
      • SelectionStart As Int [read only]
      • TextFont As B4XFont

1.gif
2.gif
 

Attachments

  • SD_xComboBox.b4xlib
    4.9 KB · Views: 205
Last edited:

Star-Dust

Expert
Licensed User
Longtime User
Update 0.02
  1. Fix bugs
  2. Added method: OpenDropDown and CloseDropDown
 

Mashiane

Expert
Licensed User
Longtime User
Hi

Can you please add a SelectedItem property - with that one can get the selected item outside the item click event. I am assuming this can use the .SelectedIndex property is such has a get and a set.

eg.

B4X:
Dim y As String = SD_xComboBox1.SelectedItem

and perhaps

B4X:
SD_xComboBox1.SelectedItem = "ABC"

Only if possible.
 

Star-Dust

Expert
Licensed User
Longtime User
Hi

Can you please add a SelectedItem property - with that one can get the selected item outside the item click event. I am assuming this can use the .SelectedIndex property is such has a get and a set.

eg.

B4X:
Dim y As String = SD_xComboBox1.SelectedItem

and perhaps

B4X:
SD_xComboBox1.SelectedItem = "ABC"

Only if possible.
Use ByValue.

B4X:
SD_xComboBox1.ByValue = "ABC"
 

Star-Dust

Expert
Licensed User
Longtime User
B4X:
Dim y As String = SD_xComboBox1.GetItem(SD_xComboBox1.SelectedItem)
 

Star-Dust

Expert
Licensed User
Longtime User
I will update the names of the methods that are misspelled by mistake
 

Star-Dust

Expert
Licensed User
Longtime User
Update 0.03
  1. Added: SelectedTextItem and SelectedValueItem (Read and Write mode)
  2. Eliminated ByValue method
 
Last edited:

Star-Dust

Expert
Licensed User
Longtime User
Update 0.04
  • Added the possibility to edit the text. Select the field from design
  • Fix bugs
 

Star-Dust

Expert
Licensed User
Longtime User
Update 0.06
  • Added OpenList event. It is raised when you click on the ComboBox and the list opens

Example to close the keyboard when the ComboBox is opened
B4X:
Private Sub SD_OpenList
    Log("Oper DropDown")
    #if B4A
        Dim Ph As Phone
        ' B4XPage
        Ph.HideKeyboard(B4XPages.GetManager.GetTopPage.Parent.NativeType)
        ' Normal
        Ph.HideKeyboard(Activity)
    #else if b4i
        ' B4XPage
        Root.As(NativeObject).RunMethod("endEditing:", Array(True))
        ' Normal
        Page1.RootPanel.As(NativeObject).RunMethod("endEditing:", Array(True))
    #End If
End Sub
 
Last edited:

Star-Dust

Expert
Licensed User
Longtime User
Update 0.07
  • Fix Bugs
 

Star-Dust

Expert
Licensed User
Longtime User
Update 0.08
  • Add field OpenDropDownOnFocus
    Allows you to determine whether to open the list when the field is in focus
  • Add propertie Enabled
 
Last edited:

Lello1964

Well-Known Member
Licensed User
Longtime User
I have this not-blocking error:

B4X:
Unexpected event (missing RaiseSynchronousEvents): mylabel_textchanged
Check the unfiltered logs for the full stack trace.
java.lang.Exception: Stack trace
    at java.lang.Thread.dumpStack(Thread.java:1368)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:314)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:255)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:144)
    at anywheresoftware.b4a.objects.EditTextWrapper$1.afterTextChanged(EditTextWrapper.java:83)
   at android.widget.TextView.sendAfterTextChanged(TextView.java:10068)
    at android.widget.TextView.setText(TextView.java:5927)
    at android.widget.TextView.setText(TextView.java:5759)
    at android.widget.EditText.setText(EditText.java:122)
    at android.widget.TextView.setText(TextView.java:5716)
    at anywheresoftware.b4a.objects.TextViewWrapper.setText(TextViewWrapper.java:39)
    at anywheresoftware.b4a.objects.B4XViewWrapper.setText(B4XViewWrapper.java:227)
    at com.PagAmico.Lite.sd_xcombobox._clear(sd_xcombobox.java:160)
    at com.PagAmico.Lite.emiscont._readreparti(emiscont.java:943)
    at com.PagAmico.Lite.emiscont._activity_resume(emiscont.java:1032)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:732)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:348)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:255)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:144)
    at anywheresoftware.b4a.BA.raiseEvent(BA.java:193)
    at com.PagAmico.Lite.emiscont.afterFirstLayout(emiscont.java:111)
    at com.PagAmico.Lite.emiscont.access$000(emiscont.java:17)
    at com.PagAmico.Lite.emiscont$WaitForLayout.run(emiscont.java:83)
    at android.os.Handler.handleCallback(Handler.java:907)
    at android.os.Handler.dispatchMessage(Handler.java:105)
    at android.os.Looper.loop(Looper.java:216)
    at android.app.ActivityThread.main(ActivityThread.java:7625)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:524)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:987)
 

Star-Dust

Expert
Licensed User
Longtime User
Update 0.10
  • Opening the DropDown will take into account whether the keyboard is open
 

Star-Dust

Expert
Licensed User
Longtime User
Update 0.11
  • Added Classic style
1651404289124.png


1651404331488.png
 

Star-Dust

Expert
Licensed User
Longtime User
Update 0.12
  • Fix b4j bug
 
Top