Android Question SearchView - during init list stopped app

arnold steger

Member
Licensed User
Longtime User
When click the button then stopped the application.
not can find my problem.

Process_Globals
Dim index As Object

Globals
Dim Namen As ListView
Dim svN As SearchView
Dim Namen_ListeGross,Namen_ListeKlein,NamenList As List

B4X:
Sub searchNamen_Click

If MarkerGeladen=False Then
    NamenList.Initialize
        Namen_ListeGross = File.ReadList(File.DirAssets,"Flurnamen_gross.txt")
       
        Namen_ListeKlein = File.ReadList(File.DirAssets,"Flurnamen_klein.txt")

    Dim files As List
    Dim PunkteFolder As String
   
    Punkte.Initialize("Punkte")
    PunkteFolder = PfadPunkte
    If File.Exists(PunkteFolder, "") = False Then
        ToastMessageShow("Ordner AppProbe nicht gefunden: " & CRLF & PunkteFolder, True)
        Return
    End If
    files = File.ListFiles(PunkteFolder) 'get all files in this folder
    If files.Size >0 Then
    For i = 0 To files.Size - 1
    Punkte.AddSingleLine(files.Get(i))
    Next

    End If

    For j = 0 To files.Size - 1
        Dim listtemp As List
        listtemp = File.ReadList(PfadPunkte,Punkte.GetItem(j))
    Next
    NamenListe=listtemp

MarkerGeladen=True

Else
    Namen.Initialize("Namen")
    Namen.AddTwoLines("Suchen","Name eingeben")
    For i = 1 To Namen_ListeGross.Size-1
    Dim PointsTempG() As String = Regex.Split(",",Namen_ListeGross.Get(i))
    Namen.AddTwoLines(PointsTempG(2),PointsTempG(0)&","&PointsTempG(1))
    NamenList.Add(PointsTempG(2))
    Next
    For i = 1 To Namen_ListeKlein.Size-1
    Dim PointsTempK() As String = Regex.Split(",",Namen_ListeKlein.Get(i))
    Namen.AddTwoLines(PointsTempK(2),PointsTempK(0)&","&PointsTempK(1))
    NamenList.Add(PointsTempK(2))
    Next
    For i = 1 To Punkte.Size-1
    Dim PointsTemp() As String = Regex.Split(",",NamenListe.Get(i))
    Namen.AddTwoLines(PointsTemp(2),PointsTemp(0)&","&PointsTemp(1))
    NamenList.Add(PointsTemp(2))
    Next

   
    Activity.AddView(Namen, 0, 50dip, 100%x, 100%y-100dip)
    ToastMessageShow(Namen.Size & " Flurnamen gefunden", True)
   
   
End If

End Sub

Sub svN_ItemClick(Value As String)
    Msgbox("Ausgewählte Flurname: " & Value, "")
   
End Sub

Sub Namen_ItemClick (Position As Int, Value As Object)
If Position=0 Then
    svN.Initialize(Me, "svN")
    svN.AddToParent(Activity, 0, 0, 200dip, 300dip)
    index=svN.SetItems(NamenList)
    svN.SetIndex(index,NamenList)
   
    Namen.RemoveView
'    svN.Initialize(Me, "svN")
    Else
    Namen.RemoveView
    Dim PointsTemp() As String = Regex.Split(",",Value)
    Msgbox("Ausgewählte Flurname: " & Value, "")
    End If

End Sub
 
Last edited:

arnold steger

Member
Licensed User
Longtime User
I can not find the ListView was`nt initialized

~i:** Activity (main) Create, isFirst = true **
~i:** Activity (main) Resume **
~de:searchview,4390913
java.lang.RuntimeException: Object should first be initialized (ListView).
at anywheresoftware.b4a.AbsObjectWrapper.getObject(AbsObjectWrapper.java:49)
at anywheresoftware.b4a.objects.ListViewWrapper.Clear(ListViewWrapper.java:197)
at com.AppProbeArnold.searchview._et_textchanged(searchview.java:326)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:636)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:302)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:238)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:121)
at anywheresoftware.b4a.objects.EditTextWrapper$1.afterTextChanged(EditTextWrapper.java:83)
at android.widget.TextView.sendAfterTextChanged(TextView.java:7626)
at android.widget.TextView.setText(TextView.java:3859)
at android.widget.TextView.setText(TextView.java:3708)
at android.widget.EditText.setText(EditText.java:81)
at android.widget.TextView.setText(TextView.java:3683)
at android.widget.TextView.setTransformationMethod(TextView.java:1755)
at android.widget.TextView.applySingleLine(TextView.java:7307)
at android.widget.TextView.setInputType(TextView.java:4075)
at anywheresoftware.b4a.objects.EditTextWrapper.setInputType(EditTextWrapper.java:174)
at com.AppProbeArnold.searchview._initialize(searchview.java:79)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:636)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:305)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:238)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:121)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:175)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:171)
at anywheresoftware.b4a.objects.ViewWrapper$1.onClick(ViewWrapper.java:77)
at android.view.View.performClick(View.java:4463)
at android.view.View$PerformClick.run(View.java:18789)
at android.os.Handler.handleCallback(Handler.java:808)
at android.os.Handler.dispatchMessage(Handler.java:103)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:5299)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:825)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:641)
at dalvik.system.NativeStart.main(Native Method)
 
Last edited:
Upvote 0

arnold steger

Member
Licensed User
Longtime User
1.click of button Suchen read all my files.
2.click write all files in a list
first line of listview open searchfield.
In this line stopped app and show line 53 in SearchView-Module (lv.Clear)

java.lang.RuntimeException: Object should first be initialized (ListView).
 

Attachments

  • AppProbe.zip
    20.6 KB · Views: 221
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
You have modified SearchView code. It is important to write this when you post a question as the error can be related to the changes you did.

This code is wrong:
B4X:
For Each it As Item In li
     If full.Length > MAX_LIMIT And it.SearchText.Contains(full) = False Then
       Continue
     End If
     lv.AddTwoLines2(it.Title, it.Text, it)
   Next
The list holds strings not Items.
 
Upvote 0

arnold steger

Member
Licensed User
Longtime User
i have find my problem.
how can modification the code for return Position from list
svN_ItemClick(Value As String, Position As Int)
 
Upvote 0

arnold steger

Member
Licensed User
Longtime User
I have resolved in a other way.
This code work fine.

B4X:
Sub searchNamen_Click

If MarkerGeladen=False Then
    NamenList.Initialize
    NamenData.Initialize
    Namen.AddSingleLine("Name suchen...")
    NamenData.Add("Name suchen...")
    For i = 1 To Namen_ListeGross.Size-1
    Dim PointsTempG() As String = Regex.Split(",",Namen_ListeGross.Get(i))
    NamenData.Add(PointsTempG(0)&","&PointsTempG(1)&","&PointsTempG(2))
    Namen.AddTwoLines(PointsTempG(2),PointsTempG(0)&","&PointsTempG(1))
    NamenList.Add(PointsTempG(2))
    Next
    For i = 1 To Namen_ListeKlein.Size-1
    Dim PointsTempK() As String = Regex.Split(",",Namen_ListeKlein.Get(i))
    NamenData.Add(PointsTempG(0)&","&PointsTempG(1)&","&PointsTempG(2))
    Namen.AddTwoLines(PointsTempK(2),PointsTempK(0)&","&PointsTempK(1))
    NamenList.Add(PointsTempK(2))
    Next
    For i = 1 To NamenListe.Size-1
    Dim PointsTemp() As String = Regex.Split(",",NamenListe.Get(i))
    NamenData.Add(PointsTempG(0)&","&PointsTempG(1)&","&PointsTempG(2))
    Namen.AddTwoLines(PointsTemp(2),PointsTemp(0)&","&PointsTemp(1))
    NamenList.Add(PointsTemp(2))
    Next
   
    Namen.Color=Colors.Black
    Namen.FastScrollEnabled=True
    Namen.Visible=True
    Activity.AddView(Namen, 0, 0, 100%x, 100%y-42dip)
    ToastMessageShow(Namen.Size & " Namen gefunden", False)
   
    If svNPanel.NumberOfViews>0 Then
    svNPanel.RemoveAllViews
    svN.AddToParent(svNPanel, 0, 0, 300dip, 300dip)
    svN.SetIndex(indexN)
    Else
    svN.AddToParent(svNPanel, 0, 0, 300dip, 300dip)
    indexN=svN.SetItems(NamenList)
    End If
End If
End Sub
Sub svN_ItemClick (Value As String)
    svNPanel.Visible=False
    Dim Position As Int
    Position=NamenList.IndexOf(Value)+1
    Dim PointsTemp() As String = Regex.Split(",",NamenData.Get(Position))
    cp.Initialize(PointsTemp(0),PointsTemp(1), 15)
    gmap.AnimateCamera(cp)
   
    Dim markertemp As Marker
    markertemp=gmap.AddMarker3(PointsTemp(0),PointsTemp(1),PointsTemp(2),IconTransp)
    markertemp.InfoWindowShown=True   
   End Sub
Sub Namen_ItemClick (Position As Int, Value As Object)
    Namen.RemoveView
If Position=0 Then
    svNPanel.Visible=True
Else   
    Dim PointsTemp() As String = Regex.Split(",",NamenData.Get(Position))
    cp.Initialize(PointsTemp(0),PointsTemp(1), 15)
    gmap.AnimateCamera(cp)

    Dim markertemp As Marker
    markertemp=gmap.AddMarker3(PointsTemp(0),PointsTemp(1),PointsTemp(2),IconTransp)
    markertemp.InfoWindowShown=True
End If

End Sub
 
Last edited:
Upvote 0

arnold steger

Member
Licensed User
Longtime User
I write from 3 list my "Namen" as listview.
All names from all my list are visible in listview, searchview find all names from all my list. Work fine.
My problem is when click of a item readed from first list (Namen_ListeGross) show my the marker and the position, perfectly.
When click of a item readed from second list (Namen_ListeKlein) then show my allway from last item from first list. the same whit (NamenListe)
how is my problem?
 
Upvote 0
Top