Skip to content

LabelEntityView

Steve Hannah edited this page Jul 6, 2021 · 1 revision

LabelEntityView

<labelEntityView>javadocs

Synopsis

A view which displays a label representing a given entity. This will display the entity name Thing.name as the text, and the entity’s icon (one of Thing.thumbnailUrl, Thing.image).

Usage

<labelEntityView iconWidth="WIDTH" iconHeight="HEIGHT"
    view-model="myEntity"
/>

Attributes

iconWidth

The icon width in pixels.

iconHeight

The icon height in pixels.

view-model

Reference to the entity to use as the view model.

label.*

The label property is a com.codename1.ui.Label component. You can set properties on this label by setting label.* attributes.

View Model

The view model is expected to properties with the following tags:

Thing.name

Will be used as the label text.

Thing.thumbnailUrl

Will be used as the label’s icon.

Thing.image

If no thumbnailUrl is found, it will check for a Thing.image property and use that as the label’s icon.

Example

<?xml version="1.0"?>
<y xsi:noNamespaceSchemaLocation="LabelEntityViewSample.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <title>LabelEntityView Example</title>
    <import>
        import com.codename1.rad.sampler.models.*;
    </import>
    <var name="profile" type="UserProfile"/>
    <script>
        profile = new UserProfileImpl();
        profile.setName("Duke");
        profile.setPhotoUrl("https://upload.wikimedia.org/wikipedia/commons/3/3d/Codenameone_New_Logo.png");
    </script>

    <labelEntityView view-model="profile"/>
    <labelEntityView view-model="profile" iconWidth="3rem" iconHeight="3rem"/>
    <labelEntityView view-model="profile" iconWidth="6rem" iconHeight="5rem"/>
    <labelEntityView view-model="profile" iconWidth="50vw" iconHeight="50vw"/>
</y>

Result:

LabelEntityViewSample
Clone this wiki locally