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
Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: How to select the image through gallery or camera?

So you are not changing the existing Bitmap, you are selecting a new Bitmap to replace it. 

 

OfK, here is a suggestion:

 

You have an image that is actually a Button, when the user clicks on this you provide a popup with 2 options

1) select new image or

2) capture new image

 

If they choose select, then start your own FilePicker dialog - I think there has been a link already provided.  I think there is also an option to invoke the standard gallery image viewer and use a APplicationMenuItem in that to select the image - this I think has been discussed in other Threads so have a search

 

If the choose camera, then start something like the CameraDemo sample, which you will find in the samples.  Alternatively you can start the Camera and detect the last picture taken, this is more complicated, but again is discussed elsewhere in the forum.

 

Does this give you a good start?

 

Forums Advisor I
Posts: 501
Registered: ‎03-01-2013
My Device: BlackBerry Z10

Re: How to select the image through gallery or camera?

Hey i dont want to provide any button .

I want when the user clicks the image a popupscreen opens that contains the two option. So what i have to do for this?

Developer
Posts: 354
Registered: ‎06-05-2013
My Device: Blackberry Z10
My Carrier: Vodafone

Re: How to select the image through gallery or camera?

Do something like this

bitmap = Bitmap.getBitmapResource("unblocked.png");
        bitmap2 = Bitmap.getBitmapResource("blocked.png");
        bitmapField = new BitmapField(bitmap, BitmapField.FOCUSABLE)
        {
        	protected boolean navigationClick(int status, int time) 
        	{
        		// Add Your Pop Up here
        		bitmapField.setBitmap(bitmap2);
        		return true;
        	}
        	protected void drawFocus(net.rim.device.api.ui.Graphics graphics, boolean on) 
        	{
        		if(on)
        		{
        			setBackground(BackgroundFactory.createSolidBackground(Color.BLACK));
        		}
        	}
        };
        add(bitmapField);

 

Developer
Posts: 354
Registered: ‎06-05-2013
My Device: Blackberry Z10
My Carrier: Vodafone

Re: How to select the image through gallery or camera?

in navigation click add pop up u want
Developer
Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: How to select the image through gallery or camera?

[ Edited ]

I actually said this

"You have an image that is actually a Button"

 

So the image is actually a button. 

 

In addition to the code provided by developer_aman_arora, if you look round the forum you will find many examples of Image buttons.  It is really just as simple as overriding navigationClick() for the BitmapField you want to be a button. 

 

Can I suggest that you do not use the code provided by developer_aman_arora as is, specifically do not override drawFocus in the method as he has done it.  If you want to provide a visual indication of focus state by changing the background, instead look at using the setBackground method and set a Background for the Focus visual state.  I find adding a 1 bit padding area around the Bitmap will provide the space for the focus background to be visible, if the image is not transparent - which it probably won't be in your case.