TableView2 library extends TableView and adds support for action buttons.
The reason for the new library is that TableView2 requires iOS 8+.
You can download it here: https://www.b4x.com/android/forum/threads/updates-to-internal-libraries.48179/page-2#post-385518
Action buttons can be added items with TableCell.AddActionButton.
The buttons are revealed with a swipe.
The ActionButtonClicked event is raised when the user clicks on one of the buttons.
A complete example:
The reason for the new library is that TableView2 requires iOS 8+.
You can download it here: https://www.b4x.com/android/forum/threads/updates-to-internal-libraries.48179/page-2#post-385518
Action buttons can be added items with TableCell.AddActionButton.
The buttons are revealed with a swipe.
The ActionButtonClicked event is raised when the user clicks on one of the buttons.
A complete example:
B4X:
Sub Process_Globals
Public App As Application
Public NavControl As NavigationController
Private Page1 As Page
Private TableView1 As TableView
End Sub
Private Sub Application_Start (Nav As NavigationController)
NavControl = Nav
Page1.Initialize("Page1")
Page1.Title = "Page 1"
Page1.RootPanel.Color = Colors.White
NavControl.ShowPage(Page1)
TableView1.Initialize("TableView1", False)
For i = 1 To 1000
Dim tc As TableCell = TableView1.AddSingleLine($"Item #${i}"$)
tc.AddActionButton("Delete", Colors.Red)
tc.AddActionButton("Change Value", Colors.Green)
Next
Page1.RootPanel.AddView(TableView1, 0, 0, 100%x, 100%y)
End Sub
Private Sub TableView1_ActionButtonClicked (SectionIndex As Int, Cell As TableCell, Text As String)
Select Text
Case "Delete"
TableView1.BeginUpdates
TableView1.RemoveCells(SectionIndex, TableView1.GetItems(SectionIndex).IndexOf(Cell), 1)
TableView1.EndUpdates
Case "Change Value"
Dim s As AttributedString
s.Initialize("New Value", Font.DEFAULT_BOLD, Rnd(Colors.Black, Colors.White))
Cell.Text = s
Cell.Update
End Select
End Sub
Private Sub Page1_Resize(Width As Int, Height As Int)
TableView1.SetLayoutAnimated(0, 1, 0, 0, 100%x, 100%y)
End Sub