Advanced
This section describes some additional API methods.
Retrieving a Cell
From time to time, you want to change specific properties of a layout element, not only the value. If you want to retrieve a Cell and change the size for example, you can do it like this:
Warning
This section is only applicable if you are using the NIMMSTA Core library to develop your application!
// Please note that in Kotlin the *Instance methods make sure the type matches as well.
device.screen.rootLayout?.findViewInstance<Cell> { it.name == "title" }?.fontSize = 34.pt
device.screen.rootLayout?.findViewByNameInstance<Cell>("test")?.fontSize = 34.pt
device.screen.rootLayout?.findViewByNameInstance<Cell>("test")?.hidden = true
// Won't compile as findViewByName returns View?, not Cell.
device.screen.rootLayout?.findViewByName("test")?.fontSize = 34.pt
Initiating layout before setting it
In certain cases it makes sense to create an instance of a NimmstaLayout from an XML file before transmitting it to the device. This way it is possible to change the layout before displaying it. An example would be hiding a view or calculating certain positions.
val layout = Platform.layoutInflater.parse("[XML-STRING]")
layout.findViewByName("test")?.hidden = true
device.setLayout(layout)
val layout = Platform.layoutInflater.parse(R.raw.nimmstalayout)
layout.findViewByName("test")?.hidden = true
device.setLayout(layout)
NimmstaLayout layout = Platform.INSTANCE.getLayoutInflater().parse("[XML-STRING]");
((Cell)layout.findViewByName("test")).setHidden(true);
device.setLayout(layout);