Do you mean random lists or random values in a given list ?AnswerList(randomvalue).Get(Qnumber)
Please, can you give an example with 1 or 2 lines of code?You can store the image files in an Array and load them in ImageViews similar to the texts.
Best regards.
Sub Process_Globals
Dim ImageFiles(4) As String
ImageFiles(0) = "Rose.jpg"
ImageFiles(1) = "Gentiane.jpg"
ImageFiles(2) = "LysMartagon.jpg"
ImageFiles(3) = "Edelweiss.jpg"
End Sub
Sub Globals
Dim ImageView1 As ImageView
End Sub
Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("main")
ImageView1.Bitmap = LoadBitmap(File.DirAssets, ImageFiles(0))
End Sub
Sub ImageView1_Click
Dim i As Int
i = Rnd(0, 4)
ImageView1.Bitmap = LoadBitmap(File.DirAssets, ImageFiles(i))
End Sub
Here you are.
Attached the small test project.B4X:Sub Process_Globals Dim ImageFiles(4) As String ImageFiles(0) = "Rose.jpg" ImageFiles(1) = "Gentiane.jpg" ImageFiles(2) = "LysMartagon.jpg" ImageFiles(3) = "Edelweiss.jpg" End Sub Sub Globals Dim ImageView1 As ImageView End Sub Sub Activity_Create(FirstTime As Boolean) Activity.LoadLayout("main") ImageView1.Bitmap = LoadBitmap(File.DirAssets, ImageFiles(0)) End Sub Sub ImageView1_Click Dim i As Int i = Rnd(0, 4) ImageView1.Bitmap = LoadBitmap(File.DirAssets, ImageFiles(i)) End Sub
Best regards.
Sub Process_Globals
Dim ImageFiles(4) As String
ImageFiles(0) = "Rose.jpg"
ImageFiles(1) = "Gentiane.jpg"
ImageFiles(2) = "LysMartagon.jpg"
ImageFiles(3) = "Edelweiss.jpg"
Dim Counter = 0 As Int
End Sub
Sub Globals
Dim ImageView1 As ImageView
End Sub
Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("main")
ImageView1.Bitmap = LoadBitmap(File.DirAssets, ImageFiles(Counter))
End Sub
Sub ImageView1_Click
ImageView1.Bitmap = LoadBitmap(File.DirAssets, ImageFiles(Counter))
Counter = Counter + 1
If Counter > 3 Then
Counter = 0
End If
End Sub
Use a counter:
Best regards.B4X:Sub Process_Globals Dim ImageFiles(4) As String ImageFiles(0) = "Rose.jpg" ImageFiles(1) = "Gentiane.jpg" ImageFiles(2) = "LysMartagon.jpg" ImageFiles(3) = "Edelweiss.jpg" Dim Counter = 0 As Int End Sub Sub Globals Dim ImageView1 As ImageView End Sub Sub Activity_Create(FirstTime As Boolean) Activity.LoadLayout("main") ImageView1.Bitmap = LoadBitmap(File.DirAssets, ImageFiles(Counter)) End Sub Sub ImageView1_Click ImageView1.Bitmap = LoadBitmap(File.DirAssets, ImageFiles(Counter)) Counter = Counter + 1 If Counter > 3 Then Counter = 0 End If End Sub
Attached you find your project a little bit modified.
In the database you entered systematically 0,1,2,0,1,2 etc in the ansind column.
The index in this column should be the index of the correct answer !
If Answer1 is the correct one then ansind = 0
If Answer2 is the correct one then ansind = 1
If Answer3 is the correct one then ansind = 2
in the rbtAnswer_CheckedChange routine we can check if the RadioButton that raised the event contains the correct answer.
Best regards.
Dim Result As Int
Counter = Counter + 1
Qnumber = Rnd(1, 3)
lblQuestion.Text = QuestionList.Get(Qnumber)
If Qnumber >= 3 Then
Qnumber = 0
End If
'If Counter = 10 Then
'Result = Msgbox2("You have answered 8 correct out of 10", "Score", "Continue", "Finish", "", Null)
'Counter = 0
'End If
rbtAnswer(0).Checked = False
rbtAnswer(1).Checked = False
rbtAnswer(2).Checked = False
rbtAnswer(0).Text = AnswerList1.Get(Qnumber)
rbtAnswer(1).Text = AnswerList2.Get(Qnumber)
rbtAnswer(2).Text = AnswerList3.Get(Qnumber)
xSQL.Initialize(File.DirDefaultExternal, "football.db", True)
xCursor = xSQL.ExecQuery("SELECT * FROM Questions")
For i = 0 To xCursor.RowCount - 1
xCursor.Position = i
QuestionList.Add(xCursor.GetString("Question"))
AnswerList1.Add(xCursor.GetString("Answer1"))
AnswerList2.Add(xCursor.GetString("Answer2"))
AnswerList3.Add(xCursor.GetString("Answer3"))
RightIndex.Add(xCursor.GetInt("ansind"))
Next
xCursor.Close
btnNext_Click
End Sub
Sub btnNext_Click
Dim Result As Int
Counter = Counter + 1
Qnumber = Rnd(1, 95)
lblQuestion.Text = QuestionList.Get(Qnumber)
If Qnumber >= 95 Then
Qnumber = 0
End If
xSQL.Initialize(File.DirDefaultExternal, "football.db", True)
xCursor = xSQL.ExecQuery("SELECT * FROM Quiz")
For i = 0 To xCursor.RowCount - 1
xCursor.Position = i
QuestionList.Add(xCursor.GetString("Question"))
AnswerList1.Add(xCursor.GetString("Answer1"))
AnswerList2.Add(xCursor.GetString("Answer2"))
AnswerList3.Add(xCursor.GetString("Answer3"))
RightIndex.Add(xCursor.GetInt("ansind"))
Next
xCursor.Close
btnNext_Click
End Sub
Sub btnNext_Click
Dim Result As Int
Counter = Counter + 1
Qnumber = Rnd(1, 6)
lblQuestion.Text = QuestionList.Get(Qnumber)
If Qnumber >= 6 Then
Qnumber = 0
End If
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?