开发者

How can I handle a click even when a user click on a BitMapField?

开发者 https://www.devze.com 2023-01-17 08:12 出处:网络
Here is my class, very simple: public class SelectYesNoArea extends Manager { BitmapField yes; BitmapField no;

Here is my class, very 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);
    }   
}

I just want to handle when a user taps on the bitmapField. H开发者_开发知识库ow can I do this?


Use an anonymous class:

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


Try using the Field.FOCUSABLE style when creating your BitmapField.

0

精彩评论

暂无评论...
验证码 换一张
取 消