I am trying to TAG data in GridView and Retrieving it on ItemClick event. But Getting the following error:-
This is my code:
B4X:
java.lang.NullPointerException
at it.giuseppe.salvi.gridview.library.core.GridViewActivityWrapper.getTag(GridViewActivityWrapper.java:253)
at com.prcamels.videos._gridview_itemclick(videos.java:503)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:175)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:163)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:159)
at it.giuseppe.salvi.gridview.library.core.GridViewActivityWrapper$1.onItemClick(GridViewActivityWrapper.java:153)
at it.giuseppe.salvi.gridview.library.core.widget.gridview.GridViewWrapper.onItemClick(GridViewWrapper.java:86)
at android.widget.AdapterView.performItemClick(AdapterView.java:298)
at android.widget.AbsListView.performItemClick(AbsListView.java:1086)
at android.widget.AbsListView$PerformClick.run(AbsListView.java:2855)
at android.widget.AbsListView$1.run(AbsListView.java:3529)
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)
java.lang.NullPointerException
This is my code:
B4X:
Sub ParseJSON(json As String)
Dim parser As JSONParser
parser.Initialize(json)
Dim root As Map = parser.NextObject
Dim albums As List = root.Get("albums")
Dim actAlbum As Int = -1
For Each col_albums As Map In albums
actAlbum = actAlbum +1
'Dim album_id As String = col_albums.Get("album_id")
'Dim album_image As String = col_albums.Get("album_image")
Dim album_title As String = col_albums.Get("album_title")
fromWeb.Initialize
If actAlbum = AlbumID Then
Dim Videos As List = col_albums.Get("videos")
Dim vid_row As Int = -1
For Each album_videos As Map In Videos
vid_row = vid_row +1
'Dim picture_id As String = album_pictures.Get("picture_id")
'Dim picture_date As String = album_pictures.Get("picture_date")
Dim video_title As String = album_videos.Get("video_title")
Dim video_image As String = album_videos.Get("video_image")
Dim video_id As String = album_videos.Get("video_id")
Dim vidmap As Map
vidmap.Initialize
vidmap.Put("video_id",video_id)
GridView.Tag = video_id
GridView.AddImageFromWeb(video_image)
GridView.SetText(vid_row, video_title)
fromWeb.Add(video_image)
Next
GridView.SetArrayList(fromWeb)
Page_title.Text = album_title
End If
Next
End Sub
Sub GridView_ItemClick(Position As Int, Tag As Object, Value As Object)
posSelected = Position
Dim vid = Sender As PhotoGridView
Dim vidmap As Map = vid.Tag
Log(vidmap.Get("video_id"))
'YouTube(vidmap.Get("video_id"))
End Sub