Android Question Table class / LoadTableFromCSV does not clear contents

gezueb

Active Member
Licensed User
Longtime User
I want to use a table to show contents of CSV files found with the ContentChooser. The table is loaded and displayed correctly the first time. But if another file which has less rows than the previous one is picked, the trailing rows of the previous file are not removed. According to the description, LoadTableFromCSV should clear the table, but for some reason it does not. Neither does the clearall method.

Result Event Content Chooser:
Sub CC_Result (Success As Boolean, Dir As String, FileName As String)
    
    If Success = True Then
        ParameterTable.Initialize(Me,"",7,1,False) 'new call for version 1.44
        If Screenheight/Screenwidth < 0.45 Then 'rather wide like the flip
            ParameterTable.AddToActivity(Activity, 40%x, 15%y, 460dip, 75%y) 'width is the sum of all dips below
            ParameterTable.SetHeader(Array As String("ID", "Bezeichnung", "On", "Off","Reps","Wied.h","Aktiv"))
            ParameterTable.RowHeight = 20dip
            ParameterTable.SetColumnsWidths(Array As Int(30dip, 180dip, 50dip, 50dip, 50dip, 50dip,50dip))
        Else
            ParameterTable.AddToActivity(Activity, 40%x, 15%y, 550dip, 68%y) 'width is the sum of all dips below
            ParameterTable.SetHeader(Array As String("ID", "Bezeichnung", "On", "Off","Reps","Wied.h","Aktiv"))
            ParameterTable.SetColumnsWidths(Array As Int(50dip, 250dip, 50dip, 50dip, 50dip, 50dip,50dip))
        End If
        ChoosenDirectory = FileName
        Log ("ChoosenDirectory: "&ChoosenDirectory)
        
        If FileName.Contains( ".jpg") Then
            ImageView1.Bitmap = LoadBitmap(Dir,FileName)
        End If
        If FileName.Contains (".csv") Then
            ParameterTable.LoadTableFromCSV(Dir,FileName,True)
        End If
    Else
        ToastMessageShow("No Success :(",True)
    End If
        
End Sub

Thanks for help! Georg
 

gezueb

Active Member
Licensed User
Longtime User
Solved:
B4X:
If ParameterTable.IsInitialized Then ParameterTable.RemoveView

before initializing does the trick!
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
The problem is that in your CC_Return routine you initialize each time a new Table !
Which means that you still see the previous ones.
You should initialize it only once and then it will work OK without RemoveView.
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…