Android Question Search for a Switch view

FrankDev

Active Member
Licensed User
Longtime User
Hello,

is there actually such a switch as shown in the picture ?
A switch that can be set to different positions....
e.g. to set a font size.

b4x Views preferred.

Best regards
Frank
 

Attachments

  • Screenshot_control.jpg
    Screenshot_control.jpg
    24.3 KB · Views: 96

Mahares

Expert
Licensed User
Longtime User
A switch that can be set to different positions....
Here is one that looks like what you show in your screeenshot
 
Upvote 0

Lucas Siqueira

Active Member
Licensed User
Longtime User
Hello,

is there actually such a switch as shown in the picture ?
A switch that can be set to different positions....
e.g. to set a font size.

b4x Views preferred.

Best regards
Frank

You can create using panels
See the example I made for you




Screenrecorder-2022-01-26-09-27-25-233.gif
 

Attachments

  • FrankDevGenericName.zip
    18.8 KB · Views: 86
Upvote 0

FrankDev

Active Member
Licensed User
Longtime User
hello Mahares

thanks for the tip. but i saw that the github project is already older.
I already had some problems with views that didn't run under the latest b4a development environment.

that's why it's better to use controls that you can influence yourself.

Best regards
 
Upvote 0

Mahares

Expert
Licensed User
Longtime User
Not to take away from what you have done which is good, but your code should be like this:
B4X:
Private Sub pn_sizeAll_Click  'same event name for all 3 panels
    Dim p As B4XView = Sender
    lb_text.Font = xui.CreateDefaultFont(p.Tag)   'tags respectively: 14, 18,22
    setAllGray
    setBlue(p)
End Sub

You do not need any of this below code:
B4X:
Private Sub pn_size1_Click
    lb_text.Font = xui.CreateDefaultFont(14)
    setAllGray
    setBlue(pn_size1)
End Sub

Private Sub pn_size2_Click
    lb_text.Font = xui.CreateDefaultFont(18)
    setAllGray
    setBlue(pn_size2)
End Sub

Private Sub pn_size3_Click
    lb_text.Font = xui.CreateDefaultFont(22)
    setAllGray
    setBlue(pn_size3)
End Sub
 
Upvote 0

Lucas Siqueira

Active Member
Licensed User
Longtime User
Not to take away from what you have done which is good, but your code should be like this:
B4X:
Private Sub pn_sizeAll_Click  'same event name for all 3 panels
    Dim p As B4XView = Sender
    lb_text.Font = xui.CreateDefaultFont(p.Tag)   'tags respectively: 14, 18,22
    setAllGray
    setBlue(p)
End Sub

You do not need any of this below code:
B4X:
Private Sub pn_size1_Click
    lb_text.Font = xui.CreateDefaultFont(14)
    setAllGray
    setBlue(pn_size1)
End Sub

Private Sub pn_size2_Click
    lb_text.Font = xui.CreateDefaultFont(18)
    setAllGray
    setBlue(pn_size2)
End Sub

Private Sub pn_size3_Click
    lb_text.Font = xui.CreateDefaultFont(22)
    setAllGray
    setBlue(pn_size3)
End Sub


Fantastic, I thought of doing it this way, but at first, it can be confusing for some users...

you need to put the font size in the TAG property of each panel, so you can get it when you click on the panel...

you will also need to change the name of the event in the designer so that all panels call the pn_sizeAll event...
 
Upvote 0
Top