Android Question Drop Down Menus

brianwiz12

Active Member
Licensed User
Hello,

first I have continued to learn a lot from this form. Now I now have to do splash pages. okay well that's a mini thing I guess.

Having trouble grasping panels but I continue to look through tutorials and code.

The main thing I really want to get a handle on is Drop Down Menu. Im creating a program with 50 different modules(50 different questions). I want people to have ability to go to different ones.

(yes I now 50 modules is not ideal and panels should be used but again grasping those for some reason is difficult)

<code>
dlist.Initialize(pnl1, "drop list", "DropSelect")
dlist.dlItems.Add("Q1")
dlist.dlItems.Add("Q2")
dlist.dlItems.Add("Q3")
dlist.dlItems.Add("Q4")
dlist.dlItems.Add("Q5")
dlist.dlItems.Add("activity.loadlayout("Q6"))
</code>

Then I tried the last one obviously that didn't work.

I don't have the experience with android coding to make it a sub like in VB Select statement I would use.

Thanks ahead of any advice. As I continue to try and get a handle and the coding and all tutorials.

Yes I have gone through the beginning tutorial several times and it does not really show different menus and examples.
 

brianwiz12

Active Member
Licensed User
Erel:

Dim dlist As droplist

Klaus to me that would require a sgllite database which I'm only at the beginning of learning.
 

brianwiz12

Active Member
Licensed User
Give you an idea what im trying to do. This is how I did it in vb6/vb2010 express

<code>
Case 0 ' One Table is selected
Dim NewMainForm AsNewForm4
NewMainForm.Show()
Me.Hide()
Case 1 ' Two Table is selected
Dim NewMainForm AsNewform2
NewMainForm.Show()
Me.Hide()
</code>

I will also point out im working with version 3.50... I found one combobox example but I have to upgrade my version to run the example.
 
Last edited:

klaus

Expert
Licensed User
What do you have in each Form ?
You don't need a database.
You could have the questions in a text file and read it into a string array and according to the index display the correct question.
 

brianwiz12

Active Member
Licensed User
B4X:
Sub Globals


    Dim EditText1 As EditText
    Dim Spinner1 As Spinner
End Sub

Sub Activity_Create(FirstTime As Boolean)
   
    Activity.LoadLayout("main")

Spinner1.Add("Question One")
Spinner1.add("Question Two")


Spinner1.DropdownTextColor = Colors.White
End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub
Sub Spinner1_ItemClick (Position As Int, Value As Object)
    Select Value
    Case "Question One"
        StartActivity("beginners")
    Case "Question Two"
        StartActivity("advanced")
End Select
End Sub
Just an example but it works. Klaus in one of your threads you showed case statements and I read the spinner document and combined them.

Klaus in terms of what I want to do:

I have 50 quotes by different people. One Label would be a quote and then radio button's to select correct answer then move on to next question.

With that being said. I open to researching different ways. One person Messaged me about panels last night in terms of it being like a frame in VB and that opened up a whole new world. Thanks mangojack
 

klaus

Expert
Licensed User
I have 50 quotes by different people. One Label would be a quote and then radio button's to select correct answer then move on to next question.
Does this mean that you will have 50 panels or whatever container it might be ?
I am still convinced that one layout would be enough. But without more details difficult to give a concrete advice.
 

brianwiz12

Active Member
Licensed User
Sorry for lack of response.

Right now im looking at a design that has 50 panels or 50 modules for the questions and answers.

I'm also looking into array list to accomplish this.
 

brianwiz12

Active Member
Licensed User
So I came up with a spinner2 to do the question and answer in the same panel. Radio Button Attempt

B4X:
Sub Spinner2_ItemClick (Position As Int, Value As Object)
    Select Value
    Case "Jericho is a city in"

    radiobutton4.Text = "Kansas"
    If radiobutton4.Checked = True Then
    Msgbox("Right-Move on to Next Question","")
    Else

    radiobutton5.Text = "Ks"
    radiobutton5.Checked = True
    Msgbox("Wrong","")

    radiobutton6.Text = "K"
    radiobutton6.Checked = True
    Msgbox("No","")
    End If
    Case "Jericho is a tv show on"
End Select
End Sub
When I choose the question it automatically has radiobutton5/6 checked and msgbox pops up wrong.

So I try with just a text entry box

B4X:
Sub Spinner2_ItemClick (Position As Int, Value As Object)
    Select Value
    Case "Jericho is a city in"
    If edittext3.text = "Kansas" Then
    Msgbox("Right-Move on to Next Question","")
    Else
    Msgbox("Wrong","")
    End If
    Case "Jericho is a tv show on"
End Select
End Sub
Same problem as Radio button. The text box is clear and I get pop up wrong...

I missing the portion of the user action beforehand.

If you can guide me at what I should look at I would be greatly appreciative.

Klaus I would also like to hear you thoughts on alternatives.
 

brianwiz12

Active Member
Licensed User
Here it is. Panel 2 is what im working on currently. Questions come from the spinner add object. Answers would come from Case Select.
 

Attachments

brianwiz12

Active Member
Licensed User
Hello,

Updated by file. I have it loading in one panel now. With the label and radio buttons changing.

I still have the problem where it chooses the radio buttons by default.
 

Attachments

brianwiz12

Active Member
Licensed User
I thank you for the reply. I have done that and I still get the msgbox pop up incorrect without selecting anything.

Sorry I did not include that version. I tried that and did not do a zip file

I know this is a simple fix.
 

klaus

Expert
Licensed User
Before beginning with coding you should think about your data structure.
What data do I need ?
How and where do I save it ?
Then you must think about the user interface.
What do you want to show on the screen ?
What can or must the user do ?
How do I step through the data sets ?
Where, when and how do I check the answers, after each question or only at the end ?
Etc.
Now you can begin with coding because the code would be different depending on the answers above.

For your data I would suggest either:
- a database and load it in arrays.
- a csv (Excel) file and load it in arrays.
The minimum data you need for each data set is:
- 1 question
- 3 possible answers
- 1 index for the right ansewer.
- and others if needed, like category or difficulty for different types of questions.

For your RadioButtons I would suggest to use a RadioButton array and one CheckedChange event and use the Tag property to know which one was selected and save the index of the selected RadioButton in a variable, or an array depending if you want to save the answers or not.
Depending on what you want, you can check the correct answer either when the user selects a new question or only at the end of the test.
Depending on how you want to navigate through the questions you must either set all the RadioButton.Checked properties to False or set the correct RadioButton.Checked property for the previously selected answer.

In your code when the user selects a question, then in Case "Question Two" you update the layout with the new data and directly after you check if the answer is OK, but the user hasn't yet given it !?
 
Top