2017년 4월 5일 수요일

Initialize text display from listpicker


Using App Inventor 2, Windows 7 and current version of Firefox.

Have a listpicker of 4 items:

1. Dine In - screen background = white
2. Take Out - screen background = yellow
3. No Charge Dine In - screen background = blue
4. No Charge Take Out - screen background = blue
When the user clicks on the listpicker, would like to display the item selected (e.g., Dine In), and change the screen background color according to the item selected.  Below are the design and block workspaces for this function.
The first time I executed AI Companion, I selected No Charge Dine In.  That value appeared in the listpicker box on the screen and the screen background changed to blue.  So, that worked.
When I select Dine In, Take Out or No Charge Take Out, the text remains as No Charge Dine In (first option selected) and the background color remains blue.  Even if I reset AI Companion and re-connect, the values remain the same.  They never seem to re-initialize.
What is wrong with the code to make this happen?
--
You need to be checking the value returned from the listpicker.  You're not actually assigning the value of the pick to anything...

Set the button text by setting it to ListPicker.Selection first, before and above the If statement.  Then, remove all of those set lstOrderType.Text statements and just set the background color...
--
That worked!  Thank you so much!!!  Below is a copy of the code in case someone wants to perform a similar function.

--
Glad it helped...

--

댓글 없음:

댓글 쓰기