Android Question Sorting error

Sergey_New

Well-Known Member
Licensed User
Longtime User
The following code throws an error when sorting the list:
java.lang.NoSuchFieldException: No field name in class Lsv/bystrovzorov/classrepository; (declaration of 'sv.bystrovzorov.classrepository' appears in base.apk)
What is the reason?
ClassRepository:
Sub Class_Globals
    Public name As String, address As ClassAddress, notes As List
End Sub

Public Sub Initialize
    address.Initialize
    notes.Initialize
End Sub
Activity:
Dim lst As List
lst.Initialize
For Each k As String In parser.db.repositories.Keys
    If parser.db.repositories.ContainsKey(k) Then
        Dim repo As ClassRepository=parser.db.repositories.Get(k)
        lst.Add(repo)
    End If
Next
lst.SortType("name",True)
 

Sergey_New

Well-Known Member
Licensed User
Longtime User
SortType works with custom types, not classes.
Added to Globals
B4X:
Type repo2(name As String, address As ClassAddress,notes As List)
Activity:
    Dim lst As List
    lst.Initialize
    For Each k As String In parser.db.repositories.Keys
        Dim repo As ClassRepository=parser.db.repositories.Get(k)
        Dim rp2 As repo2
        rp2.name=repo.name
        rp2.address=repo.address
        rp2.notes=repo.notes
        lst.Add(rp2)
    Next
    lst.SortType("name",True)
It works.
Is it possible to make it simpler?
If my memory serves me correctly, VB has the ability to sort classes.
 
Upvote 0
Top