public class

ImageButton

extends View
java.lang.Object
   ↳ com.neomades.ui.View
     ↳ com.neomades.ui.ImageButton

Class Overview

Control that displays an Image as a Button. ImageButton could have many images for different states of a Button.

Handling click events

Default properties

By default, the following properties are applied to a new ImageButton:

  • focusable (limited to some devices)
  • clickable
  • enabled
  • no text
  • no icon
  • width content stretch : MATCH_PARENT.
  • height content stretch : MATCH_CONTENT.
  • content alignment : HCENTER|VCENTER.

See Also

Summary

XML Attributes
Attribute Name Related Method Description
image setImage(Image) Res.image.XXXX or a color  
imageDisabled setImageDisabled(Image) Res.image.XXXX or a color  
imageFocused setImageFocused(int) Res.image.XXXX or a color  
imagePressed setImagePressed(int) Res.image.XXXX or a color  
[Expand]
Inherited XML Attributes
From class com.neomades.ui.View
[Expand]
Inherited Constants
From interface com.neomades.ui.Alignment
From interface com.neomades.ui.StretchMode
Public Constructors
ImageButton()
Creates a new Button.
ImageButton(Image img)
Creates a new Button with only an image.
ImageButton(int resId)
Creates a new Button with only an image.
Public Methods
void setImage(int resId)
Sets the image.
void setImage(Image image)
Sets the image.
void setImageDisabled(int image)
Sets the disabled image.
void setImageDisabled(Image image)
void setImageFocused(Image image)
void setImageFocused(int image)
Sets the focused image.
void setImagePressed(Image image)
void setImagePressed(int image)
Sets the pressed image.
void setImageScaleType(int scaleType)
Set the scale type for the image contained into this button.
[Expand]
Inherited Methods
From class com.neomades.ui.View
From class java.lang.Object

XML Attributes

image

Res.image.XXXX or a color

Related Methods

imageDisabled

Res.image.XXXX or a color

Related Methods

imageFocused

Res.image.XXXX or a color

Related Methods

imagePressed

Res.image.XXXX or a color

Related Methods

Public Constructors

public ImageButton ()

public ImageButton (Image img)

Creates a new Button with only an image.

Parameters
img the image to display

public ImageButton (int resId)

Creates a new Button with only an image.

Parameters
resId the image to display

Public Methods

public void setImage (int resId)

Sets the image.

Related XML Attributes
Parameters
resId the image to show
Throws
CrossThreadException if this method call is done in the wrong Thread.
CrossThreadException if the method is called from outside the UI-Thread

public void setImage (Image image)

Sets the image.

Related XML Attributes
Parameters
image the image to show.
Throws
CrossThreadException if this method call is done in the wrong Thread.
CrossThreadException if the method is called from outside the UI-Thread

public void setImageDisabled (int image)

Sets the disabled image.

Related XML Attributes
Parameters
image the image to show when the button is disabled
Throws
CrossThreadException if this method call is done in the wrong Thread.
CrossThreadException if the method is called from outside the UI-Thread

public void setImageDisabled (Image image)

Related XML Attributes
Throws
CrossThreadException if this method call is done in the wrong Thread.
CrossThreadException if the method is called from outside the UI-Thread

public void setImageFocused (Image image)

Related XML Attributes
Throws
CrossThreadException if this method call is done in the wrong Thread.
CrossThreadException if the method is called from outside the UI-Thread

public void setImageFocused (int image)

Sets the focused image.

Related XML Attributes
Parameters
image the image to show when the button is focused
Throws
CrossThreadException if this method call is done in the wrong Thread.
CrossThreadException if the method is called from outside the UI-Thread

public void setImagePressed (Image image)

Related XML Attributes
Throws
CrossThreadException if this method call is done in the wrong Thread.
CrossThreadException if the method is called from outside the UI-Thread

public void setImagePressed (int image)

Sets the pressed image.

Related XML Attributes
Parameters
image the image to show when the button is pressed
Throws
CrossThreadException if this method call is done in the wrong Thread.
CrossThreadException if the method is called from outside the UI-Thread

public void setImageScaleType (int scaleType)

Set the scale type for the image contained into this button.

By default, the scale type is STRETCH.

Parameters
scaleType the scale type to apply to the image of the ImageButton
See Also