Android Question B4XComboBox

Sergey_New

Well-Known Member
Licensed User
Longtime User
The font size of this element cannot be changed after it is created.
A possible solution is to uncomment the lines shown below.
B4X:
Sub Class_Globals
    Private Root As B4XView 'ignore
    Private xui As XUI 'ignore
    Private B4XComboBox1 As B4XComboBox
    Dim lst As List=Array As String("A", "B", "C")
End Sub

Private Sub B4XPage_Created (Root1 As B4XView)
    Root = Root1
    Root.LoadLayout("1")
    B4XComboBox1.SetItems(lst)
    B4XComboBox1.SelectedIndex=1
    B4XComboBox1.cmbBox.TextSize=20
End Sub

Private Sub Button1_Click
'    B4XComboBox1.cmbBox.Clear
'    B4XComboBox1.SetItems(lst)
'    B4XComboBox1.SelectedIndex=1
    B4XComboBox1.cmbBox.TextSize=14
End Sub
Is there really no simple solution?
 

PaulMeuris

Well-Known Member
Licensed User
And what if you do this:
B4X:
    B4XComboBox1.cmbBox.TextSize = 14
    B4XComboBox1.cmbBox.SelectedIndex = 1
The B4XComboBox1 should redraw itself to show the selected index.
This way you don't need to refill the items list.
Note: remember the first item has index = 0
 
Last edited:
Upvote 0

Sergey_New

Well-Known Member
Licensed User
Longtime User
And what if you do this:
Doesn't work. You need to change the index, but you can't return the index to the original value.
I've attached an example, check it out.
 

Attachments

  • Project.zip
    4.7 KB · Views: 30
Upvote 0

PaulMeuris

Well-Known Member
Licensed User
B4X:
Private Sub Button1_Click
'    B4XComboBox1.cmbBox.Clear
'    B4XComboBox1.SetItems(lst)
    B4XComboBox1.cmbBox.TextSize=14
    B4XComboBox1.SelectedIndex=0
    Sleep(0)
    B4XComboBox1.SelectedIndex=1
End Sub
You can temporally change the selectedindex and then reset it to the original value.
The sleep method allows the combobox to redraw itself.
 
Upvote 0

Sergey_New

Well-Known Member
Licensed User
Longtime User
You can temporally change the selectedindex
This is roughly the same method as in post #1. I'm looking for a method to redraw a B4XComboBox, possibly using JavaObject.
 
Upvote 0

valerioup

Member
Licensed User
Longtime User
solutions:
Private Sub Button1_Click
 For Each v As B4XView In Root.GetAllViewsRecursive
       If v Is Button Then 
       Else           
            If v Is Label Then               
                v.TextSize=14
            End If
       End If
    Next
End Sub

try this
 
Upvote 0

Sergey_New

Well-Known Member
Licensed User
Longtime User
Thanks for the tip!
The correct solution is:
B4X:
Private Sub Button1_Click
    For Each v As B4XView In Root.GetAllViewsRecursive
        If v Is Button Then
        
        Else If v.Tag Is B4XComboBox Then
            Dim cmb As B4XComboBox=v.Tag
            cmb.cmbBox.TextSize=14
        Else if v Is Label Then
            v.TextSize=14
        End If
    Next
End Sub
 
Upvote 0
Top