I have made a custom view and I try to add it to the activity.addview and I face type mismatch issue
I thought customview never be a view until I saw SimpleExoPlayerView which is a custom view and it is added normally to activity.addview
I need to add the customview to the activity not the Base because I laterly use findview to get the view from the activity and use it's custom properties
I have Added it already but it only allow me to add the base panel to the activity, while I need the complete control to be able to access it again with findview
I tested it, it's possible!
You should add a routine to get the base panel, even like a Propety, if it doesn's exist.
I tested it like this.
B4X:
Public Sub getPanel As Panel
Return BasePanel ' name depends on your code
End Sub
Then in the calling module: MyCustomView.Panel.NumberOfViews works. For Each v As View In MyCustomView.Panel.GetAllViewsRecursive works For Each v As View In Acticity.GetAllViewsRecursive works, and finds all the views in the CustomView.
I tested it, it's possible!
You should add a routine to get the base panel, even like a Propety, if it doesn's exist.
I tested it like this.
B4X:
Public Sub getPanel As Panel
Return BasePanel ' name depends on your code
End Sub
Then in the calling module: MyCustomView.Panel.NumberOfViews works. For Each v As View In MyCustomView.Panel.GetAllViewsRecursive works For Each v As View In Acticity.GetAllViewsRecursive works, and finds all the views in the CustomView.
Sorry, I do not understand.
What do yo mean with custom view itself?
The CustomView is only known by it's main Panel.
You can define the properties of the CustomView with getXXX and setXXX routines.
XXX will be considered as a Property.
The you can access it with MyCustomView.XXX.
Sorry, I do not understand.
What do yo mean with custom view itself?
The CustomView is only known by it's main Panel.
You can define the properties of the CustomView with getXXX and setXXX routines.
XXX will be considered as a Property.
The you can access it with MyCustomView.XXX.
I need to be able to add multiple ScrollingPanels at runtime and access them with findview to add more text and call ScrollingPanel1.AddObject
If I just added the ScrollingPanel1.base panel to the activity I wouldn't be able to access the method ScrollingPanel1.AddObject because it belongs to the customview not the base panel. and Findview would only return the basepanel
if there is a way to get the customView from it's basepanel that would work
I've done something similar in my MultiRowTabPane library (It's for B4j but the method will work for B4a). Create the panel in the calling activity or class then pass it to the customview to add it.
You will need to keep a reference to the panel as a global variable if you want to change it after adding, and any callbacks will come directly to the calling module.
I've done something similar in my MultiRowTabPane library (It's for B4j but the method will work for B4a). Create the panel in the calling activity or class then pass it to the customview to add it.
You will need to keep a reference to the panel as a global variable if you want to change it after adding, and any callbacks will come directly to the calling module.
yeah, it looks that I have to keep global map for the runtime created views and customviews to be able to access them later, which is not the elegant way, but It may work
It could be possible to get the library to add the panel and handle the callbacks. But it would mean handling every possible type of callback if you don't know what is going to be added. And if a customview is added, you won't know what the events will be.