public class ImageButton extends ImageWidget implements Clickable
Modifier and Type | Field and Description |
---|---|
static int |
ACTIVE
Active state.
|
NO_CONSTRAINT
Constructor and Description |
---|
ImageButton(String imagePath)
Creates an image button with the resource path of the image to display.
|
Modifier and Type | Method and Description |
---|---|
boolean |
handleEvent(int event)
Handles the given event.
|
boolean |
isInState(int state)
Gets whether or not the widget is in the given state.
|
void |
setOnClickListener(OnClickListener listener)
Sets the listener on the click events of this button.
|
void |
setPressed(boolean pressed)
Changes the clickable element state.
|
computeContentOptimalSize, onAttached, onDetached, renderContent, setImagePath
addClassSelector, contains, containsWidget, getAbsoluteX, getAbsoluteY, getContentBounds, getDesktop, getHeight, getParent, getStyle, getWidgetAt, getWidth, getX, getY, hasClassSelector, isAttached, isEnabled, isShown, isTransparent, onHidden, onLaidOut, onShown, removeAllClassSelectors, removeClassSelector, render, requestLayOut, requestRender, requestRender, setClassSelectors, setEnabled, setPosition, setStyle, updateStyle
public static final int ACTIVE
public ImageButton(String imagePath)
imagePath
- the resource path of the image to display.public boolean handleEvent(int event)
Widget
false
(does not consume event).
Called by the desktop event manager.
handleEvent
in class Widget
event
- the event to handle.true
if the widget has consumed the event, false
otherwise.public boolean isInState(int state)
Widget
public void setOnClickListener(@Nullable OnClickListener listener)
listener
- the listener to set.public void setPressed(boolean pressed)
Clickable
setPressed
in interface Clickable
pressed
- true
if the element is pressed, false
otherwise.