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
Highlighted
Trusted Contributor
Posts: 200
Registered: ‎02-22-2010
My Device: BlackBerry 9550
My Carrier: Airtel
Accepted Solution

bitmap erases as i scroll in listfield and doesnt repaints

hi all,

       i am trying to use a single bitmap for the listfield which has 10 list (say). i'm trying to place bitmap b4 it but it just erases as the user scrolls and then doesnt repaints. plz help me find solution.

 

public MyCallback()
	{
		dest = new XYRect(5,5,20,20);	
		bitmap = Bitmap.getBitmapResource("icon_select.png");
	}
	

	public void drawListRow(ListField listField, Graphics graphics, int index,
			int y, int width)
	{
		String text = (String) list.elementAt(index);	
		dest.y+=15;	
		graphics.drawBitmap(dest, bitmap, 0, 0);	
		graphics.drawText(text,25, y+3,0,width);		
	}

 also how can make this bitmap appear as it is b4 every name i have.

 

1702iB363DFBE74A22FDD

this is b4 the scroll. and after scroll it looks like.

 

1703i50D129FE2D30A778

plz help me find solution

Swapnil G.
Developer
Posts: 190
Registered: ‎10-22-2009
My Device: Blackberry Torch

Re: bitmap erases as i scroll in listfield and doesnt repaints

both images are same.

wats the problem is image getting disappear on scroll?

-----------------------------------------------------------------------------------
Please mark posts as solved if you found a solution. Press the kudos button to thank the user who helped you.
Developer
Posts: 16,999
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: bitmap erases as i scroll in listfield and doesnt repaints

you do not use the y parameter in drawBitmap. this means your bitmap is painted always to the same place.

----------------------------------------------------------
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
Trusted Contributor
Posts: 200
Registered: ‎02-22-2010
My Device: BlackBerry 9550
My Carrier: Airtel

Re: bitmap erases as i scroll in listfield and doesnt repaints

yes both the images are the same. while scrolling it get disappear so completly

Swapnil G.
Developer
Posts: 16,999
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: bitmap erases as i scroll in listfield and doesnt repaints

use the y parameter you get in the drawListRow call

----------------------------------------------------------
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
Developer
Posts: 190
Registered: ‎10-22-2009
My Device: Blackberry Torch

Re: bitmap erases as i scroll in listfield and doesnt repaints

use dest .y += y+15

-----------------------------------------------------------------------------------
Please mark posts as solved if you found a solution. Press the kudos button to thank the user who helped you.
Developer
Posts: 190
Registered: ‎10-22-2009
My Device: Blackberry Torch

Re: bitmap erases as i scroll in listfield and doesnt repaints

u may have missed out on y parameter in function parameter as said by simon,

u can do something like

 

dest.y=y+15

 

-----------------------------------------------------------------------------------
Please mark posts as solved if you found a solution. Press the kudos button to thank the user who helped you.
Trusted Contributor
Posts: 200
Registered: ‎02-22-2010
My Device: BlackBerry 9550
My Carrier: Airtel

Re: bitmap erases as i scroll in listfield and doesnt repaints

guys, my problem is when i scrol my images get disappeared completely. and doesnt paints.

Swapnil G.
Developer
Posts: 190
Registered: ‎10-22-2009
My Device: Blackberry Torch

Re: bitmap erases as i scroll in listfield and doesnt repaints

u mean when u focus and unfocus the individual row.

If that is problem then watch for drawFocus, u may try to call inavalidate inside it..

 

can u post a more extensive snippet

 

-----------------------------------------------------------------------------------
Please mark posts as solved if you found a solution. Press the kudos button to thank the user who helped you.
Developer
Posts: 16,999
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: bitmap erases as i scroll in listfield and doesnt repaints

example:

row 1 has y of 0

row2 has y of 10

row n has y of 500

 

when you scroll down your row1 is no longer visible.

as you paint the picture on y = 0 all the time the picture is also no longer visible.

if you do not use the y parameter everything is painted on the same place, and this place is scrolled away.

 

just use the y parameter...

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