Hi there, I need to create a label in sequence with Spinner's text like in the images attached. I tried the link below but it doesn't better for my app...
Thanks for any ideas..
This is a wrap for this github project. TagView Version: 1 TagView Methods: Initialize (tagtext As String) IsInitialized As Boolean isDeletable As Boolean Properties: Background As Drawable Deletable As Boolean [write only] DeleteIcon As String DeleteIndicatorColor As Int...
If you are looking to color the label based on the color chosen in the spinner, you can create a sub like this:
B4X:
Sub ColorLabel(l As Label)
If a.Contains("red") Then
l.color = Colors.Red
else if a.Contains("green") Then
l.color = Colors.Green
else if a.Contains("yellow") Then
l.color = Colors.Yellow
End If
End Sub
And your button1 code will be something like this:
B4X:
Private Sub Button1_Click
If Label1.Text = "" Then
Label1.Visible=True
Label1.Text= a
ColorLabel(Label1)
Else
If Label2.Text = "" Then
Label2.Visible=True
Label2.Text= a
ColorLabel(Label2)
Else
If Label3.Text = "" Then
Label3.Visible=True
Label3.Text= a
ColorLabel(Label3)
Else
If Label4.Text = "" Then
Label4.Visible=True
Label4.Text= a
ColorLabel(Label4)
Else
If Label5.Text = "" Then
Label5.Visible=True
Label5.Text= a
ColorLabel(Label5)
Else
If Label6.Text = "" Then
Label6.Visible=True
Label6.Text= a
ColorLabel(Label6)
'finish rest of labels like above
End sub
Thanks for this, but my question is: I need to create label without labels created in the design... But from the code... if I select an item and I click on the button, the code creates a label with text selected... I don't know if this is possible... I see xui.CreateLabels but I don't know how to use it...
It is possible. Here is the code you need for an array of 8 labels by code. Make sure the layout Layoutlabel when loaded should only have the 3 radio buttons, spinner1 and button1. The labels will be created by code in one column, but you can tweak the app to make 3 columns of labels. Please note that after the 8th label the button1 is disabled so the app stops adding labels.
B4X:
Sub Globals
Private a As String
Private Panel1 As Panel
Private RadioButtonGreen As RadioButton
Private RadioButtonRed As RadioButton
Private RadioButtonyellow As RadioButton
Private Spinner1 As Spinner
Dim GreenArr(2), RedArr(3),YellowArr (4)As String
Private Button1 As Button
Private n As Int =8 'number of labels. You can change this to any number to have more labels
Private lbl(n) As Label
Private i As Int =0
End Sub
B4X:
Private Sub Button1_Click
Dim w =200dip, h=50dip As Float
lbl(i).Initialize("lbl")
Activity.AddView(lbl(i), 0,i*60dip+200dip, w, h)
lbl(i).Text= a
lbl(i).TextSize = 20
ColorLabel(lbl(i))
i=i+1
If i=n Then Button1.Enabled =False
End Sub
I removed the old code and took the code from the AS_Chips to make this view even better. I spend a lot of time in creating views, like this and to create a high quality view cost a lot of time. If you want to support me and further views, then you can do it here by Paypal. :) Without scroll...