How do I show random images instead of random numbers on the center of the screen?
I have a small app that shows random numbers (0 through 22, for example). You press a button and a random numbers shows in the center of the screen for a few seconds and then it automatically disappears. It is working perfectly.
Here is the basic code:
Now, I’ve been trying to show random images instead. I have 22 small images named “image00.jpg”, “image01.jpg”, etc all the way to “image22.jpg”. I know that I have to use “ImageView” in the Visual Designer instead of “Label1” which I currently use to show the random numbers. I tried mixing suggestions in the forum but I got nowhere… If I don’t get a Java error I get a missing value…
Can I also show a mix of image formats, not just jpg but png and bmp etc all at once?
I know that in Sub Globals I have to Dim ImageView1 as ImageView, and that in Sub btnrandom_Click and won’t need the Label1.text = K from the current code…
I have tried some of these suggestions and combined them, but the answer evades me, perhaps because my implementation varies too much:
http://www.b4x.com/android/forum/threads/loading-imageview-bitmaps.19044/
http://www.b4x.com/android/forum/threads/how-to-load-an-image-at-random.21047/
http://www.b4x.com/android/forum/threads/load-layout-randomly.42591/
Some of these examples only include the bottom line code but not the background info or additional/supporting code or libraries to load… I can’t guess it… I also tried loading all the libraries available, and still nothing.
I’m using Basic4Android 3.82
Any suggestions? Please help, and, thank you so much in advanced.
I have a small app that shows random numbers (0 through 22, for example). You press a button and a random numbers shows in the center of the screen for a few seconds and then it automatically disappears. It is working perfectly.
Here is the basic code:
B4X:
Sub Globals
Dim K As Int
Dim Label1 As Label
Dim btnrandom As Button
End Sub
Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("Layout01")
Timer1.Initialize ("Timer1",2000)
End Sub
Sub Timer1_Tick
Label1.Text = ""
Timer1.Enabled = False
End Sub
Sub btnrandom_Click
k = Rnd (0, 23)
Label1.Text = K
Timer1.Enabled = True
End Sub
Now, I’ve been trying to show random images instead. I have 22 small images named “image00.jpg”, “image01.jpg”, etc all the way to “image22.jpg”. I know that I have to use “ImageView” in the Visual Designer instead of “Label1” which I currently use to show the random numbers. I tried mixing suggestions in the forum but I got nowhere… If I don’t get a Java error I get a missing value…
Can I also show a mix of image formats, not just jpg but png and bmp etc all at once?
I know that in Sub Globals I have to Dim ImageView1 as ImageView, and that in Sub btnrandom_Click and won’t need the Label1.text = K from the current code…
I have tried some of these suggestions and combined them, but the answer evades me, perhaps because my implementation varies too much:
http://www.b4x.com/android/forum/threads/loading-imageview-bitmaps.19044/
http://www.b4x.com/android/forum/threads/how-to-load-an-image-at-random.21047/
http://www.b4x.com/android/forum/threads/load-layout-randomly.42591/
Some of these examples only include the bottom line code but not the background info or additional/supporting code or libraries to load… I can’t guess it… I also tried loading all the libraries available, and still nothing.
I’m using Basic4Android 3.82
Any suggestions? Please help, and, thank you so much in advanced.