Emulator and device crash when click at ListView

trencasostres

Member
Licensed User
Longtime User
Hello,
when I click any item of a ListView, the emulator and the device crashes. The message is "Unafortunately, MyApp has stopped"

Can anyone help me?
Thanks.


Part of my code:

Sub Globals
Dim listado As List
Dim listarchivos As ListView
End Sub

--------------------------------------------------------------------------------------

Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("archivos")
listado.Initialize
End Sub
------------------------------------------------------------------------------------------------
Sub inicio
Select Case Msgbox2("Què vols fer?","","Partit nou","Abandonar l'aplicació","Carregar partit anterior",Null)
Case DialogResponse.POSITIVE
nuevo=True
StartActivity("principal")
Case DialogResponse.CANCEL
ExitApplication
Case DialogResponse.NEGATIVE
nuevo=False
listado.Addall(File.ListFiles(File.DirInternal))
listado.Sort(True)
For n = 0 To listado.Size-1
listarchivos.AddSingleLine(listado.Get(n))
Next
listarchivos.Visible=True
listarchivos.Initialize("listarchivos")
b_archivos_cancelar.visible=True
End Select
Return
End Sub
 

trencasostres

Member
Licensed User
Longtime User
Thank you for the answer and happy new year 2013.
This is the log contents when I click any item on the ListView. I think that it is Java language and I don't unsertand it.

** Activity (main) Resume **


java.lang.IndexOutOfBoundsException: Invalid index 3, size is 0


at java.util.ArrayList.throwIndexOutOfBoundsException(ArrayList.java:251)
at java.util.ArrayList.get(ArrayList.java:304)
at anywheresoftware.b4a.objects.SimpleListAdapter.getItem(SimpleListAdapter.java:72)
at anywheresoftware.b4a.objects.ListViewWrapper$1.onItemClick(ListViewWrapper.java:57)
at android.widget.AdapterView.performItemClick(AdapterView.java:298)
at android.widget.AbsListView.performItemClick(AbsListView.java:1100)
at android.widget.AbsListView$PerformClick.run(AbsListView.java:2749)
at android.widget.AbsListView$1.run(AbsListView.java:3423)
at android.os.Handler.handleCallback(Handler.java:725)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5039)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)


at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
at dalvik.system.NativeStart.main(Native Method)
 
Upvote 0

trencasostres

Member
Licensed User
Longtime User
Please use [ code ] [ /code ] tags (without spaces) when posting code.

Why do you initialize the list several times? If it was added with the designer then you do not need to initialize it at all.

Solved! I didn't know them.
Thank you.
 
Upvote 0
Top