Android Question How to Pass Number of Column Dynamically in Tableview

junaidahmed

Well-Known Member
Licensed User
Longtime User
I have used "Table1.LoadTableFromCSV2" to load data from csv file.I would like to know how to pass number of columns dynamically in Table Initialize (based on csv
B4X:
Table1.Initialize(Me, "Table1", 3, Gravity.CENTER_HORIZONTAL, True)
    Table1.CellAlignment = Bit.Or(Gravity.LEFT, Gravity.CENTER_VERTICAL)
    Table1.HeaderColor = Colors.Blue
    Table1.HeaderTextColor = Colors.Yellow
    Table1.TextColor = Colors.Blue
    Table1.TableColor = Colors.Red
    Table1.RowHeight = 30dip

    Table1.AddToActivity(Activity, 5, 12%y , Activity.Width, Activity.Height - 12%y)
        
    Table1.MultiSelect = False
    Table1.SortColumn = False
    Table1.SingleLine = False
    Table1.ClearAll

    Table1.LineWidth = 2dip
    Table1.TextSize = 14

Table1.LoadTableFromCSV2(File.DirRootExternal, "Grid.csv", True, ";", True)
        'Table1.JumpToRow(405)

        Dim Alignments() As Int
        Alignments = Array As Int(Gravity.CENTER, Bit.Or(Gravity.LEFT, Gravity.CENTER_VERTICAL), Bit.Or(Gravity.RIGHT, Gravity.CENTER_VERTICAL), Bit.Or(Gravity.LEFT, Gravity.CENTER_VERTICAL), Bit.Or(Gravity.RIGHT, Gravity.CENTER_VERTICAL))
        Table1.SetHeaderAlignments(Alignments)
        Table1.SetCellAlignments(Alignments)
        Dim tf() As Typeface
        tf = Array As Typeface(Typeface.DEFAULT, Typeface.DEFAULT_BOLD, Typeface.DEFAULT, Typeface.DEFAULT_BOLD, Typeface.DEFAULT)
        Table1.SetTypeFaces(tf)
file).
 
Top