public class ImageButton extends ImageWidget
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 |
---|---|
void |
handleClick()
Handles a click event.
|
boolean |
handleEvent(int event)
Handles the given event.
|
boolean |
isInState(int state)
Gets whether or not the widget is in the given state.
|
protected void |
onAttached()
This method is called as soon as:
the widget is attached to a desktop that is attached,
the desktop of the widget is attached.
|
void |
setOnClickListener(OnClickListener listener)
Sets the listener on the click events of this button.
|
computeContentOptimalSize, 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 void handleClick()
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
protected void onAttached()
Widget
After this call, the widget is ready to be rendered.
For example, the widget can allocate some resources useful to render it.
onAttached
in class ImageWidget
Desktop.setAttached()
public void setOnClickListener(@Nullable OnClickListener listener)
listener
- the listener to set.