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

Native Development

Reply
New Contributor
Posts: 2
Registered: ‎05-10-2013
My Device: BlackBerry Z10
My Carrier: 972556696369

How to save multiple images and sentences and pick one to display at random?

Hello everyone, total newbie here!

 

I'd like to save about 20 sentences and then have an action that will pick one of them at random and then display it on a text area. How do I do it?

 

Oh, and I would also like to do the same with images, store them and choose one at random. So how do I do that?

 

Thanks very much!

 

Dvir

Developer
Posts: 1,524
Registered: ‎12-18-2012
My Device: Z30, Z10 LE, DevAlpha C, PlayBook

Re: How to save multiple images and sentences and pick one to display at random?

Hi,

Split this into simpler tasks:

Start from creating a page with ImageView and TextArea.

Logic is easier to implement in C++, this document describes the integration:

http://developer.blackberry.com/cascades/documentation/dev/integrating_cpp_qml/

 

Try setting a static text and image programmatically.

When this is working, create a list of sentences and their corresponding image URLs, create a function to pick a random one, call it from action handler in QML.

 


Andrey Fidrya, @zmeyc on twitter