Android Question AHViewPager

gruizelgruis

Member
Licensed User
Longtime User
Hi all,
I'm pulling my hair out because I cant find a solution to the "Initialize" problem i have.

Attention: V2.20 has an API change which makes the ViewPager incompatible with older versions. The AHPageContainer parameter is removed from the Initialize() method. Initialize2() has the old signature. If you use Initialize() (or add the View to the Designer as a custom view) then you have to set the container object with ViewPager.PageContainer = <YourContainer>

B4X:
Dim ProductenContainer As AHPageContainer '// <-- lib AHPageviewer
Dim ProductPager As AHViewPager

'Initialize the panels we use for the pages and put them in the container
ProductenContainer.Initialize  '/ AHPageViewer <-- 

Dim Pan As Panel
        Pan = CreateProductPanel( MsgPart(1), TempProductList )
        ProductenContainer.AddPage( Pan ,MsgPart(1))

ProductPager.Initialize(ProductenContainer)

I have been at this all day. And I cant find anything that points to a solution.
 

gruizelgruis

Member
Licensed User
Longtime User
Still having some issues I hope some one can help me out.
My project compiles ok. But crashes on this line: "ProductTabs.Initialize(ProductPager)"
I know the APi has changed. Is the AHViewPagerTabs still functional, if so. How do I implement this

B4X:
    Dim ProductenContainer As AHPageContainer '// <-- lib AHPageviewer
    Dim ProductPager As AHViewPager
    Dim ProductTabs As AHViewPagerTabs

ProductenContainer.Initialize
...
...
Pan = CreateProductPanel( MsgPart(1), TempProductList )

    ProductenContainer.AddPage( Pan ,MsgPart(1))
       
    '/ProductPager.Initialize(ProductenContainer)
           
    ProductPager.PageContainer = ProductenContainer
           
    'As we want to show the tabs page indicator, we initialize it
    ProductTabs.Initialize(ProductPager) '/ app stops at this point


Error occurred on line: 424 (Main)
java.lang.RuntimeException: Object should first be initialized (AHViewPager).
at anywheresoftware.b4a.AbsObjectWrapper.getObject(AbsObjectWrapper.java:67)
at de.amberhome.viewpager.AHViewPager.setPageContainer(AHViewPager.java:221)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.shell.Shell.runVoidMethod(Shell.java:777)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:354)
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 anywheresoftware.b4a.BA.raiseEvent2(BA.java:197)
at anywheresoftware.b4a.debug.Debug.delegate(Debug.java:262)
at b4a.example.main._mainchat(main.java:1630)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.debug.Debug.CallSub4(Debug.java:318)
at anywheresoftware.b4a.debug.Debug.CallSubNew2(Debug.java:285)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.keywords.Common.CallSubDebug2(Common.java:1055)
at b4a.example.svrchat._newtext(svrchat.java:294)
at b4a.example.svrchat$ResumableSub_ConnectAndSend.resume(svrchat.java:208)
at anywheresoftware.b4a.shell.DebugResumableSub$DelegatableResumableSub.resumeAsUserSub(DebugResumableSub.java:48)
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 anywheresoftware.b4a.BA.raiseEvent(BA.java:193)
at anywheresoftware.b4a.shell.DebugResumableSub$DelegatableResumableSub.resume(DebugResumableSub.java:43)
at anywheresoftware.b4a.BA.checkAndRunWaitForEvent(BA.java:267)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:137)
at anywheresoftware.b4a.BA$2.run(BA.java:387)
at android.os.Handler.handleCallback(Handler.java:790)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6518)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:472)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
 
Upvote 0

Situ LLC

Active Member
Licensed User
The first 2 Dim move to global area an change for private o public. You will see it works happening a few times ..
 
Upvote 0
Top