04-21-2010 04:09 AM
Hi everyone,
I am trying to develop a little application to slideshow images in a blackberry.
I´ve got the images to display after a period of time, however I am not beeing able to make the previous one
disapear before I can show the next one. It´s my first time developing for blackberry (I am a novice ideed), and
any help would be appreciated.
The code:
final class HelloWorldScreen extends MainScreen
{
HelloWorldScreen()
{
try{
timer = new Timer();
timer.scheduleAtFixedRate(new TimerMainEvent(),2000,2000);
}
catch(Exception e)
{
//do nothing
}
}
Timer timer;
public static int COUNT =0;
private String[] images = {"moma.png","google_color.png","nike.png","novarti s_color.png","pfizer_color.png","heineken.png"};
private class TimerMainEvent extends TimerTask
{
public void run()
{
if(COUNT == 5){
COUNT = 0;
}
UiApplication.getUiApplication().invokeLater(new Runnable()
{
public void run()
{
synchronized(UiApplication.getEventLock())
{
Bitmap IMAGEM = Bitmap.getBitmapResource(images[COUNT]);
BitmapField ImgBmpField = new BitmapField(IMAGEM);
add(ImgBmpField);
}
}
});
COUNT++;
}
}
}Thanks in advance, Rodolpho.
04-21-2010 11:47 AM
Anyone?
Tks!
04-21-2010 12:18 PM
Welcome to the BlackBerry forums, sorry we haven't responded till now.
If you retain a reference to the BitmapField you have previously added, then you have two options:
a) Delete it, then add the new one
b) Change the Bitmap associated with the BitmapField (using its set(...) method).