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

Reply
Developer
peter_strange
Posts: 19,599
Registered: ‎07-14-2008
My Device: Not Specified

Re: Problem in screen transition

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?

Please use plain text.
Forums Advisor I
vaishali28
Posts: 501
Registered: ‎03-01-2013
My Device: BlackBerry Z10

Re: Problem in screen transition

Sir what do you mean by saying special attribute??

Please use plain text.
Developer
peter_strange
Posts: 19,599
Registered: ‎07-14-2008
My Device: Not Specified

Re: Problem in screen transition

[ Edited ]

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. 

Please use plain text.
Forums Advisor I
vaishali28
Posts: 501
Registered: ‎03-01-2013
My Device: BlackBerry Z10

Re: Problem in screen transition

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)
            {
                super.paint(graphics);
                graphics.drawBitmap(0, 0, displayWidth,displayHeight, resize5, 0, 0);
            }
        };

Please use plain text.
Developer
peter_strange
Posts: 19,599
Registered: ‎07-14-2008
My Device: Not Specified

Re: Problem in screen transition

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. 

Please use plain text.
Forums Advisor I
vaishali28
Posts: 501
Registered: ‎03-01-2013
My Device: BlackBerry Z10

Re: Problem in screen transition

Sorry i have posted before reading the your reply.

Please use plain text.
Developer
peter_strange
Posts: 19,599
Registered: ‎07-14-2008
My Device: Not Specified

Re: Problem in screen transition

[ Edited ]
Please use plain text.
Contributor
rahul0108
Posts: 30
Registered: ‎04-13-2013
My Device: blackberry bold
My Carrier: developer

Re: Problem in screen transition

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");
return image;
}

 

and we have to set this image to the screen that is extending the mainscreen class as

 HFM m1= new HFM()

{

paint()

{

super.paint();

g.drawBitmap(0,0,100,100,ForegroundImageHFM .setForegroundImage(),0,0);

}

};

 

 

Sorry for my bad english.

Please use plain text.
Developer
peter_strange
Posts: 19,599
Registered: ‎07-14-2008
My Device: Not Specified

Re: Problem in screen transition

[ Edited ]

@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. 

Please use plain text.
Forums Advisor I
vaishali28
Posts: 501
Registered: ‎03-01-2013
My Device: BlackBerry Z10

Re: Problem in screen transition

I just want to ask 1 thing, what is factored in scroll field.

Please use plain text.