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 ................................................................................................ 18
4.2.6 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 ...................................................................................... 32
4.8.1.2 Xml help files for B4X Libraries ........................................................................... 32
4.8.2 Complie to a product specific library ............................................................................. 34
4.8.2.1 Library specific attributes ...................................................................................... 36
4.8.2.2 Tip for MaterialIcons and Fontawesome fonts ...................................................... 38
4.9 Program flow ...................................................................................................................... 39
4.10 Intellisense help .................................................................................................................. 40
4.10.1 Comments before Sub Class_Globals ....................................................................... 40
4.10.2 Comments before a routine ........................................................................................ 40
4.10.3 Comments before an event routine ............................................................................ 41
4.11 CustomViews (XUI) .......................................................................................................... 42
4.11.1 CustomViews (XUI) class structue ............................................................................ 42
4.12 GetView ............................................................................................................................. 43
4.13 Add many CustomViews in the code ................................................................................. 44
5 First example CustomButton .................................................................................................... 46
5.1 Event declarations .............................................................................................................. 46
5.2 Custom properties for the Designer ................................................................................... 46
5.3 Class help header................................................................................................................ 47
5.4 Global variables ................................................................................................................. 48
5.5 Initialize routine ................................................................................................................. 49
5.6 DesignerCreateView routine .............................................................................................. 50
5.7 Base_Resize routine B4i / B4J only .................................................................................. 51
5.8 AddToParent routine .......................................................................................................... 52
5.9 InitClass routine ................................................................................................................. 53
5.10 Click / LongClick event routines ....................................................................................... 55