Buttons In Blackberry - blackberry

I want to create a screen in which there is an image in the background and in the foreground there are two centered buttons.
When either of the buttons are clicked, I want to display new screens.
I am able to create the buttons only -- the rest I am unable to complete.

RIM offers an extensive set of Development Guides that are a good start.

You need to have a field manager to cover the entire screen. and in the paint method of that manager you need to draw the background image of entire screen size then call super.Paint()
after that you can add two buttons on the same manager.
final Bitmap bodyBG = Bitmap.getBitmapResource("body"+ApplicationUtil.getInstance().getScreenResolution()+".png");
VerticalFieldManager pannel = new VerticalFieldManager(VerticalFieldManager.VERTICAL_SCROLL){
protected void sublayout(int maxWidth, int maxHeight) {
// TODO Auto-generated method stub
super.sublayout(Display.getWidth(), Display.getHeight());
setExtent(Display.getWidth(), Display.getHeight());
}
protected void paint(Graphics graphics) {
// TODO Auto-generated method stub
graphics.clear();
graphics.drawBitmap(0,0,bodyBG.getWidth(), bodyBG.getHeight(), bodyBG, 0, 0);
super.paint(graphics);
}
};
now add buttons on pannel

Related

how to improve autosuggest/complete in blackberry + java

I am facing lot of issues while implement the auto suggest :I will tell you my issues .
1) Focus is always comes on auto suggest /complete field.First there is button .But focus is also on autosuggest field as shown in figure
2) When I write m on auto suggest field monday is display when I click the track pad it display monday on autosuggest field But Monday of pop up is not hide.
3) what is this encircle .How to change is gray color (or remove this color).some times it display on whole field and some time on half field
4) I just want a auto suggest with fix width not whole width .Like this on a screen with black background and autosuggest (edit field have white background no gray when focus comes on auto suggest)
Example
Label Auto suggest
Days Auto-complete of days
public final class MyScreen extends MainScreen implements JsonObserver
{
/**
* Creates a new MyScreen object
*/
public MyScreen()
{
// Set the displayed title of the screen
setTitle("Drop-down List Demo");
VerticalFieldManager vfm=new VerticalFieldManager(){
protected void sublayout(int maxWidth, int maxHeight) {
// TODO Auto-generated method stub
super.sublayout(maxWidth, maxHeight);
setExtent(maxWidth, maxHeight/2);
}
protected void paint(Graphics graphics) {
// TODO Auto-generated method stub
graphics.setColor(Color.BLACK);
graphics.fillRect(0, 0, Display.getWidth(), Display.getHeight()/2);
super.paint(graphics);
}
};
vfm.add(new ButtonField("add"));
BasicFilteredList filterList = new BasicFilteredList();
String[] days = {"Monday","Tuesday","Wednesday",
"Thursday","Friday","Saturday","Sunday"};
filterList.addDataSet(1,days,"days",BasicFilteredList.COMPARISON_IGNORE_CASE);
AutoCompleteField autoCompleteField = new AutoCompleteField(filterList);
vfm.add(autoCompleteField);
vfm.add(new ButtonField("addpppp"));
add(vfm);
}
}

Blackberry VerticalfieldManager virtual scroll view size too large

Developing on the blackberry (OS 7.0) and I have an extended Vertical Field manager created as such:
_myVFM = new MyViewManager(Manager.USE_ALL_WIDTH | Manager.USE_ALL_HEIGHT | Manager.VERTICAL_SCROLL){};
However, when I scroll the view, the virtual scroll view size appears way too big.
i.e, I can scroll quite alot further down than is needed and I cant work out why?
Any body any quick ideas? I do have a background image in there that is created as such:
public void paint(Graphics graphics)
{
Bitmap backgroundBitmap = Bitmap.getBitmapResource("bg.png");
Bitmap newBackground = new Bitmap(Display.getWidth(), Display.getHeight());
backgroundBitmap.scaleInto(newBackground, Bitmap.FILTER_LANCZOS, Bitmap.SCALE_TO_FILL);
graphics.clear();
graphics.drawBitmap(0, 0, Display.getWidth(),
Display.getHeight(), newBackground, 0, 0);
super.paint(graphics);
}
Please and thanks,
Burrows
You can redefine the method to define the height of the manager
protected void setExtent(int width, int height) {
super.setExtent(width, myHeight);
}
To not repeat the background image is necessary to redefine the following method, returning false
protected boolean isScrollCopyable() {
return false;
}
Another comment is that it is a bad practice to obtain an image from the paint method. What you are doing is every time you call the paint method is going to get this image.
It's best to get the image once and then use it.
public MyScreen() {
super(NO_VERTICAL_SCROLL);
I managed to fix the issue in my extension of MainScreen using 'NO_VERTICAL_SCROLL' style parameter
Combined with Rupak's suggestion of setting the Background in the constructor of my Vertical Field Manager rather than overriding paint (
https://gist.github.com/3248319)
everything seems Good now - thanks all for your help.
Burrows
No need to USE_ALL_HEIGHT in your constructor.
// instead use this
_myVFM = new MyViewManager(Manager.USE_ALL_WIDTH | Manager.VERTICAL_SCROLL){};

How to remove white color around Labelfield in Blackberry

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.

BlackBerry textfield

I am trying to develop an application in which text is displayed on a background image.
Text must be displayed on an image and when the background image is changed text also must change.
To achive above requirement first you need to set Background image for your MainScreen for this there are more methods one is to override paint method of MainScreen.
Example code:
Bitmap screen1=Bitmap.getBitmapResource("Screen_1.jpg");
public void paint(Graphics graphics)
{
graphics.drawBitmap(0, 0, Display.getWidth(), Display.getHeight(),screen1, 0, 0);
super.paint(graphics);
}
};
After setting background image for screen you need to add LabelField or RichTextField to screen.
Example:
LabelField lf=new LabelField("text",Field.USE_ALL_WIDTH|DrawStyle.HCENTER);
add(lf);
When you need to change Backgound image set.
screen1=Bitmap.getBitmapResource("you image.jpg");
lf.setText("your labelfield text");
invalidate();
Hope this will help you.

please tell me how i can paint the whole screen in a rimlet?

i am developing a blackberry app. i want to paint the screen. i have implemented this
VerticalFieldManager hfmBg = new VerticalFieldManager(Field.USE_ALL_HEIGHT )
{
protected void paint(Graphics g)
{
g.setBackgroundColor(Color.SILVER);
g.clear();
super.paint(g);
}//end of paint method
};//end of vertical field manager
but tell me is there any other approach to paint the whole screen?
You have the right idea - just put that paint method in your Screen (MainScreen or FullScreen) class instead of your Manager class. You may also have to add the following empty method to your Screen class to override themes that set the default colors:
protected void applyTheme() {
}

Resources