views:

36

answers:

1

Hi friends i am working BitmapField in blackberry

I implemented my class with FieldChangeListener and add FieldChangeListener method in my class and even add setChangeListner to that particular Bitmap Field, But it is not responding with click event on it..

plz give u r valuable solutions to add clickevent to BitmapField

thanks in advance

A: 

First, BitmapField is not focusable by default, so you'll need to subclass and override isFocusable to fix that. Then override navigationclick to fire a fieldChanged event. Code snippet for a minimum field:

import net.rim.device.api.ui.component.BitmapField;

public class ClickableBitmapField extends BitmapField {
    public boolean isFocusable() {
        return true;
    }

    protected boolean navigationClick(int status, int time) {
        fieldChangeNotify(0);
        return true;
    }
}

In addition to this, you may want to provide some indication of when your field is in focus (unless you only care about touch-screen devices). The default implementation will just draw a highlight on any transparent areas of your bitmap. You can change this by overriding drawFocus, and maybe onFocus and onUnfocus to change the bitmap you display when the focus state changes.

Anthony Rizk