¿Cómo puedo manejar un evento de clic cuando un usuario haga clic en un campo de memoria de imagen?

StackOverflow https://stackoverflow.com/questions/3771016

  •  04-10-2019
  •  | 
  •  

Pregunta

Esta es mi clase, muy simple:

public class SelectYesNoArea extends Manager {

    BitmapField yes;
    BitmapField no;
    DateField date;
    Calendar cal;

    public SelectYesNoArea(long style){
        super(style);           

        Bitmap bgPic = Bitmap.getBitmapResource("divBackgrounds.png");
        Background bg = BackgroundFactory.createBitmapBackground(bgPic);
        setBackground(bg);

        cal = Calendar.getInstance();               
        date = new DateField("",cal.getTime().getTime(), DateFormat.DATE_SHORT);
        add(date);

        Bitmap bitYes = Bitmap.getBitmapResource("yes.png");
        yes = new BitmapField(bitYes);
        add(yes);

        Bitmap bitNo = Bitmap.getBitmapResource("no.png");
        no = new BitmapField(bitNo);
        add(no);
    }   
}

Sólo quiero manejar cuando un par de toques de usuario en el bitmapField. ¿Cómo puedo hacer esto?

¿Fue útil?

Solución

Usar una clase anónima:

yes = new BitmapField(bitYes) {
    trackwheelClick(int status, int time) {
        Do whatever you want here !
    }
}

Otros consejos

Trate de usar el estilo Field.FOCUSABLE al crear su BitmapField.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top