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
New Developer
Posts: 86
Registered: ‎01-20-2012
My Device: Bold Touch
My Carrier: Vodafone

How to replace a bitmapField in the mainscreen?

Hi Im trying to replace a bitmap Field from a background thread. Previously i got an error saying old field is not a child but now i guess i managed to replace but i dont see the new bitmap that i have replace the previous one with?

 

 

Please help

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

Re: How to replace a bitmapField in the mainscreen?

please post a code snippet
----------------------------------------------------------
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
New Developer
Posts: 86
Registered: ‎01-20-2012
My Device: Bold Touch
My Carrier: Vodafone

Re: How to replace a bitmapField in the mainscreen?

[ Edited ]
Here is the code snippet

UiApplication.getUiApplication().invokeLater(new Runnable() { public void run() { synchronized (UiApplication.getEventLock()) { try { camView.jpegBytes = jp; System.out.println(bit); net.rim.device.api.ui.Screen scr = UiApplication.getUiApplication().getActiveScreen(); test lvg = new test(); HorizontalFieldManager hfm = new HorizontalFieldManager(); //scr.add(new BitmapField(img.getBitmap())); BitmapField bmpField = new BitmapField(bit); //Manager m = lvg.hfmBmp.getManager(); System.out.println("Replacing BitmapField."); //lvg.hfmBmp.getManager().replace(lvg.hfmBmp, hfm); //scr.getManager().replace(lvg.bmpStream, bmpField); lvg.bmpStream.getManager().replace(lvg.bmpStream, bmpField); lvg.invalidate(); } catch(IllegalArgumentException e) { System.out.println("Exception while displaying streaming images: " + e.getMessage()); } catch(NullPointerException e) { System.out.println("NullPointerException while displaying streaming images: " + e.getMessage()); } } } });

 

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

Re: How to replace a bitmapField in the mainscreen?

use only invokelater, don't synchronize on the eventlock.
i would suggest to retrieve the manager, assign it to a variable and check it with the debugger.

what kind of field is lvg.bmpStream? Where is it initialized? why is it accessed directly (public?) ?
----------------------------------------------------------
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
New Developer
Posts: 86
Registered: ‎01-20-2012
My Device: Bold Touch
My Carrier: Vodafone

Re: How to replace a bitmapField in the mainscreen?

its a bitmapField whcih is in the mainscreen UI. im accessing it from a background thread. I have set it to public to access from a different class.

 

Il try your suggestion

New Developer
Posts: 86
Registered: ‎01-20-2012
My Device: Bold Touch
My Carrier: Vodafone

Re: How to replace a bitmapField in the mainscreen?

Hi Simon,

 

I did as you said but still its not work. also the manager is not null.

 

System.out.println("Replacing BitmapField.");
Manager m = lvg.bmpStream.getManager();
							//lvg.hfmBmp.getManager().replace(lvg.hfmBmp, hfm);
							//scr.getManager().replace(lvg.bmpStream, bmpField);
							lvg.bmpStream.getManager().replace(lvg.bmpStream,bmpField);							
lvg.invalidate();

 The manager does not return null. it returns the same horizontal field manager that i have used on the main screen to add the bitmapField.

New Developer
Posts: 13
Registered: ‎07-20-2009
My Device: Not Specified

Re: How to replace a bitmapField in the mainscreen?

On some version of OS 6.0 I saw that manager does not call sublayout after deleting and replacing fields, try on different devices or simulators
New Developer
Posts: 86
Registered: ‎01-20-2012
My Device: Bold Touch
My Carrier: Vodafone

Re: How to replace a bitmapField in the mainscreen?

[ Edited ]

If thats the case Marfa how am I supposed to develop an app for all the devices. I mean I am a bit doubtful about it...Im pretty sure the replace method could be done and I feel just miss only a wee bit here!!!

 

the replace part doesnt throw any errors or exceptions but the UI doesnt show the new bitmapField that I want do display.

 

It's really hard to find support on blackberry issues as well

New Developer
Posts: 13
Registered: ‎07-20-2009
My Device: Not Specified

Re: How to replace a bitmapField in the mainscreen?

try to override method replace() for this manager and call updateLayout() after super.replace()
New Developer
Posts: 13
Registered: ‎07-20-2009
My Device: Not Specified

Re: How to replace a bitmapField in the mainscreen?

And it is BlackBerry, You should be very patient to develop for it