Blackberry Field.VISUAL_STATE_NORMAL
I am trying to create a control equivalent to the UISegmentedControl on the iPhone, which would be three buttons that act as like radio buttons. The idea is when one is selected it is disabled, and has a different visual style.
The buttons are subclassed from Field directly in order to get the required visual style, and they grouped inside a custom GridFieldManager.
The issue is when clicked, the buttons behave as expected, but as soon as focus is moved, the buttons revert to Field.Visual_STATE_NORMAL (evidenced by console output). The only customization to the containing GridFieldManager is a couple loops to determine focus in other areas where that manager is used.
The buttons are initialized as follows:
private void init() {
this.setBackground( Field.VISUAL_STATE_NORMAL, BackgroundFactory.createLinearGradientBackground(0xfc9b68, 0Xfc9b68, 0xff5800, 0xff5800) );
this.setBackground( Field.VISUAL_STATE_DISABLED, BackgroundFactory.createLinearGradientBackground(0xe78568, 0xff5800, 0xd53000, 0xd53000) );
this.setBackground( Field.VISUAL_STATE_FOCUS, BackgroundFactory.createLinearGradientBackground(0xd8d8d8, 0xd8d8d8, 0x0000000, 0x000000) );
}
The i开发者_如何学Cssues is that somehow, the visual state for each button is being reset. In short, the client wants a Blackberry application that looks and behaves exactly like an iPhone or Android application. Any ideas on how this could happen would be greatly appreciated.
The fix I found for this was to add a flag to track if the Field was selected or selected or not, which is set and unset in the MainScreen. Based on that flag, the visual state is updated as needed during every repaint.
精彩评论