# Class WidgetKind

java.lang.Object
com.codename1.surfaces.WidgetKind

public class WidgetKind extends Object

Declares one kind of home-screen widget the app offers (an app may offer several). The kind id must match an entry in the `surfaces.json` file kept in the project's resources: widget kinds are compiled into the native app (the widget gallery entries, the iOS widget bundle and the Android receivers are all static), so the build needs them at build time while this runtime declaration drives publishing and validation. A mismatch logs a prominent warning.

Ids are restricted to `[a-z][a-z0-9_]*` because they are used to derive native type and resource names.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `WidgetKind(String id)`
  Creates a widget kind declaration.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `WidgetKind`
  `addSupportedSize(WidgetSize size)`
  Adds a supported size family.
  `String`
  `getDescription()`
  Returns the gallery description, or null.
  `String`
  `getDisplayName()`
  Returns the gallery title, or null.
  `String`
  `getId()`
  Returns the stable kind identifier.
  `List<WidgetSize>`
  `getSupportedSizes()`
  Returns the supported size families; `SMALL` and `MEDIUM` when none were added explicitly.
  `WidgetKind`
  `setDescription(String description)`
  Sets the description shown in the platform widget gallery.
  `WidgetKind`
  `setDisplayName(String displayName)`
  Sets the title shown in the platform widget gallery.

  ### Methods inherited from class Object

  `clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Constructor Details

  - ### WidgetKind

    public WidgetKind(String id)

    Creates a widget kind declaration.

    ###### Parameters

    - `id`: the stable kind identifier, `[a-z][a-z0-9_]*`

- ## Method Details

  - ### setDisplayName

    public WidgetKind setDisplayName(String displayName)

    Sets the title shown in the platform widget gallery.

    ###### Parameters

    - `displayName`: the gallery title

    ###### Returns

    this kind, for chaining

  - ### setDescription

    public WidgetKind setDescription(String description)

    Sets the description shown in the platform widget gallery.

    ###### Parameters

    - `description`: the gallery description

    ###### Returns

    this kind, for chaining

  - ### addSupportedSize

    public WidgetKind addSupportedSize(WidgetSize size)

    Adds a supported size family. When no size is added the kind defaults to `SMALL` and `MEDIUM`.

    ###### Parameters

    - `size`: the size family to support

    ###### Returns

    this kind, for chaining

  - ### getId

    public String getId()
    Returns the stable kind identifier.

  - ### getDisplayName

    public String getDisplayName()
    Returns the gallery title, or null.

  - ### getDescription

    public String getDescription()
    Returns the gallery description, or null.

  - ### getSupportedSizes

    public List<WidgetSize> getSupportedSizes()
    Returns the supported size families; `SMALL` and `MEDIUM` when none were added explicitly.