Activity.LoadLayout("Layout1")
' Set Header Text
FlexGrid1.ColsName=Array As String("Num","Selc","Name","Img","Digit")
' Set Clumn Width
FlexGrid1.ColsWidth=Array As Int(75dip,50dip,100dip,40dip,150dip)
' Set Type of Dates
FlexGrid1.ColsType=Array As Int(FlexGrid1.TypeInt,FlexGrid1.TypeCheck,FlexGrid1.TypeString,FlexGrid1.TypeImage,FlexGrid1.TypeFloat)
FlexGrid1.ColsAlignment=Array As String("CENTER","CENTER","LEFT","LEFT","RIGHT")
Dim B As Boolean=False
For i=1 To 25
B=Not(B)
FlexGrid1.AddRow(Array As Object(i,B,"User " & i,Null,Rnd(50,10000)/100))
' AddRow2 can set rowWidht
'FlexGrid1.AddRow2(Array As Object(i,B,"User " & i,LoadBitmap(File.DirAssets,"b4a.png"),Rnd(50,10000)/100),60dip)
Next
FlexGrid1.SetCell(0,0,100)
FlexGrid1.SetCell(1,2,"User 200")
FlexGrid1.SetCell(0,3,LoadBitmap(File.DirAssets,"b4a.png"))
FlexGrid1.SetCell(2,3,LoadBitmap(File.DirAssets,"b4j.png"))
FlexGrid1.SetCell(4,3,LoadBitmap(File.DirAssets,"b4i.png"))
'FlexGrid1.SetRowHeight(1,60dip)
'FlexGrid1.SetColWidth(3,40dip)
FlexGrid1.Invalidate
Wrong. In xCustomListView you create each item as you wish, even with all EditTexts, if you want.But I am sure that the idea of making the cells editable is not contained.
I would also like to see the written code that allowed us to create such a grid.
You don't need to write any code. You create the cell layouts with the designer.Sometimes the custom listview to create such panels you have to write a lot of code that you would do first to create a scrollview and a sub that you can poolate it.
Sub Globals
......
Private clv2 As CustomListView
.....
End Sub
Sub Activity_Create(FirstTime As Boolean)
.......
For i = 1 To 20
clv2.Add(CreateListItem($"Item #${i}"$, clv2.AsView.Width, 60dip), $"Item #${i}"$)
Next
End Sub
Sub CreateListItem(Text As String, Width As Int, Height As Int) As Panel
Dim p As Panel
p.Initialize("")
p.SetLayout(0, 0, Width, Height)
p.LoadLayout("CellItem")
Label1.Text = Text
Return p
End Sub
Sub clv2_ItemClick(Index As Int, Value As Object)
clv2.AsView.BringToFront
Log(Index & " = " & Value)
...
End Sub
Sub Globals
......
Private SV As ScrollView
.....
End Sub
Sub Activity_Create(FirstTime As Boolean)
.......
For i = 1 To 20
SV.Panel.Addview(CreateListItem($"Item #${i}"$,$"Item #${i}"$),0,SV.Panel.Height,SV.Width,60dip)
SV.Panel.Height=SV.Panel.Height+60dip
Next
End Sub
Sub CreateListItem(Text As String, Value As Object) As Panel
Dim p As Panel
p.Initialize("Item")
'p.SetLayout(0, 0, Width, Height)
p.LoadLayout("CellItem")
Label1.Text = Text
p.Tag=Value
Return p
End Sub
Sub Item_Click
Dim P As Panel = Sender
Dim Index As Int = P.Top/60dip
Dim Value As Object = P.Tag
Log(Index & " = " & Value)
End Sub
Private FlexGrid1 as Flexgrid
Sub Activity_Create(FirstTime As Boolean)
FlexGrid1.ColsName=Array As String("Text","Button","Check")
FlexGrid1.ColsWidth=Array As Int(75dip,250dip,100dip)
FlexGrid1.ColsType=Array As Int(FlexGrid1.TypeString,Flecgrid1.TypeButton,FlexGrid1.TypeCheck)
For i=1 To 20
FlexGrid1.AddRow(Array As Object($"Item #${i}"$,"Click Me",True)
Next
End Sub
Sub FlexGrid1_CellClick(Row As Int, Col As Int)
Dim Value As Object = FlexGrid1.GetCell(Row,Col)
Log("Col:" & col & " Row:" & row & " ---" & Value)
End Sub
FlexGrid1.ColsType=Array As Int(FlexGrid1.TypeString,Flecgrid1.TypeButton,FlexGrid1.TypeCheck)
PS. In the future this line will not be necessary
You will not need to specify what type of data will contain each column because the class will recognize the type of each individual cellB4X:FlexGrid1.ColsType=Array As Int(FlexGrid1.TypeString,Flecgrid1.TypeButton,FlexGrid1.TypeCheck)
Yes.Are you able to do this with XCustomListView?
Are you able to do this with XCustomListView?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?