Private Sub CreateLayouts (PrefItem As B4XPrefItem) As B4XView
Dim p As B4XView = xui.CreatePanel("")
p.Width = CustomListView1.sv.ScrollViewContentWidth
p.Height = 50dip
Select PrefItem.ItemType
Case TYPE_BOOLEAN
p.LoadLayout("booleanitem")
Dialog.InternalSetTextOrCSBuilderToLabel(p.GetView(0), PrefItem.Title)
p.GetView(0).TextColor = TextColor
Case TYPE_MULTILINETEXT
p.Height = PrefItem.Extra.Get("height")
p.LoadLayout("textitemmulti")
Dim ft As B4XFloatTextField = p.GetView(0).Tag
ft.HintText = PrefItem.Title
ft.Update
ft.TextField.Tag = Array As Int(miTextFieldID, PrefItem.ItemType) '<<<<<
Case TYPE_TIME
CreateTimeItem(PrefItem, p)
Case TYPE_NUMERICRANGE
CreateNumericRangeItem(PrefItem, p)
Case TYPE_TEXT, TYPE_PASSWORD, TYPE_NUMBER, TYPE_DECIMALNUMBER
p.Height = 60dip
If PrefItem.ItemType = TYPE_PASSWORD Then
p.LoadLayout("passworditem")
Else
p.LoadLayout("textitem")
Dim ft As B4XFloatTextField = p.GetView(0).Tag
If PrefItem.ItemType = TYPE_NUMBER Then
#if B4A
Dim et As EditText = ft.TextField
et.InputType = et.INPUT_TYPE_NUMBERS
#else if B4I
Dim ttf As TextField = ft.TextField
ttf.KeyboardType = ttf.TYPE_NUMBER_PAD
#End If
Else If PrefItem.ItemType = TYPE_DECIMALNUMBER Then
#if B4A
Dim et As EditText = ft.TextField
et.InputType = et.INPUT_TYPE_DECIMAL_NUMBERS
#else if B4I
Dim ttf As TextField = ft.TextField
ttf.KeyboardType = ttf.TYPE_NUMBERS_AND_PUNCTUATIONS
#End If
End If
End If
Dim ft As B4XFloatTextField = p.GetView(0).Tag
ft.HintText = PrefItem.Title
ft.Update
ft.TextField.Tag = Array As Int(miTextFieldID, PrefItem.ItemType) '<<<<<
Case TYPE_DATE
TwoLabelsLayout("lblDate", p, PrefItem)
Case TYPE_OPTIONS
TwoLabelsLayout("lblOptions", p, PrefItem)
Case TYPE_SHORTOPTIONS
p.LoadLayout("shortoptions")
p.GetView(0).TextColor = TextColor
Dim original As List = PrefItem.Extra.Get("options")
#if B4i
Dim no As NativeObject = B4XComboBox1.mBtn
B4XComboBox1.mBtn.Font = xui.CreateDefaultBoldFont(16)
no.RunMethod("setTitleColor:forState:", Array(no.ColorToUIColor(TextColor), 0))
no.SetField("contentHorizontalAlignment", 2) 'right
#end if
#if B4A
Dim spnr As Spinner = B4XComboBox1.cmbBox
spnr.TextColor = TextColor
spnr.DropdownBackgroundColor = Dialog.BackgroundColor
SetBackgroundTintList(spnr, xui.Color_Gray, TextColor)
Dim options As List
options.Initialize
Dim cs As CSBuilder
For Each opt As String In original
options.Add(cs.Initialize.Alignment("ALIGN_OPPOSITE").Typeface(Typeface.DEFAULT_BOLD).Append(opt).PopAll)
Next
B4XComboBox1.SetItems(options)
#else
B4XComboBox1.SetItems(original)
#End If
Dialog.InternalSetTextOrCSBuilderToLabel(p.GetView(0), PrefItem.Title)
Case TYPE_COLOR
TwoLabelsLayout("lblColors", p, PrefItem)
Case TYPE_EXPLANATION
TwoLabelsLayout("lblExplanation", p, PrefItem)
Case TYPE_SEPARATOR
Dim lbl As Label
lbl.Initialize("")
Dim xlbl As B4XView = lbl
xlbl.SetTextAlignment("CENTER", "CENTER")
xlbl.TextColor = SeparatorTextColor
xlbl.Font = xui.CreateDefaultBoldFont(14)
xlbl.Color = SeparatorBackgroundColor
p.Height = 30dip
p.AddView(xlbl, 0, 0, p.Width, p.Height)
Dialog.InternalSetTextOrCSBuilderToLabel(xlbl, PrefItem.Title)
PrefItem.Required = False
End Select
If PrefItem.Required Then
Dim rlbl As Label
rlbl.Initialize("")
Dim xlbl As B4XView = rlbl
xlbl.Text = "*"
xlbl.TextColor = xui.Color_Red
xlbl.TextSize = 11
xlbl.SetTextAlignment("TOP", "LEFT")
p.AddView(xlbl, 01dip, 0dip, 10dip, 10dip)
End If
p.Color = ItemsBackgroundColor
If mTheme <> THEME_DARK Then
If p.GetView(0).Tag Is B4XFloatTextField Then
Dim tf As B4XFloatTextField = p.GetView(0).Tag
tf.TextField.TextColor = TextColor
tf.NonFocusedHintColor = TextColor
tf.Update
If tf.lblClear.IsInitialized Then tf.lblClear.TextColor = TextColor
If tf.lblV.IsInitialized Then tf.lblV.TextColor = TextColor
End If
End If
Return p
End Sub