B4A Library [Lib] ScrollView2D

fabioferreiracs

Member
Licensed User
Longtime User
is possible map touch event in scrollview2d ? i use a bitmap in scrollview2d background and I need to know what position was touched (x and y)
 

keirS

Well-Known Member
Licensed User
Longtime User
I cat get this library to work in Marshmallow 6.01 using your example code when I scroll I get.
B4X:
java.lang.NullPointerException: Attempt to invoke virtual method 'void android.graphics.drawable.Drawable.setAlpha(int)' on a null object reference
    at flm.b4a.scrollview2d.EdgeEffect.draw(EdgeEffect.java:320)
    at flm.b4a.scrollview2d.TwoDScrollView.draw(TwoDScrollView.java:1997)
    at android.view.View.draw(View.java:16096)
    at android.view.ViewGroup.drawChild(ViewGroup.java:3609)
    at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3399)
    at android.view.View.draw(View.java:16094)
    at android.view.ViewGroup.drawChild(ViewGroup.java:3609)
    at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3399)
    at android.view.View.draw(View.java:16094)
    at android.view.ViewGroup.drawChild(ViewGroup.java:3609)
    at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3399)
    at android.view.View.draw(View.java:16094)
    at android.view.ViewGroup.drawChild(ViewGroup.java:3609)
    at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3399)
    at android.view.View.draw(View.java:16187)
    at com.android.internal.policy.PhoneWindow$DecorView.draw(PhoneWindow.java:2690)
    at android.view.ViewRootImpl.drawSoftware(ViewRootImpl.java:2728)
    at android.view.ViewRootImpl.draw(ViewRootImpl.java:2642)
    at android.view.ViewRootImpl.performDraw(ViewRootImpl.java:2434)
    at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2067)
    at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1107)
    at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6013)
    at android.view.Choreographer$CallbackRecord.run(Choreographer.java:858)
    at android.view.Choreographer.doCallbacks(Choreographer.java:670)
    at android.view.Choreographer.doFrame(Choreographer.java:606)
    at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:844)
    at android.os.Handler.handleCallback(Handler.java:739)
    at android.os.Handler.dispatchMessage(Handler.java:95)
    at android.os.Looper.loop(Looper.java:148)
    at android.app.ActivityThread.main(ActivityThread.java:5417)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)

I tried disabling edge effects but it still crashes.
 

Informatix

Expert
Licensed User
Longtime User
Please download the latest version from this forum and try again.
 

jimmykuss

Member
Licensed User
Longtime User
Hello,

i use b4a V3.20 and can not run the demo (see picture). I got some errors(log) and have no idee.
Can you help me?
Thanks
JK
 

Attachments

  • log.PNG
    49.3 KB · Views: 234

vbmundo

Well-Known Member
Licensed User
Hi,

I quit the old Table.Bas from my Proyect and add this new Table2.0

But when compile I have error at this line

Private cTextSize As Float
Type RowCol (Row As Int, Col As Int)
Private cAlignment As Int

"An item with the same key is added."

What's wrong ?

Regards
 

klaus

Expert
Licensed User
Longtime User
I have a problem with the GetType function for ScrollView2D.Panel in version 1.2 of the library.
I get this error
Error occurred on line: 44 (Main)
java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.Object anywheresoftware.b4a.objects.PanelWrapper.getObject()' on a null object reference
at b4a.example.main._activity_create(main.java:431 ...

in this line: Log(GetType(sc2.Panel)) ' error in this line

The code:
B4X:
Sub Activity_Create(FirstTime As Boolean)
    Activity.LoadLayout("Main")
 
    Log(GetType(scvTest))
    Log(GetType(scvTest.Panel))
    InitScrollView2D
    Log(GetType(sc2Test))
    Log(GetType(sc2Test.Panel)) 'this works
 
    For i = 0 To Activity.NumberOfViews - 1
        Private v1 As View
        v1 = Activity.GetView(i)
        Log(GetType(v1))
        If GetType(v1) = "anywheresoftware.b4a.objects.ScrollViewWrapper$MyScrollView" Then
            Private scv As ScrollView
            scv = v1
            Log(GetType(scv.Panel))
        Else If GetType(v1) = "flm.b4a.scrollview2d.ScrollView2DWrapper$MyScrollView" Then
            Private sc2 As ScrollView2D
            sc2 = v1
            Log(GetType(sc2.Panel)) ' error in this line
        End If
    Next
End Sub

Attached a small test program.

The code above works with version 1.1 of the library.
 

Attachments

  • ScrollView2D_GetType.zip
    7.8 KB · Views: 294

Informatix

Expert
Licensed User
Longtime User
Yes, this is normal. The Panel is not created until the SV2D is initialized.
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…