Android Question Panel questions. Maybe i should do class's that load into a panel?

brianwiz12

Active Member
Licensed User
Longtime User
Hello,

I have been working to re-work and launch a better trivia app that does not include 15+ activity modules. Im trying to make it lean and mean so when i add content it will not be bulky.

So i began to play with Panels and got to the point where

B4X:
Activity.LoadLayout("S1E1")

    'Activity.SetBackgroundImage(LoadBitmap(File.DirAssets, "jerichobackground.png"))
    rbtAnswer(0).Initialize("rbtAnswer")
    rbtAnswer(0).Tag = 0
    panel1.AddView(rbtAnswer(0), 10dip, 5dip, 450dip, 75dip)
    rbtAnswer(1).Initialize("rbtAnswer")
    rbtAnswer(1).Tag = 1
    panel1.AddView(rbtAnswer(1), 10dip, 50dip, 450dip, 75dip)
    rbtAnswer(2).Initialize("rbtAnswer")
    rbtAnswer(2).Tag = 2
    panel1.AddView(rbtAnswer(2), 10dip, 95dip, 450dip, 75dip)
    If File.Exists(File.DirDefaultExternal, "SeasonOne.db") = False Then
        File.Copy(File.DirAssets, "SeasonOne.db", File.DirDefaultExternal, "SeasonOne.db")
    End If
    QuestionList.Initialize
    AnswerList1.Initialize
    AnswerList2.Initialize
    AnswerList3.Initialize
    RightIndex.Initialize
    xSQL.Initialize(File.DirDefaultExternal, "SeasonOne.db", True)

    xCursor = xSQL.ExecQuery("SELECT * FROM One ")
    Log(xCursor.RowCount)
    For i = 0 To xCursor.RowCount - 1
        xCursor.Position = i
        Log(xCursor.GetString("Question"))
        Log(xCursor.GetString("ChoiceOne"))
        Log(xCursor.GetString("ChoiceTwo"))
        Log(xCursor.GetString("ChoiceThree"))
        Log(xCursor.GetString("ansind"))
        Log(" ")
        QuestionList.Add(xCursor.GetString("Question"))
        AnswerList1.Add(xCursor.GetString("ChoiceOne"))
        AnswerList2.Add(xCursor.GetString("ChoiceTwo"))
        AnswerList3.Add(xCursor.GetString("ChoiceThree"))
        RightIndex.Add(xCursor.GetInt("ansind"))
    Next
    xCursor.Close
    btnNext_Click
    Button1.SendToBack

Where i can click next after the above module and load another episode of my trivia game as below indicates

B4X:
panel1.RemoveView
    btnNext.RemoveView
    lblQuestion.RemoveView'
    CursPosition.RemoveView
    Activity.SetBackgroundImage(LoadBitmap(File.DirAssets, "jerichobackground.png"))
    rbtAnswer(0).Initialize("rbtAnswer")
    rbtAnswer(0).Tag = 0
    Panel2.AddView(rbtAnswer(0), 10dip, 5dip, 450dip, 75dip)
    rbtAnswer(1).Initialize("rbtAnswer")
    rbtAnswer(1).Tag = 1
    Panel2.AddView(rbtAnswer(1), 10dip, 50dip, 450dip, 75dip)
    rbtAnswer(2).Initialize("rbtAnswer")
    rbtAnswer(2).Tag = 2
    Panel2.AddView(rbtAnswer(2), 10dip, 95dip, 450dip, 75dip)
    If File.Exists(File.DirDefaultExternal, "SeasonOne.db") = False Then
        File.Copy(File.DirAssets, "SeasonOne.db", File.DirDefaultExternal, "SeasonOne.db")
    End If
    QuestionList.Initialize
    AnswerList1.Initialize
    AnswerList2.Initialize
    AnswerList3.Initialize
    RightIndex.Initialize
    xSQL.Initialize(File.DirDefaultExternal, "SeasonOne.db", True)

    xCursor = xSQL.ExecQuery("SELECT * FROM Three ")
    Log(xCursor.RowCount)
    For i = 0 To xCursor.RowCount - 1
        xCursor.Position = i
        Log(xCursor.GetString("Question"))
        Log(xCursor.GetString("ChoiceOne"))
        Log(xCursor.GetString("ChoiceTwo"))
        Log(xCursor.GetString("ChoiceThree"))
        Log(xCursor.GetString("ansind"))
        Log(" ")
        QuestionList.Add(xCursor.GetString("Question"))
        AnswerList1.Add(xCursor.GetString("ChoiceOne"))
        AnswerList2.Add(xCursor.GetString("ChoiceTwo"))
        AnswerList3.Add(xCursor.GetString("ChoiceThree"))
        RightIndex.Add(xCursor.GetInt("ansind"))
    Next
    xCursor.Close
    Button1_Click

I have run into several issues where i have seemed to be close to solving but not exactly solving it. I will list them for input or guidance.

1. I have attached a screenshot. My goal is to have a drop down at the top outside of the panel so people can choose the episode within that season to play. As you can see by the screenshot it holds over the trivia. I cant seem to find where in my code the panel is setup for full view. The next button at the button does not seem to be an issue. I even moved Episode three next to the next button and no help.

2. It seems that i would have to create for instance this season of trivia has 22 epsiodes.. So i would need to create 22 panels. question labals, curs labels and next buttons. With that i would have to as seen in the second piece of code remove every single view from the activity for it to not overlap and give issues. This is where i think i might be able to use class's and load it?

3. Going to the extreme end is their a way i can make it even more dynamic and just use the same panel and make the database code load Instead of episode 2 go to another episode without doing number 2?

I know i have done this in javascript programming but that was well a decade ago.

Thoughts? suggestions?

I thank this community as you are always helpful and the search is awesome i have gotten so many ideas and implementation ideas.
 

Attachments

  • panels.png
    panels.png
    28.9 KB · Views: 291

brianwiz12

Active Member
Licensed User
Longtime User
Hello,

Sorry for the delay in getting back.

The layout will be

top of screen a drop down menu to choose what episode ( IE 1,2,3,4,5,6 ect.

Then it will from there load a panel for that specific episode. Then if you choose a different episode it loads another panel

Button is a next button to go to next question

-----------------

Now the second portion of question 1. In loading different panels i have to remove every single thing from panel 1, labels, next buttons ect. Which means i would end up having at some point to remove up to 23 next buttons, labels ect each time i load a panel.

Is there a way to avoid this?

Sticking with the database format.
 
Upvote 0

brianwiz12

Active Member
Licensed User
Longtime User
Sorry i have not posted in awhile been very busy.

Im still having the mis understanding about why this panel controls the screen when the above code does not point it out.

If i add a button as the screenshot showed it shows at the top. When i add the button at the button it overlaps with the other one.

Only thing the panels are loading is the answers. They are not loading the questions or other buttons.
 
Upvote 0

brianwiz12

Active Member
Licensed User
Longtime User
Let me try to show the issue/questions again. Maybe i just cant explain this properly.

First lets look at my designer layout attached designer
The top button will be the drop down to load the panel
The next button controls the questions without the panel and goes to the next episode once it goes through all the random questions that are listed in that Database.

Second screen shot Samsung 1400 4 inch phone attached as 4inchphone
This looks like what i want it to look like

Third Samsung S3 (I use an S6) same thing attached as S3
The button that is at the top that will be the drop down overtakes the button next button.
 

Attachments

  • designer.png
    designer.png
    14.4 KB · Views: 252
  • 4inchphone.png
    4inchphone.png
    30.5 KB · Views: 259
  • s3.png
    s3.png
    27.5 KB · Views: 255
Upvote 0

brianwiz12

Active Member
Licensed User
Longtime User
This can be closed. I will post any other question i have with panels in another thread.

I have figured out what i was doing dumbly wrong with Variants.
 
Upvote 0
Top