I implemented a splashscreen and a mainpage for my BlackBerry app. On the splashscreen page I want to change the background color to black.
In the SplashScreen that you use
public class SplashScreen extends MainScreen {
public SplashScreen(){
getMainManager().setBackground(
BackgroundFactory.createSolidBackground(0x00000000);
);
}
}
You could do a couple things. You could call getDelegate().setBackground(BackgroundFactory.createSolidBackground(Color.BLACK)) or override the Screen's paint method to
protected void paint(Graphics graphics) {
int oldColor = graphics.getColor();
graphics.setColor(Color.BLACK);
graphics.clear();
graphics.setColor(oldColor);
super.paint(graphics);
}
Related
I have a custom ImageButton in which I have placed a png and the hover Image which is transparent from some parts. So when It gets focused it also takes it self with a blue focus. I want to remove that focus blue color but at the same time I want my hoverImage to work!
This is my ImageButton Class: http://codepad.org/mjtIUKLR
A solution that works for me is to add this functionality to the paint method and track whether focus has been gained:
boolean hasFocus = false;
public void onFocus(int direction) {
invalidate();
hasFocus = true;
}
public void onUnfocus() {
hasFocus = false;
invalidate();
super.onUnfocus();
}
And then use this in your paint method:
public void paint(Graphics graphics) {
if (hasFocus){
graphics.drawShadedFilledPath(xPositions, yPositions, null,
HIGHLIGHTED_GRADIENT, null);
}else{
graphics.drawShadedFilledPath(xPositions, yPositions, null,
GRADIENT, null);
}
super.paint(graphics);
}
In my example above, I am using a custom gradient for highlighting that overrides the default blue colour. In your case you will obviously want to change your image or something.
How can we change a font color while using Rich List in Blackberry.
final VerticalFieldManager vfm = new VerticalFieldManager(){
protected void paint(Graphics graphics){
graphics.setColor(0x36c9e3);
super.paint(graphics);
}
};
RichList list = new RichList(vfm, true,1, 2);
I am developing a blackberry app and I am new to Blackberry. I am using Label Field in every screens, but there is a color surrounding the LabelField other than the background I have given for the screen like the image I have given here..
This is a header in my App,which comes in every screens. Here you can see a white color around the "state editions". It does not look good. I want the orange background color at the place of white color. Thanks in advance...
You are using the following code.. (from your comment)
lF1= new LabelField("state editions",LabelField.FIELD_LEFT |FIELD_VCENTER) {
public void paint(Graphics graphics) {
graphics.clear();
graphics.setColor(Color.BLACK);
graphics.setBackgroundColor(Color.ORANGE); graphics.fillRect(0, 0,0, 0);
super.paint(graphics);
}
};
Try to modify this like the following:
lF1= new LabelField("state editions",LabelField.FIELD_LEFT |FIELD_VCENTER) {
public void paint(Graphics graphics) {
super.paint(graphics);
}
};
That means, you don't have to extend default LabelField.
Just use,
lF1= new LabelField("state editions",LabelField.FIELD_LEFT |FIELD_VCENTER);
And check the Graphics , graphics.clear() etc in the API.
I want to display an alert in every time when the user change the orientation of the mobile. There is a method to capture this mouvement?
I use Display.getOrientation();. But it always returns 32 in different orientation.
You get a call to sublayout() when orientation changes. You can save the displaywidth to a variable, and if the value has changed in sublayout() , you know the orientation has changed.
like this.
protected void sublayout(int width, int height) {
if(Display.getWidth()==oldWidth)
{
//no change
}
else
{
// orientation changed
}
oldWidth = Display.getWidth();
super.sublayout(width, height);
}
Note: when you check orientation you have to close SLIDER in 9800 simulator other wise it wont work
try following code :
public class checkOrientation
{
VerticalFieldManager manager;int ori;
public checkOrientation()
{
ori=Display.getOrientation();
manager=new VerticalFieldManager()
{
protected void sublayout(int maxWidth, int maxHeight) {
super.sublayout(Display.getWidth(),Display.getHeight());
setExtent(Display.getWidth(),Display.getHeight());
if(ori!=Display.getOrientation()){
UiApplication.getUiApplication().invokeLater(new Runnable() {
public void run() {
ori=Display.getOrientation();
Dialog.inform(""+Display.getOrientation());
}
});
}
}
};
add(manager);
}
}
How do I remove default BLUE focus color in Blackberry? I have one bitmap field and it is focusable. When I click on that image, transparent portion of that image focus with BLUE color and I want to remove that.
This is a method by which you can remove the default color of focus. If you want to set your own color then you need to give body.
protected void drawFocus(Graphics paramGraphics,boolean paramBoolean)
{
//...
}
You can Try the follwing code
Bitmap b = Bitmap.getBitmapResource("test.png"){
protected void onFocus(int direction)
{
backgroundColour = highlightColour;
invalidate();
}
protected void onUnfocus()
{
backgroundColour = Color.GRAY;
invalidate();
}
protected void paint(Graphics graphics)
{
graphics.setColor(backgroundColour);
}
}