Welcome!

Welcome to the Official BlackBerry Support Community Forums. This is your resource to discuss support topics with your peers, and learn from each other. New to the forum? Please visit the ‘Getting Started’ link below.
inside custom component

Java Development

Reply
Developer
nish1013
Posts: 246
Registered: ‎08-14-2010

custom field visual state

Hi , 

 

I am using follwoing code to draw different image according to visual state 

 

switch (state) {
		case Field.VISUAL_STATE_ACTIVE:
			foregroundImageIndex = 3;

			break;
		case Field.VISUAL_STATE_FOCUS:

			foregroundImageIndex = 1;

			break;
		case Field.VISUAL_STATE_NORMAL:

			foregroundImageIndex = 0;

			break;
		case Field.VISUAL_STATE_DISABLED:
			foregroundImageIndex = 2;
			break;
		case Field.VISUAL_STATE_DISABLED_FOCUS:
			foregroundImageIndex = 2;
			break;
		}

 Focus and enable status work fine, but when I create a pulic disable method and change the status then call invalidate() does not give the right draw.

 

What could go wrong ? as well as how can I set backfround for four status ? I using following code in constructor 

setBackground(VISUAL_STATE_FOCUS,
				BackgroundFactory.createBitmapBackground(
						focucedBitmapBackground, 0, 0,
						Background.REPEAT_SCALE_TO_FIT));
		setBackground(VISUAL_STATE_ACTIVE,
				BackgroundFactory.createBitmapBackground(
						pressedBitmapBackground, 0, 0,
						Background.REPEAT_SCALE_TO_FIT));
		setBackground(VISUAL_STATE_NORMAL,
				BackgroundFactory.createBitmapBackground(
						enabeldBitmapBackground, 0, 0,
						Background.REPEAT_SCALE_TO_FIT));
		setBackground(VISUAL_STATE_DISABLED,
				BackgroundFactory.createBitmapBackground(
						disabledBitmapBackground, 0, 0,
						Background.REPEAT_SCALE_TO_FIT));

 

 

any help will be highly appriciated .

Please use plain text.