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
Contributor
rhiosianturi
Posts: 15
Registered: ‎05-16-2011
My Device: Blackberry 8900
My Carrier: IND Telkomsel
Accepted Solution

Java Threading for Slideshow image

Hi, I'm newbie in develop Blackberry app..

 

can anybody help me, how to create an image slideshow using Java Threading?

I'm really clueless about this

thanks :smileyhappy:

Please use plain text.
Developer
peter_strange
Posts: 19,601
Registered: ‎07-14-2008
My Device: Not Specified

Re: Java Threading for Slideshow image

Welcome to the forum.

 

I have to say, this is a very difficult thing to start with.  So I would recommend you start with something simpler, and just have a slideshow that changes when the user clicks a button.  Have an image in the centre and two buttons to either side.  Just getting that working will be a challenge.

 

Once you have done this, then you should look at Threading.

 

OK?

Please use plain text.
Contributor
rhiosianturi
Posts: 15
Registered: ‎05-16-2011
My Device: Blackberry 8900
My Carrier: IND Telkomsel

Re: Java Threading for Slideshow image

I've done that..

 

here is a sample of my code :

 

public void run() {
        for (i = 0; i < 6; i++) {
            UiApplication.getUiApplication().invokeLater(new Runnable() {
                public void run() {
                    scr.changeImage(slideShowImage[i]);
                }
            });
            try {
                Thread.sleep(5000);
            } catch (InterruptedException ex) {}
        }
    }

 

 

There is also a changeImage function at myScreen to change the image, so it looks like a slideshow. But if I did this, it's only repeat 6 times. I want this to repeat again from start and it become like looping forever and will stop if I close this screen or push new screen.. Can you help me with this? Thx :smileyhappy:

Please use plain text.
Developer
peter_strange
Posts: 19,601
Registered: ‎07-14-2008
My Device: Not Specified

Re: Java Threading for Slideshow image

[ Edited ]

Well done - you are not such a newbie!

 

Maybe I'm missing something...

 

public void run() {

while (true) {
        for (i = 0; i < 6; i++) {

        }

}

}

Please use plain text.
Contributor
rhiosianturi
Posts: 15
Registered: ‎05-16-2011
My Device: Blackberry 8900
My Carrier: IND Telkomsel

Re: Java Threading for Slideshow image

yeaahh it's work!! :smileyvery-happy:

 

thank u so much :Clap:

Please use plain text.
Developer
peter_strange
Posts: 19,601
Registered: ‎07-14-2008
My Device: Not Specified

Re: Java Threading for Slideshow image

If I could make a suggestion....

 

I normally do a

 

finished == false;

while (!finished ) {

}

 

and then have a method that will set finished to true when I want to stop the infinite loop.

 

Just a suggestion. 

Please use plain text.