01-20-2011 07:12 AM
Hi guys i have a question ..
Iam using a picturescrollfield with some buttons below. I create this UI and want that a button is disabled when some criteria is fullfilled. So i make some code to put in the fieldchange and change the visual state to disabled if criteria is fullfilled. All this works fine.
But my Problem is when i create the ui, the buttons arent disabled. They are just disabled when i scroll and make the fieldchange begin. So i decided to put something like url_button.setVisualState(ButtonField.VISUAL_
Anybody knows why and how to change ?
08-30-2011 09:16 PM - edited 08-30-2011 10:27 PM
Good question, I am also confused with this matter, could you please give us a hint on that?
Bear in mind that I am using the default buttons provided. I have seen some workarounds by creating custom buttons, but I was wondeing if with the newer apis, it would be simpler to implement enable/disable functionality of a button.
08-31-2011 06:00 PM - edited 08-31-2011 06:01 PM
Using the setEditable method should achieve what you are looking for.
// Disable the button myButton.setEditable(false); // Enable the button myButton.setEditable(true);
The button will still be displayed on the UI, however, it will not be clickable, just disabled.
09-02-2011 05:15 PM
Glad I could help! Please mark the topic as solved by the way if my answer was sufficient.
As for setVisualState, the docs say:
public final void setVisualState(int visual)
Sets this field's current visual state, which can be subsequently accessed via Field.getVisualState().
Parameters: visual - One of the following visual states: Field.VISUAL_STATE_NORMAL, Field.VISUAL_STATE_ACTIVE,Field.VISUAL_STATE_FOCUS, Field.VISUAL_STATE_DISABLED, Field.VISUAL_STATE_DISABLED_FOCUS. Since: BlackBerry API 4.6.0
Looks like, from the states available, it allows you to directly choose a state of the field rather than letting the UI determine the correct state due to focus and editablilty. I haven't made use of this myself, so someone else please chime in if you have any insight. Russ.