Code:
public class EscaladosButton extends Field {
private TarifaDTO tarifa;
private Bitmap button;
private Bitmap on;
private Bitmap off;
private int fieldHeight;
public EscaladosButton(TarifaDTO tarifa) {
super(Manager.FOCUSABLE);
on = Bitmap.getBitmapResource("escalados_icon.jpg");
off = Bitmap.getBitmapResource("escalados_icon.jpg");
fieldHeight = on.getHeight();
this.tarifa = tarifa;
button = off;
invalidate();
}
public EscaladosButton() {
super(Field.FOCUSABLE);
button = off;
}
protected void onFocus(int arg0) {
button = on;
super.onFocus(arg0);
}
protected void onUnfocus() {
button = off;
super.onUnfocus();
}
protected void drawFocus(Graphics g, boolean arg1) {
g.drawBitmap(0, 0, 0, fieldHeight, button, 0, 0);
}
protected void paint(Graphics arg0) {
arg0.drawBitmap(0, 0, 0, fieldHeight, button, 0, 0);
}
public TarifaDTO getTarifa() {
return tarifa;
}
public void setTarifa(TarifaDTO tarifa) {
this.tarifa = tarifa;
}
protected void layout(int arg0, int arg1) {
// TODO Auto-generated method stub
}
}
Here is my code.