Android Question CLVNested Error

gacar

Active Member
I am trying CLVNested I am getting "java.lang.reflect.InvocationTargetException" error

Here my codes

B4XMainPage

B4X:
Sub Class_Globals
    Private Root As B4XView
    Private xui As XUI
    Private CustomListView1 As CustomListView
    Private clvItem As CustomListView
    Private nested As CLVNested 
End Sub

Public Sub Initialize
'    B4XPages.GetManager.LogEvents = True  
End Sub

'This event will be called once, before the page becomes visible.
Private Sub B4XPage_Created (Root1 As B4XView)
    Root = Root1
    Root.LoadLayout("MainPage")   
    nested.Initialize(Me) '<<<<<<<<<<<< Here using "activity" in original code, but i couldn't use "activity" here then using "Me"
    nested.base.LoadLayout("1")
    nested.CLV = CustomListView1
    For i = 1 To 1 
        Dim p As B4XView = xui.CreatePanel("")
        p.SetLayoutAnimated(0, 0, 0, 100%x, 200dip)
        p.LoadLayout("Item")
        FillInnerList
        p.Tag = clvItem 'must set the Panel tag like this
        CustomListView1.Add(p, "")
    Next
End Sub

Sub FillInnerList
    Dim s As String= "lorem ipsum dolor sit amet, consectetur adipiscing elit. " _
    & "sed id tempus libero. phasellus tempor ullamcorper feugiat. sed vitae vulputate mauris, vitae efficitur erat. mauris dolor nisi, efficitur sollicitudin tristique id, interdum tempus quam. aliquam eleifend ligula id odio consequat mollis. orci varius natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. maecenas viverra orci at hendrerit aliquet. proin sollicitudin erat eu dictum tincidunt." _
    & "etiam vulputate egestas libero, ut mattis turpis semper vel. donec lacus nisl, sollicitudin eu congue et, iaculis a sapien. aliquam tristique ullamcorper mi, at malesuada massa finibus non. maecenas id dapibus arcu. in venenatis et eros non bibendum. fusce non lacus sed erat interdum placerat. vivamus tristique orci at lectus feugiat viverra.morbi porta viverra vestibulum. sed congue congue mi, id convallis ex tempor at. proin fermentum semper libero, at ullamcorper lectus consectetur nec. sed id magna erat. nullam in lectus viverra purus rhoncus iaculis nec ultrices tellus. sed eu turpis pellentesque, accumsan ligula non, pharetra libero. vivamus sed quam enim. proin vehicula arcu sit amet malesuada fermentum. cras id dolor non ligula malesuada dapibus. interdum et malesuada fames ac ante ipsum primis in faucibus. curabitur a arcu a urna dapibus tincidunt non id mauris1." _ 
    & "etiam vulputate egestas libero, ut mattis turpis semper vel. donec lacus nisl, sollicitudin eu congue et, iaculis a sapien. aliquam tristique ullamcorper mi, at malesuada massa finibus non. maecenas id dapibus arcu. in venenatis et eros non bibendum. fusce non lacus sed erat interdum placerat. vivamus tristique orci at lectus feugiat viverra.morbi porta viverra vestibulum. sed congue congue mi, id convallis ex tempor at. proin fermentum semper libero, at ullamcorper lectus consectetur nec. sed id magna erat. nullam in lectus viverra purus rhoncus iaculis nec ultrices tellus. sed eu turpis pellentesque, accumsan ligula non, pharetra libero. vivamus sed quam enim. proin vehicula arcu sit amet malesuada fermentum. cras id dolor non ligula malesuada dapibus. interdum et malesuada fames ac ante ipsum primis in faucibus. curabitur a arcu a urna dapibus tincidunt non id mauris2."
    clvItem.AddTextItem(s, 0)
End Sub

CLVNested

B4X:
Sub Class_Globals
    Private xui As XUI 'ignore
    Public base As B4XView
    Public CLV As CustomListView
End Sub

Public Sub Initialize (Parent As B4XView)
    Dim tpc As TouchPanelCreator
    base = tpc.CreateTouchPanel("tpc")
    Parent.AddView (base, 0, 0, Parent.Width, Parent.Height)
End Sub

My Sample code and Original CLVNested Code here
 

Attachments

  • Project.zip
    19 KB · Views: 165
  • CLVNested.zip
    12.7 KB · Views: 171

gacar

Active Member
Please post the full error message from the logs. Right click to copy.

My error code here

B4X:
Günlükçü şuna bağlandı: emulator-5554
--------- beginning of system
--------- beginning of main
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
17
*** Service (service1) Create ***
** Service (service1) Start **
Connected to B4A-Bridge (Wifi)
Installing file.
** Activity (main) Pause, UserClosed = false **
Sleep not resumed (context is paused): anywheresoftware.b4a.b4abridge.anotherprogressbar$ResumableSub_BusyLoop
PackageAdded: package:b4a.example
Copying updated assets files (2)
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
Connected to B4A-Bridge (Wifi)
Connected to B4A-Bridge (Wifi)
** Activity (main) Pause, UserClosed = false **
Connected to B4A-Bridge (Wifi)
Copying updated assets files (3)
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
Error occurred on line: 10 (CLVNested)
java.lang.reflect.InvocationTargetException
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.keywords.Common.CallSubDebug2(Common.java:1055)
    at b4a.example.b4xpagesmanager._createpageifneeded(b4xpagesmanager.java:1060)
    at b4a.example.b4xpagesmanager._showpage(b4xpagesmanager.java:417)
    at b4a.example.b4xpagesmanager._addpage(b4xpagesmanager.java:245)
    at b4a.example.b4xpagesmanager._addpageandcreate(b4xpagesmanager.java:259)
    at b4a.example.b4xpagesmanager._initialize(b4xpagesmanager.java:165)
    at b4a.example.main._activity_create(main.java:415)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:732)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:351)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:255)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:144)
    at b4a.example.main.afterFirstLayout(main.java:105)
    at b4a.example.main.access$000(main.java:17)
    at b4a.example.main$WaitForLayout.run(main.java:83)
    at android.os.Handler.handleCallback(Handler.java:751)
    at android.os.Handler.dispatchMessage(Handler.java:95)
    at android.os.Looper.loop(Looper.java:154)
    at android.app.ActivityThread.main(ActivityThread.java:6161)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:892)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:782)
Caused by: java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
    at anywheresoftware.b4a.debug.Debug.CallSub4(Debug.java:336)
    at anywheresoftware.b4a.debug.Debug.CallSubNew2(Debug.java:285)
    ... 24 more
Caused by: java.lang.reflect.InvocationTargetException
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.debug.Debug.CallSub4(Debug.java:318)
    ... 25 more
Caused by: java.lang.ClassCastException: b4a.example.b4xmainpage cannot be cast to android.view.View
    at anywheresoftware.b4a.objects.B4XViewWrapper.asViewWrapper(B4XViewWrapper.java:89)
    at anywheresoftware.b4a.objects.B4XViewWrapper.getWidth(B4XViewWrapper.java:142)
    at b4a.example.clvnested._initialize(clvnested.java:58)
    at b4a.example.b4xmainpage._b4xpage_created(b4xmainpage.java:60)
    ... 27 more
** Activity (main) Resume **
 
Upvote 0
Top