Table of contents 2 B4X CustomViews
1 General information ..................................................................................................................... 5
2 Class modules .............................................................................................................................. 6
2.1 Getting started ...................................................................................................................... 6
2.1.1 Adding a class module ..................................................................................................... 8
2.1.2 Polymorphism .................................................................................................................. 9
2.1.3 Self-reference ................................................................................................................. 10
2.1.4 Activity object B4A only ............................................................................................. 11
3 Standard class ............................................................................................................................. 12
3.1 Standard class structure ...................................................................................................... 12
4 CustomViews ............................................................................................................................. 14
4.1 CustomView types ............................................................................................................. 14
4.2 CustomView class structure ............................................................................................... 15
4.2.1 Event declarations .......................................................................................................... 16
4.2.2 Designer properties declarations .................................................................................... 16
4.2.3 Global variable declarations ........................................................................................... 16
4.2.4 Initialization routine ....................................................................................................... 17
4.2.5 Designer support routine DesignerCreateView ............................................................ 18
4.2.6 Accessing a CustomView from any container like xCustomListview .......................... 18
4.2.7 Routine to get the base Panel ......................................................................................... 19
4.3 Adding a custom view by code .......................................................................................... 20
4.4 Add properties .................................................................................................................... 21
4.5 Add Events ......................................................................................................................... 22
4.5.1 Code in the Class ............................................................................................................ 23
4.5.2 Event declaration in the class ......................................................................................... 24
4.5.3 Code in the calling module ............................................................................................ 24
4.6 Custom view and custom properties in the Designer ......................................................... 25
4.7 Add layouts to a CusomView ............................................................................................ 29
4.8 Libraries ............................................................................................................................. 30
4.8.1 Generate a B4X Library *.b4xlib .................................................................................. 31
4.8.1.1 AdditionalLibraries folder ...................................................................................... 33
4.8.1.2 Xml help files for B4X Libraries ........................................................................... 33
4.8.2 Complie to a product specific library ............................................................................. 35
4.8.2.1 Library specific attributes ...................................................................................... 37
4.8.2.2 Tip for MaterialIcons and Fontawesome fonts ...................................................... 39
4.9 Program flow ...................................................................................................................... 40
4.10 Intellisense help .................................................................................................................. 41
4.10.1 Comments before Sub Class_Globals ....................................................................... 41
4.10.2 Comments before a routine ........................................................................................ 41
4.10.3 Comments before an event routine ............................................................................ 42
4.11 CustomViews (XUI) .......................................................................................................... 46
4.11.1 CustomViews (XUI) class structure .......................................................................... 46
4.12 GetView ............................................................................................................................. 47
4.13 Add many CustomViews in the code ................................................................................. 48
5 First example xCustomButton................................................................................................... 50
5.1 Event declarations .............................................................................................................. 50
5.2 Custom properties for the Designer ................................................................................... 51
5.3 Class help header................................................................................................................ 51
5.4 Global variables ................................................................................................................. 52
5.5 Initialize routine ................................................................................................................. 53
5.6 DesignerCreateView routine .............................................................................................. 54
5.7 Base_Resize routine B4i / B4J only .................................................................................. 55
5.8 AddToParent routine .......................................................................................................... 56
5.9 InitClass routine ................................................................................................................. 57