Android Question B4XTable - all rows and no header

Status
Not open for further replies.

RB Smissaert

Well-Known Member
Licensed User
Longtime User
How to delete a row?

I think you can delete a row quite easily, but unless I am mistaken you have to add some code to the B4XTable class (so use the class instead of the library).
This is what I added to the class:

B4X:
Sub Class_Globals
Private lRowID As Long 'this is the SQLite rowid of the underlying table and view

B4X:
Private Sub CellClicked (pnl As B4XView, LongClicked As Boolean)
If DateTime.Now < LastCellClickEvent + 20 Then Return
LastCellClickEvent = DateTime.Now
Dim column As B4XTableColumn = pnl.Parent.Tag
Dim Row As Int = pnl.Tag - 1
Dim e As String
If Row = -1 Then
If LongClicked Then
e = "_headerlongclicked"
Else
e = "_headerclicked"
HeaderClicked(column)
End If
If xui.SubExists(mCallBack, mEventName & e, 1) Then
#if B4i
If LongClicked Then FeedbackGenerator.RunMethod("impactOccurred", Null)
#End If
CallSub2(mCallBack, mEventName & e, column.Id)
End If
Else
Dim RowId As Long = VisibleRowIds.Get(Row)
lRowID = RowId '<<<< added to pick up the SQLite rowid

Now we could add a button to delete a row:

B4X:
Private Sub btnDelRow_Click
sql1.ExecNonQuery2("delete from data where rowid = ?", Array As String(lRowID))
CountAll = CountAll - 1
Refresh
End Sub


RBS
 
Upvote 0
Status
Not open for further replies.
Top