Search code examples
androidlistbackground-colorapp-inventortinydb

App Inventor choose background color from list in TinyDB


I am trying to make an app using App Inventor.

The app has more functions, but I am stuck at the I would say "basic" one. What I want to do is basically change the background color (or color of any element) by calling the color from list stored in TinyDB.

I have two screens Screen1 and a Menu screen. I am tring to call TinyDB while Screen1 initializes and set background color of app on the first in the list. Further I want to let user to choose a color from list on the other screen "Menu". After picking a color change the color on both screens.

I tried to make it following the instruction https://sites.google.com/site/blocks123/playing-with-colors , but it is little bit confusing for me.

On the printscreen i have the TinyDB blocks on the Screen1. Is it possible on Screen1 just call/initialize TinyDB but has the TinyDB blocks on other screen "Menu"?

And when I have TinyDB and lists of color how to change the color on the chosen one?

enter image description here

Thank you Taifun. Your tutorial was helpful for me, evethought it is bit confusing with variables which aren´t described there. Anyway I tried to do it a bit on my way and I think I am going the right direction. As it shown on second image I made it on the "Menu" screen and trying to save my choice to [TinyDB]. It works almost fine but except the error when "Menu" screen inicialize. I don´t understand why I am getting this message while to value is in the list? And the other way how to pass the BCurrentColor variable to "Screen1"? If I use set.Screen1.BackgroundColor it doesntWork

enter image description here

Well now I know I am close, I can almost fell it in the air. It is properly change background color on "Menu" screen but some how it doesn´t saves the choice to [TinyDB] as I describes at comments. Where I went wrong? I hope when I save the color "code" to database I can call it on the other screen.

enter image description here


Solution

  • As Taifun mentioned the problem was with the variables BCurrentColor and BCurrentColorName. After I changed them to values and the trigger after selecting color from list sets it to required color.

    Then I can call it from TinyDB. It works fine.