"Scroll to top" button in a vertical scroll arrangement

1,044 views
Skip to first unread message

Michael Freeborn

unread,
Jul 20, 2017, 10:12:49 AM7/20/17
to MIT App Inventor Forum
Hi there,

I'm making my first app and I've had to look up help or guides for many problems along the way, but for this problem I am completely flummoxed and can't find a good solution.

My App is a multiple choice quiz. I have the answer options in a vertical scroll arrangement below the question, which itself is fixed. When I select "next question", the question and answer choices are set to new values (on the same screen), but the vertical scroll arrangement remains in its current state (i.e. scrolled half way down/all the way to the bottom.)

I am trying to find a way to automatically reset the scroll position in the vertical scroll arrangement to the top each time the next question is loaded, so that the first answer choice is always visible at the top.

So, is there any way to manipulate the scroll arrangement to reset it back to the top? I've found suggestions along the lines of "pushing" the list around by changing the size of hidden labels/arrangements but that's not quite what I'm after.

Tim Carter

unread,
Jul 20, 2017, 12:07:10 PM7/20/17
to MIT App Inventor Forum
Try "not visible", then "visible", should reset it, but may not look pretty!

Abraham Getzler

unread,
Jul 20, 2017, 12:49:53 PM7/20/17
to MIT App Inventor Forum
What's the total number of labels and buttons and other things in that vertical arrangement?
Is the number proportional to the number of questions?

If so, you are doing this wrong.

You should be swapping the text of the questions and answers in and out
to one question's worth of display items as you progress from
question to question.

ABG

Michael Freeborn

unread,
Jul 20, 2017, 1:11:31 PM7/20/17
to MIT App Inventor Forum
Tim Carter: Alas, I tried toggling 'not visible' to 'visible' but with no joy :/ 

Michael Freeborn

unread,
Jul 20, 2017, 1:11:35 PM7/20/17
to MIT App Inventor Forum
I'm not quite sure I'm following you, but, the vertical scroll is placed immediately below a fixed arrangement containing the Question label. Within the vertical scroll are 5 horizontal arrangements for the 5 options. Within each horizontal arrangement is a check box and an associated button. The text of this transparent button is where each answer choice goes (let's users press anywhere on the text to select their answer). The questions and answer choices are written on Excel and then converted into a table from CSV. Each time the "next" button" is pressed, it cycles the Question Number variable up by 1 and the subsequent question and choices populate the relevant button.texts. Beneath the 5 options is a "submit" button and a "next question" button which is enabled/disabled as required.

Does that help?

Abraham Getzler

unread,
Jul 20, 2017, 1:27:26 PM7/20/17
to MIT App Inventor Forum
List Pickers are a great way to save on screen real estate.

Show the question in the .Text of the List Picker,
and load its Elements with the Answer Options.

When the user hits the question, the answer options pop up,
for him to select one.

After Selecting, you can show feedback in the List Picker .Text by showing
JOIN(question, \n, answer selection) 

There should be no need for scrollable vertical arrangements
with this approach.

ABG


Tim Carter

unread,
Jul 20, 2017, 1:47:59 PM7/20/17
to MIT App Inventor Forum
Got it working; see video


Added a textbox height on 1 pixel to the top of the arrangement, then gave it focus and did the visible/notvisible thing with a clock (50msecs)

Probably a better way!

Abraham Getzler

unread,
Jul 20, 2017, 2:06:01 PM7/20/17
to MIT App Inventor Forum

Michael Freeborn

unread,
Jul 20, 2017, 2:47:43 PM7/20/17
to MIT App Inventor Forum
Perfect - I haven't had to use text boxes yet so I had no idea they had a "get focus" call function. Thank you very much.
Reply all
Reply to author
Forward
0 new messages