java me - how to disable the button using bitmapbuttonfield in advanced ui examples in blackberry -


I am using bitmap button fields in advanced UI instances. By default, any method is unable to disable the button in 5.0 JR, so I've added the code below to disable it and then disabling the functionality of the button, but setchangelistener is not working Which is my problem .. here is my code which I put to close the add button .. check Do I need to change anything in the in-action action method?

  Public Boolean Disable () {Return is Disabled; } Public Zero Set Disable (Boolean is disabled) {this.isDisable = isDisable; Invalid (); } Public Boolean Focus is Eligible () {Return is Focus & amp; ! IsDisable; } Public Zero Set Focusable (Boolean Focus is Eligible) {this.isFocusable = isFocusable; } Protected Boolean invokeAction (int operation) {if (Is! IsDisable) {fieldChangeNotify (0); } Back true; } Public Boolean set enabled () {return false; }  

Here's one.

In fact, using the field objects on isEditable () objects, because there are some similar concepts due to being capable and capable, if you are actually Want to disable separately in () code, it's okay. Just use the place where I use (edit) (remember to reverse boolean ... it is always a reason to program in positive ... make your way is Enabled () instead of isDisabled () ).

Therefore, instead of any of the above codes, I will just add this code to BitMapButtonFilled , or BaseButtonField :

  Public Boolean Focus is Lable () {Return is Editing () & amp; Super.isFocusable (); }  

and in Bitmapbuttonfield

  protected zero color (graphics ) {Int olderAlpha = g.getGlobalAlpha (); Int Index = G. Drilling styling (graphics. DRAWSTYLE_FOCUS)? Meditation: Normal; If (! Ejective ()) {g.setGlobalAlpha (100); // alpha is 0 to 255, so it is 100/255} g.drawBitmap (0, 0, _bitmaps [index] .getWidth (), _bitmaps [index] .getHeight (), _bitmaps [index], 0, 0) ; G.setGlobalAlpha (oldAlpha); }  

And after that, I can set a change listener, or disable the button, such as in my manager category:

  Bitmapbuttonfield BTN = new BitMapbuttonfield (bitmap.get MAPRSOS (" button. "), Bitmap.getbitmapRSOSSRS (" button-BTPP "); Btn.setChangeListener (New Field Change Listener) {Public Zero Field changed (field field, int reference) {Dialog.alert (clicked "button!"}}}}); Btn.setEditable (wrong); // Disables adding this button (BTN);  

But, understand that if you mean the disable button, it means that your change listener will not be able to call it how to work The change is called the listener only when the button is enabled and therefore clickable.

Also, note that when the disabled (when the editable ) button looks different, I override the paint () button is disabled To set a different alpha value You have not mentioned this, so if you do not like it, you can definitely remove it.


Comments

Popular posts from this blog

Python SQLAlchemy:AttributeError: Neither 'Column' object nor 'Comparator' object has an attribute 'schema' -

java - How not to audit a join table and related entities using Hibernate Envers? -

mongodb - CakePHP paginator ignoring order, but only for certain values -