Android Question ScrollView cannot add custom view class

Nickelgrass

Active Member
Licensed User
Longtime User
Hello,
I have a custom view. In my activity I add a Scrollview. If I want to add my view it gives me warning 22 (Types do not match). Then I changed the view from cutsomview to customview(XUI) and the Scrollview to a xCustomListView but exactly the same.

Sample:
Dim gui_item As cv_can_display
gui_item.init(id, "suffix", 0x00FFFF)
GuiList.Panel.AddView(gui_item, offset*ITEMHEIGHT, 0dip, GuiList.Width, 100dip)
offset = offset + 1

How can I make a Scrollview and load my cutsom views in there? I thought the CustomListView was the way to go but no luck.

The error was
GuiList.Panel.AddView(gui_item, offset*ITEMHEIG
src\b4a\example\sample_app.java:499: error: incompatible types: cv_can_display cannot be converted to View
mostCurrent._guilist.getPanel().AddView((android.view.View)(_gui_item),(int) (_offset*_itemheight),anywheresoftware.b4a.keywords.Common.DipToCurrent((int) (0)),mostCurrent._guilist.getWidth(),anywheresoftware.b4a.keywords.Common.DipToCurrent((int) (100)));

Thanks
 

klaus

Expert
Licensed User
Longtime User
How did you create your CustoView.
If you want to add a CusromView by code you can:
- Make a layout file with just your CustomView and load it when needed.
- Add a AddToParent routine in your CustomView code. You may have a look at chapeter 4.3 Adding a custom view by code in the B4X CustomViews booklet.
 
Upvote 0

Nickelgrass

Active Member
Licensed User
Longtime User
Ah, thank you. Now I understand what the GetBase sub is for in the customviewclass module.

Code:
GuiList.Panel.AddView(gui_item.GetBase, offset*ITEMHEIGHT, 0dip, GuiList.Width, 100dip)

This worked too.
 
Upvote 0
Top