Skip to first unread message

Rafa Puente

unread,
Mar 6, 2018, 1:40:09 PM3/6/18
to MIT App Inventor Forum
[ESPAÑOL]
Buenas tardes,

tengo un problema que no sé como solucionar. Yo he creado en Screen 1 un botón con el color de fondo gris, cuando el botón se pulsa cambio su color de fondo a color verde y voy a la screen2. Cuando vuelvo a la Screen 1 el color del botón vuelve a ser gris y no de color verde.

¿Cómo puedo cambiar y mantener el color de fondo de un botón y que no cambie cuando vuelvo de otra pantalla?

Espero haberme explicado bien.

Gracias!

[ENGLISH]
Good afternoon,

I have a problem that I do not know how to solve. I have created in Screen 1 a button with the color of gray background, when the button is pressed it changes its background color to green color and I go to screen2. When I return to Screen 1 the color of the button becomes gray again and not green.

How can I change and maintain the background color of a button and not change when I come back from another screen?

I hope you have explained me well.

Thank you!


Evan Patton

unread,
Mar 7, 2018, 5:01:18 PM3/7/18
to MIT App Inventor Forum
Hi Rafa,

If you are seeing this behavior in the companion, this is because the companion does not save the state of a screen when transitioning to a new screen. It emulates screen changes by clearing and restoring the screen based on the project contents. If you compile the app and run it on your device, you should get the right behavior assuming that your app isn't so memory intensive Android destroys Screen1.

If you want to be more robust to the lifecycle of Screen1, you should write some information to track the background color to TinyDB and then restore it in the Screen1.Initialize block.

Regards,
Evan

Rafa Puente

unread,
Mar 11, 2018, 11:44:24 AM3/11/18
to MIT App Inventor Forum
Hi Evan,

thank you for answer me, 

best regards,

Rafa
Reply all
Reply to author
Forward
0 new messages