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

Native Development

Posts: 1,638
Registered: ‎07-14-2008
My Device: Z10
My Carrier: Fido

How to set external picture for ImageButton?

I have a ImageButton and want to set a external image for the defaultImage.


I'm able to set the default image if I reference it from the asset folder but not externally.


// this works



// this does not.  I also tried adding file:/// to the url and it doesn't work






Regular Contributor
Posts: 76
Registered: ‎07-31-2012
My Device: Blackberry
My Carrier: Vodafone

Re: How to set external picture for ImageButton?

Hi smiley,


Have you given permission in bar descriptor file to accsess Shared Files?

If yes then I guess it may be because the image would be too large to fit in. Max dimensions of an image which can be handled by cascade ImageView is 2048 & I assume it would be same for ImageButton

Copy the same image to assets & try setting it from there. If it doesn't work from asstes too, you may have to use QPainter & ImageData class to replicate that image. Look at the below given link. It may help:

Do note that the PixelBufferData Class which is mentioned in above post, has been replaced by ImageData class since release of beta 3 SDK.



Nishant Shah

Posts: 1,638
Registered: ‎07-14-2008
My Device: Z10
My Carrier: Fido

Re: How to set external picture for ImageButton?

[ Edited ]

Thanks for the reply.  Shared access is ok.  I can read the picture file.


No matter how I set the defaultimage for ImageButton it just won't load.  When this happens the imageButton control doesn't even display on the screen.  However if I change it to a Button control the picture will load fine.


I copied the same file and included in the assets folder and it works but NOT when I try to set it to a shared file path.



is the above the correct way to set the default image?

Posts: 13
Registered: ‎11-30-2012
My Device: Alpha
My Carrier: Pepephone

Re: How to set external picture for ImageButton?

Did you solved this problem?

I have a similir issue. I take a pictura with the camara, and want to display it in a ImageButton. I have access to the file, because the file is sent by post to the server, and it's correct saved, but when I try 


 where fileName is something similar to (carama result)


 the defaultImage is always black


BlackBerry Development Advisor
Posts: 683
Registered: ‎11-29-2011
My Device: PRIV
My Carrier: Rogers

Re: How to set external picture for ImageButton?

another post already mentioned this, but is your image smaller than 2048x2048?