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.
08-26-2013 05:18 AM
On to the second part of my previous post then:
"Now create a special attribute - a Bitmap - for the HFM. Add a special method to set this Bitmap - say called setForegroundImage(). Once you have sorted out how to do that, then override the paint() method for this manager, and in your overridden method, caller super.paint() which will paint your background image, then use drawBitmap to paint the special Bitmap. To make sure you are painting this in the correct place, you will need to base the position of the Bitmap on the horizontalScroll position of the HFM. "
The trick, or workaround that I am proposing, is that you do not actually have a background and foreground image, in the usual meaning of the words. What you are doing is painting over the top of a HorizontalFieldManager. You can use this technique to achieve other things if you want.
And note one complication here is that you need to factor in the horizontal scroll position for the HFM.
Finally, two other points:
a) I have been told that Display.getHeight() and Display.getWidth() are complicated operations, so I would something like:
int displayHeight = Display.getHeight();
int displayWidth = Display.getWidth();
and then use these variables rather than invoking the Display method.
b) If someone tilts (turns sideways) the device once you have sized your background images, are you going to resize them?
08-26-2013 05:33 AM - edited 08-26-2013 07:35 AM
When you create a new class in Java, this class will extend another class, and add additional features or attributes to the class it is extending.
In this case, you are extending HFM, and the special attribute you are adding is the ability to specify a foreground image.
So you are creating a new Object, which you might call ForegroundImageHFM, and this extends HorizontalFieldManager.
This is standard Java, not special to BlackBerry.
08-26-2013 05:33 AM
If in the paint method i am directly giving the image that i want to add on the backgroundImage, then i am getting the image only on the 1st background image.
manager1 = new HorizontalFieldManager()
protected void paint(Graphics graphics)
graphics.drawBitmap(0, 0, displayWidth,displayHeight, resize5, 0, 0);
08-26-2013 05:38 AM
Can you please, please, please read everything and make sure that you understand it. Read everything. Ask for clarification if you don't understand. But read everything.
Once you have read everything, do everything. Not just the first bit, not just the bit until it breaks. Everything you can.
It is really really frustrating when I write something as carefully as I can, explaining all the steps, and then you read some of it, do even less, and then ask why it is not working.
08-26-2013 06:04 AM - edited 08-26-2013 07:29 AM
The posts you have not completed are
which was repeated here:
and read this:
I am not going to apologize for going on at you. We have been round exactly this sort of loop before.
08-26-2013 06:04 AM
Hi this is interseting . i am also tryng this.
So to set the image over the background image we have to do like this??
Create class ForegroundImageHFM that extends HFM and it contains a static method
public static Bitmap setForegroundImage()
Bitmap image= Bitmap.getBitmapResource("IMage1.png");
and we have to set this image to the screen that is extending the mainscreen class as
HFM m1= new HFM()
Sorry for my bad english.
08-26-2013 06:54 AM - edited 08-26-2013 04:39 PM
@rahul0108 - I presume you are working with vaishali28?
I apologise for dragging this out.
I could have written this for you in less time that it took me to write the first post on this Thread. But that is not the point of the forum. The point of the forum is to explain and resolve problems, not provide cut and paste code. Your job as a programmer is understand the code you are writing. Cut/paste code does not help with that.
In addition, I also said this was a workaround to achieve the effect required with as little work as possible. It may not work for you. If you understand the code, then you will understand its restrictions and implications, so you can make that decision and/or tailor the code.
So forgive me for trying to lead you, rather than tell you.
I appreciate there are many, in fact I would say most, people on the forum for whom English is not their first language. That is why I spend a great deal of time trying to make sure that what I say is as clear as possible, and I spell check and re check. And revise and correct, as has happened on this Thread. So if I say something you don't understand, please ask for clarification. But remember I expect you to know Java and have read the APIs, this is is not the right place to learn Java, nor does it replace or repeat the official documentation for the BlackBerry API.
Now to answer your question:
"So to set the image over the background image we have to do like this??....."
You don't have to - this is just one option, there are others. This option is simple and allows for a scrolling HFM as a background, which is what I thought you were trying to achieve.
The code you pasted is pretty much what vaishali28 posted earlier. You both have missed a step in what i suggested you needed to do. Specifically you have not factored in the scroll. Please review the JavaDoc for HFM (actually Manager in general) looking to find out the Manager's current horizonalt scroll position. Then figure out where you need to paint the Bitmap in relation to that.
Edited for clarity and make the post more positive as was intended rather than the negative way it read.