Reputation: 33
How to make a blackberry BitmapField
non-focusable in runtime? I want make it dimmed based on a certain event.
Upvotes: 1
Views: 94
Reputation: 28168
Most of times this works:
field.setEditable(false);
You can also create a non-focusable field by passing the style flag Field.NON_FOCUSABLE
or Field.FOCUSABLE
to the constructor, but once instantiated you cannot change it's focusable state. Even if you could, then the field won't look "dimmed" or "disabled", but simply the focus will jump to the next focusable field after it. An example of this are non-focusable label fields.
UPDATE: This would work for built in fields like EditFields, Checkbox, RadioButtons, etc. In your case, this does not work since a BitmapField is not "editable", it's a read only field. You can make a trick like @adwiv answer shows, but the "disabled" or gray overlay you'll have to implement it yourself.
Upvotes: 1
Reputation: 1266
Extend the BitmapField to override the isFocusable()
method like this:
public class FocusableBitmapField extends BitmapField {
//Default value depending on whether you want it that way.
private boolean focusable = true;
public boolean isFocusable() {
return focusable;
}
public boolean setFocusable(boolean focusable) {
this.focusable = focusable;
}
}
Upvotes: 1