artsoft Active Member Licensed User Longtime User Jun 3, 2021 #1 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
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
Erel B4X founder Staff member Licensed User Longtime User Jun 3, 2021 #2 [B4X] I need 100 <custom view here>s. How to add programmatically? Upvote 0
artsoft Active Member Licensed User Longtime User Jun 3, 2021 #3 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
Great Erel! Yes, I see this mechanism now within the example code which comes also with the ZoomImageView lib. Thanks a lot. Best regards
artsoft Active Member Licensed User Longtime User Jun 3, 2021 #4 Erel said: [B4X] I need 100 <custom view here>s. How to add programmatically? Click to expand... 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
Erel said: [B4X] I need 100 <custom view here>s. How to add programmatically? Click to expand... 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
Erel B4X founder Staff member Licensed User Longtime User Jun 3, 2021 #5 artsoft said: Where is my mistake currently? Click to expand... In most cases it is a mistake to use ScrollView. Much simpler to use xCustomListView. You need to add ZIV.mBase, not ZIV.ImageView. Upvote 0
artsoft said: Where is my mistake currently? Click to expand... In most cases it is a mistake to use ScrollView. Much simpler to use xCustomListView. You need to add ZIV.mBase, not ZIV.ImageView.
DonManfred Expert Licensed User Longtime User Jun 4, 2021 #6 artsoft said: I need it while runtime Click to expand... This is a mistake. [B4X] I need 100 <custom view here>s. How to add programmatically? Custom views are designed to be added with the designer. It is however very simple to create a layout file with the custom view and load it multiple times. Tip: remove the call to AutoScaleAll from the designer script. Complete example: Sub Globals Private B4XSwitch1 As B4XSwitch End... www.b4x.com Upvote 0
artsoft said: I need it while runtime Click to expand... This is a mistake. [B4X] I need 100 <custom view here>s. How to add programmatically? Custom views are designed to be added with the designer. It is however very simple to create a layout file with the custom view and load it multiple times. Tip: remove the call to AutoScaleAll from the designer script. Complete example: Sub Globals Private B4XSwitch1 As B4XSwitch End... www.b4x.com