I need, as i made in b4a, to customize first and second line text size or line height of list view, pass a value to retrieve on click event and then open a file. Starting from b4a code
i write this code
But in this way i need to name txt file (or fill TableView) with same name of file, but it will be more efficent to pass a value like in AddTwoLines2 on b4a
Last problem: TableView is not word-wrapp capable so i'm looking to this custom list view class but i have not find a good way.
Any help will be appreciated
B4X:
'B4A code
Sub Globals
Dim lstTracce As ListView
End Sub
Sub Activity_Create(FirstTime As Boolean)
lstTracce.TwoLinesLayout.Label.TextSize = 14
lstTracce.TwoLinesLayout.Label.Height = 60dip
lstTracce.TwoLinesLayout.Label.Top=0
lstTracce.TwoLinesLayout.SecondLabel.Top = lstTracce.TwoLinesLayout.Label.Height
lstTracce.TwoLinesLayout.SecondLabel.TextSize = 12
lstTracce.TwoLinesLayout.SecondLabel.Height = 40dip
lstTracce.TwoLinesLayout.ItemHeight = lstTracce.TwoLinesLayout.Label.Height + lstTracce.TwoLinesLayout.SecondLabel.Height
i = 0
Do While i <7
i = i+1
lstTracce.AddTwoLines2(i,10+i,50+i)
Loop
lstTracce.SetSelection(0)
End Sub
Sub LstTracce_ItemClick (Position As Int, Value As Object)
Dim selection As String
Dim i As Intent
selection ="file_" & Value & ".txt"
If File.Exists(File.DirRootExternal, "/scabr/" & selection ) = False Then
File.Copy(File.DirAssets, selection, File.DirRootExternal, "/scabr/" & selection )
End If
i.Initialize(i.ACTION_VIEW, "file://" & File.Combine(File.DirRootExternal, "/scabr/" & selection ))
i.SetType("text/xml")
Try
StartActivity(i)
Catch
ToastMessageShow("Unable to open file.", True)
End Try
End Sub
i write this code
B4X:
'b4i code
Sub Process_Globals
'These global variables will be declared once when the application starts.
'Public variables can be accessed from all modules.
Public App As Application
Public NavControl As NavigationController
Public lstTracce As TableView
End Sub
Sub MyButton_Click
main1.Initialize("main1")
main1.Title = "My app"
main1.RootPanel.LoadLayout("main")
main1.RootPanel.AddView(lstTracce,0, 120, 100%x, 50%y)
NavControl.ShowPage(main1)
For i= 0 to 6
lstTracce.AddTwoLines(i,10+i)
Next
lstTracce.ReloadAll
End Sub
Sub LstTracce_SelectedChanged (SectionIndex As Int, Cell As TableCell)
Dim selection As String
selection ="file_" & Cell.Text.ToString & ".txt"
Try
Msgbox(selection ," File to open ")
'StartActivity(i)
Catch
Msgbox("Unable to open file.", "Error")
End Try
End Sub
But in this way i need to name txt file (or fill TableView) with same name of file, but it will be more efficent to pass a value like in AddTwoLines2 on b4a
Last problem: TableView is not word-wrapp capable so i'm looking to this custom list view class but i have not find a good way.
Any help will be appreciated
Last edited: