Android Question xCustomListView 1.53 GetView error

msali

Member
Licensed User
Longtime User
Hi,
I have looked everywhere on the forum but could not find the answer because it is working just perfectly well in the example by Erel at https://www.b4x.com/android/forum/threads/b4x-xui-cross-platform-native-ui-library.84359/

I have following code
B4X:
Sub chkSelect_CheckedChange(Checked As Boolean)
    Dim index As Int= clvPlayerFav.GetItemFromView(Sender)
    Dim pnl As B4XView= clvPlayerFav.GetPanel(index)
    lstSelectedPlayers.Add(pnl.GetView(1).Tag)   
End Sub

and I am getting following error.

I know i must be missing something very trivial but am not able to find the issue.

Note: Code works perfectly well if i use the for Each loop

B4X:
For Each v As B4XView In pnl.GetAllViewsRecursive


B4X:
actplayerlist_chkselect_checkedchange (java line: 475)
java.lang.RuntimeException: Object should first be initialized (View).
    at anywheresoftware.b4a.AbsObjectWrapper.getObject(AbsObjectWrapper.java:50)
    at anywheresoftware.b4a.objects.B4XViewWrapper.GetView(B4XViewWrapper.java:237)
    at com.jakes.kgscorecard.actplayerlist._chkselect_checkedchange(actplayerlist.java:475)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:186)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:170)
    at anywheresoftware.b4a.objects.CompoundButtonWrapper$1.onCheckedChanged(CompoundButtonWrapper.java:44)
    at android.widget.CompoundButton.setChecked(CompoundButton.java:157)
    at android.widget.CompoundButton.toggle(CompoundButton.java:116)
    at android.widget.CompoundButton.performClick(CompoundButton.java:121)
    at android.view.View$PerformClick.run(View.java:22473)
    at android.os.Handler.handleCallback(Handler.java:761)
    at android.os.Handler.dispatchMessage(Handler.java:98)
    at android.os.Looper.loop(Looper.java:156)
    at android.app.ActivityThread.main(ActivityThread.java:6523)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:942)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:832)

Thanks in advance
 

msali

Member
Licensed User
Longtime User
Dear Experts, it is killing me. Desperately need help.

I have even created another project and simulated the same flow, i.e., added a tabstrip in first layout, then a custom list view in 2nd layout and cards with multiple views in 3rd layout.

Even that project is working perfectly well.

Please , please help me out here. What am i doing wrong in the main project.

desperate for help.

regards.
 
Upvote 0

MarkusR

Well-Known Member
Licensed User
Longtime User
you should set a breakpoint in chkSelect_CheckedChange and start in debug mode so you can see what is set or not.
check index here index = clvPlayerFav.GetItemFromView(Sender)
check pnl here pnl = clvPlayerFav.GetPanel(index)
make a tempory variable here for theview = pnl.GetView(1)
look if theview.tag contains something before continue to
lstSelectedPlayers.Add(theview.Tag)
 
Upvote 0

mangojack

Well-Known Member
Licensed User
Longtime User
As @MarkusR suggested .. make a temporary variable for theview =pnl.GetView(1)

B4X:
Sub chkSelect_CheckedChange(Checked As Boolean)
  Dim index As Int= clvPlayerFav.GetItemFromView(Sender)
  Dim pnl As B4XView= clvPlayerFav.GetPanel(index)
  Dim v As B4XView = pnl.GetView(1)     'view containing tag property
  lstSelectedPlayers.Add(v.Tag)
End Sub
 
Upvote 0

msali

Member
Licensed User
Longtime User
Thanks for your responses guys.

I finally figured it out. Actually in the 3rd layout where i had placed the card for clvPlayerFav was within a panel view itself therefore i had to use the GetView twice.

B4X:
    Dim index As Int= clvPlayerFav.GetItemFromView(Sender)
    Dim pnl As B4XView= clvPlayerFav.GetPanel(index)
    Dim pnl2 As B4XView= pnl.GetView(0)
    Dim chk As B4XView = pnl2.GetView(2)
    lstSelectedPlayers.Add(chk.Tag)


All my views checkbox, button etc were in pnl2.


Anyhow, am thankful to you for your responses.

Cheers:)
 
Upvote 0
Top