B4J Question "ListView.AddTwoLines2" in B4J

pptan

New Member
Licensed User
Longtime User
Hello

Erel, Congratulations, wonderful work

Please, what would the equivalent code in B4J???

B4A:
ListView1.AddTwoLines2 (line1, line2, line3)

Thank you very much.
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
ListView can either show a simple value or a Node.

SS-2013-12-15_09.21.20.png


B4X:
Sub Process_Globals
   Private fx As JFX
   Private MainForm As Form
   Private ListView1 As ListView
End Sub

Sub AppStart (Form1 As Form, Args() As String)
   MainForm = Form1
   MainForm.RootPane.LoadLayout("1") 'Load the layout file.
   MainForm.Show
   For i = 1 To 10
     AddTwoLines2(ListView1, "This it the Title", "This is the second line", i)
   Next
End Sub

Sub AddTwoLines2(lv As ListView, Line1 As String, Line2 As String, Value As Object)
   Dim ap As AnchorPane
   ap.Initialize("")
   Dim lbl1, lbl2 As Label
   lbl1.Initialize("")
   lbl1.Text = Line1
   lbl1.Font = fx.DefaultFont(16)
   lbl2.Initialize("")
   lbl2.Text = Line2
   ap.AddNode(lbl1, 0, 0, lv.Width, 20dip)
   ap.AddNode(lbl2, 0, 25dip, lv.Width, 20dip)
   lv.Items.Add(ap)
   lbl1.Tag = Value
End Sub

Sub ListView1_SelectedIndexChanged(Index As Int)
   If Index > = -1 Then
     Dim ap As AnchorPane = ListView1.SelectedItem
     Dim lbl1 As Label = ap.GetNode(0)
     Dim value As Object = lbl1.Tag
     Log(value)
   End If
End Sub
 
Upvote 0

rapblack

Member
Licensed User
Longtime User
In B4J can be create group of control
see attached picture
I create 3 Label and 1 TextField
label1 = Length of side a
label2 = , a =
TextFeild1 = 1000
label3 = mm
Requirement need to put label1:Label2:TextFeild1:Label3 and get value form TextFeild1
Please guide me for some code
Best Regard
rapblack
 

Attachments

  • built-up control.png
    built-up control.png
    1.4 KB · Views: 312
Upvote 0
Top