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.

inside custom component

Java Development


Thank you for visiting the BlackBerry Support Community Forums.

BlackBerry will be closing the BlackBerry Support Community Forums Device Forums on April 1st (Developers, see below)

BlackBerry remains committed to providing excellent customer support to our customers. We are delighted to direct you to the CrackBerry Forums, a well-established and thorough support channel, for continued BlackBerry support. Please visit http://forums.crackberry.com or http://crackberry.com/ask. You can also continue to visit BlackBerry Support or the BlackBerry Knowledge Base for official support options available for your BlackBerry Smartphone.

"When we launched CrackBerry.com 10 years ago, we set out to make it a fun and useful destination where BlackBerry Smartphone owners could share their excitement and learn to unleash the full potential of their BlackBerry. A decade later, the CrackBerry community is as active and passionate as ever and I know our knowledgeable members and volunteers will be excited to welcome and assist more BlackBerry owners with their questions."

- Kevin Michaluk, Founder, CrackBerry.com

Developers, for more information about the BlackBerry Developer Community please review Join the Conversation on the BlackBerry Developer Community Forums found on Inside BlackBerry.


Reply
Developer
Posts: 55
Registered: ‎02-08-2010
My Device: Blackberry Bold
My Carrier: Verizon
Accepted Solution

ListField setting background + transparency.

[ Edited ]

Hi,

 

Is there some way to make components like ListFields translucent? (not sure if that's the right term when talking about UIs)


Thanks,

Teja.

 

Edit: Elaborating a bit..

 

1. I have a ListField that I want to set a white background to. How do I do this? I'm already implementing ListFieldCallBack and have the drawListRow overridden. I've tried to do g.setBackground(Color.WHITE), but this doesn't seem to work..

 

Edit2: Tried overriding paintBackground() and using g.setBackground there. Still doesn't work.

 

2. Then I'd like to increase the transparency of the ListField's rows so that the screen background is visible. I was going through the methods in the graphics class, and tried g.setGlobalAlpha(100), but that doesn't seem to work.

 

Thanks again,

Teja.

Developer
Posts: 1,041
Registered: ‎07-16-2008
My Device: ಠ_ಠ

Re: ListField setting background + transparency.

Are you calling Graphics#clear() after you set the background color?

 

Graphics#setBackgroundColor() affects Graphics#clear().

Graphics#setColor() affects Graphics.draw*().

Developer
Posts: 55
Registered: ‎02-08-2010
My Device: Blackberry Bold
My Carrier: Verizon

Re: ListField setting background + transparency.

Thanks, g.clear() is letting me set the background color.

 

I now have a VerticalFieldManager to which I added a jpeg as a screen background. I need to increase the transparency of the Field to make it show the screen background. My current code -

 

 

add(login = new EditField("Username:","") {
    protected void paintBackground(Graphics g) {
	g.setBackgroundColor(Color.WHITE);
	g.clear();
	g.setGlobalAlpha(100);
	super.paintBackground(g);
    } 
});

Add method - 

 

public void add(Field field) {
    objManager.add(field);
}

 

 

g.setGlobalAlpha is making the text "look" transparent - some shade between black and white, but the background color doesn't change at all.

 

Help?


Thanks,

Teja.

Highlighted
Developer
Posts: 55
Registered: ‎02-08-2010
My Device: Blackberry Bold
My Carrier: Verizon

Re: ListField setting background + transparency.

[ Edited ]

Whoops, had to put setGlobalAlpha before setting the background. This works, but it makes the text transparent too. Is it possible to make the text look solid and make just the background transparent?

 

 

add(login = new EditField("Username:","") {
	protected void paintBackground(Graphics g) {
		g.setGlobalAlpha(100);
		g.setBackgroundColor(Color.WHITE);
		g.clear();
		super.paintBackground(g);
	}
});

 

Thanks,

Teja.

 

Edit: Overriding the draw* method and settingGlobalAlpha back to 255 before drawing text works.