Android Question How do I add to List of a custom Type

Tim Chapman

Active Member
Licensed User
Longtime User
I don't know what the correct words are for what I am asking here. I don't know what to call the Objects.
Would Todos be called a list or something else?
Line 22 gives an error: Unknown Member: Add
What is the correct way for me to do this?
Thanks in advance!

My b4A Code:
Type Todo(ID As Short, Name As String, Status As Byte, Context As Byte, Category As Byte, Priority As Int, Note As String) 'THIS IS IN PROCESS_GLOBALS.
Dim Todos As Todo

Sub MySub
    Dim workbook1 As ReadableWorkbook
    Dim TodoSheet As ReadableSheet
    workbook1.Initialize(Dir, FileName)
    TodoSheet = workbook1.GetSheet(0)
      
    'Load the main sheet of the spreadsheet into an list of type Todo.
    For row = 1 To TodoSheet.RowsCount - 1
        Dim TempTodo As Todo
        TempTodo.Initialize
        If TodoSheet.GetCellValue(2,row) > 0 And TodoSheet.GetCellValue(2,row) < 5 Then
            TempTodo.ID = TodoSheet.GetCellValue(0,row)
            TempTodo.Name = TodoSheet.GetCellValue(1,row)
            TempTodo.Status = TodoSheet.GetCellValue(2,row)
            TempTodo.Context = TodoSheet.GetCellValue(5,row)
            TempTodo.Category = TodoSheet.GetCellValue(6,row)
            TempTodo.Priority = TodoSheet.GetCellValue(9,row)
            TempTodo.Note = TodoSheet.GetCellValue(17,row)
            Todos.Add(TempTodo)
            ExitFlag = 0
        End If
        
        If TodoSheet.GetCellValue(1,row) = "" Then 'Found the first blank line.  Done loading todo spreadsheet into Todos List.
            ExitFlag = 1
        End If
        If ExitFlag = 1 Then Exit
    Next
End Sub
    Next
 

mangojack

Expert
Licensed User
Longtime User
Would Todos be called a list or something else?

Declare Todos As List.. Then all should be good.

B4X:
Type Todo(ID As Short, Name As String, Status As Byte, Context As Byte, Category As Byte, Priority As Int, Note As String)

Private  Todos As List
 
Upvote 1
Top