Android Question Populate ListView via Code Module

CesarLM

Member
Licensed User
Longtime User
In Code Module

Sub populateList() As ListView
Dim lstCodes As ListView
lstCodes.Initialize("ListView")
lstCodes.AddTwoLinesAndBitmap2("...
lstCodes.AddTwoLinesAndBitmap2("...
End Sub


From the activity module

Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("layout")
Activity.AddView(mdlSubs.populateList(), 0dip, 0dip, 100dip, 100dip) ' java.lang.NullPointerException
...
End Sub


java.lang.NullPointerException
at iexe.com.br.gcc.actopcoes._activity_create(actopcoes.java:340)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:169)
at iexe.com.br.gcc.actopcoes.afterFirstLayout(actopcoes.java:102)
at iexe.com.br.gcc.actopcoes.access$000(actopcoes.java:17)
at iexe.com.br.gcc.actopcoes$WaitForLayout.run(actopcoes.java:80)
at android.os.Handler.handleCallback(Handler.java:615)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4745)
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:786)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)
 

DonManfred

Expert
Licensed User
Longtime User
Return the list from the populatelist sub.

B4X:
return lstCodes
End Sub
 
Upvote 0

CesarLM

Member
Licensed User
Longtime User
Click is not working on the Listitem Listview in activity module.

Sub lstCodes_ItemClick (Position As Int, Value As Object)
Log(Value)
End Sub
 
Upvote 0
Top