1 - I put a checkbox in the customlistview, related with a boolean field in database.
How I can click in this checkbox and update the boolean field in database?
2 - How I can click in a item of customlistview and show all fields of selected item in a messagebox?
I try to make this, but not works (Logs shows: "No records found. (Map) Not initialized"):
B4X:
Sub clv1_ItemClick (index As Int, Value As Object)
Dim m As Map
m = DBUtils.ExecuteMap(Main.SQL1, "SELECT id, project, author, marked FROM myTable WHERE id = ?", Array As String(Value))
Dim myText As String
myText = m.Get("project") & CRLF & m.Get("author")
Msgbox(myText, "")
End Sub
1. Again, you need to check the example that comes with CustomListView.
This is the relevant code to handle the checkbox. It is not so simple but go over it and you will understand it:
B4X:
Sub chk_CheckedChange(Checked As Boolean)
Dim index As Int
index = clv3.GetItemFromView(Sender)
Dim pnl As Panel
pnl = clv3.GetPanel(index)
Dim chk As CheckBox
chk = pnl.GetView(2)
Msgbox("Item value: " & clv3.GetValue(index) & CRLF & "Check value: " & chk.Checked, "")
End Sub
2. Add Log(Value). Is this the value that you are looking for?
1. Again, you need to check the example that comes with CustomListView.
This is the relevant code to handle the checkbox. It is not so simple but go over it and you will understand it:
B4X:
Sub chk_CheckedChange(Checked As Boolean)
Dim index As Int
index = clv3.GetItemFromView(Sender)
Dim pnl As Panel
pnl = clv3.GetPanel(index)
Dim chk As CheckBox
chk = pnl.GetView(2)
Msgbox("Item value: " & clv3.GetValue(index) & CRLF & "Check value: " & chk.Checked, "")
End Sub
I have seen and used this example, but how I get the record in database and update it, using this information (click on item of customlistview and find the record in database)?
Dim table As List
table = DBUtils.ExecuteMemoryTable(SQL1, "SELECT id, project, author FROM " & myTable,Null,0)
Dim i As Int : i = 0
For Each cols() As String In table
i = i + 1
clv1.Add(CreatePanelItem(i & ". " & cols(0), cols(1), cols(2), 100%x, 100%y), 100dip, cols)
Next