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
Regular Contributor
BB_Developement
Posts: 75
Registered: ‎03-22-2013
My Carrier: Blackberry
Accepted Solution

Custom dropdown image not shown proper on Blackberry simulator 9000

[ Edited ]

Hello,

I have created custom dropdown in my code. my code works proper for other simulators.

But when i tried to run on Blackberry simulator 9000 the image of dropdown not shown proper it cuts as half of image.

I check my code i have not manually set height for dropdown .

Please any one tell me why image is not shown proper on simulator 9000.

 

Please use plain text.
Developer
simon_hain
Posts: 15,558
Registered: ‎07-29-2008
My Carrier: O2 Germany

Re: Custom dropdown image not shown proper on Blackberry simulator 9000

not without your code, i guess. crystal ball is all cloudy.
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Please use plain text.
Developer
peter_strange
Posts: 19,513
Registered: ‎07-14-2008

Re: Custom dropdown image not shown proper on Blackberry simulator 9000

Welcome to the forums. 

 

I am guessing that you don't know how to use the Code insert button.  If you look at the top of the Edit Window, you will see a number of formatting options like Font.  Look to the right and there are two buttons, one of which is used to insert code.  Hover over the buttons and you will see a description.  Press the Insert Code button, add your code, and you will see something like the following:

 

    public void drawListRow(ListField list, Graphics g, int index, int y, int w) {
    	Bitmap bitmap = Bitmap.getBitmapResource(arrowBitmapName);
    	int fontWidth = getFont().getAdvance(text);
    	int width = Display.getWidth() ;
    	int height = list.getRowHeight();
    	g.setColor(Color.BLACK); g.setFont(fontPlain);
    	g.drawBitmap(0,0, bitmap.getWidth(), bitmap.getHeight(), bitmap, 0, 0);
    	g.drawText(text, 3, y-drptextHeight, 0, w);
    }

I think this is the routine you use to draw each line of your drop down..

 

Can I recommend that you move as much code as you can out of this method.  It is called very frequently.  So creating a Butmap in here, which is quite an expensive operation, is not a good idea, especially when the Bitmap actually does not change.  So create it once and use it in the drawListRow.

 

Also use the parameters that are passed in.  The width you have to paint is given in the parameter, and may not be the same as the actual Display width. 

 

Anyway, this code draws the Bitmap at (0, 0).  I susspect it should be drawn at (0, y).  This might explain why it is not drawn properly.  You seem to have a similar problem with the text.

 

The drawListRow is given a 'y' value and is expected to paint from y to y + listField.getRowHeight().  But in fact drawListRow has access to the entire paint area, so can do other things as well.  You need to code your method correctly to get the right results in your List.

 

Hope this helps, otherwise, please post your code so we can actually read it.  Actually, as I say to other people, don't post your real code.  Create a simple example that we can run that demonstrates your problem.  Then any one can run your sample and see the problem.  Never paste all your code.  People are put off by many lines of code. 

 

Please use plain text.