Android Question ZoomImageView - Error

artsoft

Active Member
Licensed User
Longtime User
Hi all!

I need a ZoomImageView which is not provided by the designer.

I need it while runtime:

B4X:
    Dim svIV As ZoomImageView
    svIV.Initialize (Me, "showImage")
    svIV.SetBitmap(b)
    svIV.tag = t
    sv.Panel.AddView(svIV.ImageView, 10dip, yPos, w, h)

Additional notes:

- b is a valid bitmap
- t is a valid string
- sv is a valid ScrollView
- w and h are valid dimensions

I got an error in this line...

B4X:
    svIV.SetBitmap(b)

... with this log info:

B4X:
 ...
Error occurred on line: 91 (ZoomImageView)
java.lang.RuntimeException: Object should first be initialized (B4XView).
    at anywheresoftware.b4a.AbsObjectWrapper.getObject(AbsObjectWrapper.java:67)
    at anywheresoftware.b4a.objects.B4XViewWrapper.asViewWrapper(B4XViewWrapper.java:89)
    at anywheresoftware.b4a.objects.B4XViewWrapper.SetBitmap(B4XViewWrapper.java:377)
    at de.padlockblue.manager.zoomimageview._setbitmap(zoomimageview.java:136)
    at java.lang.reflect.Method.invoke(Native Method)
 ...

If I use a normal ImageView instance, then there is no error.

Where is my mistake here?

Thanks for any help in advance.
Regards ARTsoft
 

artsoft

Active Member
Licensed User
Longtime User
Great Erel!

Yes, I see this mechanism now within the example code which comes also with the ZoomImageView lib.

Thanks a lot.
Best regards
 
Upvote 0

artsoft

Active Member
Licensed User
Longtime User

I have to ask a question to this.

I try to add now some instances of a ZoomImageView with this code (is called in my case two times):

B4X:
    Activity.LoadLayout("zi_view")
    
    ZIV.SetBitmap(b)
    ZIV.tag = t
    ZIV.mBase.Enabled = True
    ZIV.mBase.Visible = True
    ZIV.mBase.Width = w
    ZIV.mBase.Height = h
    
    sv.Panel.AddView(ZIV.ImageView, 10dip, yPos, w, h)

While trying to add the view to my ScrollView, now I get this exception:

B4X:
java.lang.IllegalStateException: The specified child already has a parent. You must call removeView() on the child's parent first.
    at android.view.ViewGroup.addViewInner(ViewGroup.java:5274)
    at android.view.ViewGroup.addView(ViewGroup.java:5089)
    at android.view.ViewGroup.addView(ViewGroup.java:5061)
    at anywheresoftware.b4a.objects.PanelWrapper.AddView(PanelWrapper.java:65)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.shell.Shell.runVoidMethod(Shell.java:777)

The layout "zi_view" only contains 1 instance of a ZoomImageView and the parent there is the Activity itself.

Where is my mistake currently?

Thx and regards
ARTsoft
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
Upvote 0
Top