AYUDA COMO CERRAR UNA PANTALLA AL ACCIONAR UN BOTON

1,897 views
Skip to first unread message

EstebanZ

unread,
Oct 11, 2015, 1:31:07 AM10/11/15
to MIT App Inventor Forum
BUENAS NOCHES, NECESITO SABER COMO PUEDO LOGRAR HACER QUE AL RATO DE DAR CLIC EN UN BOTON ME VAYA A OTRA PANTALLA PERO QUE LA ANTERIOR SE CIERRE, GRCIAS DE ANTEMANO.

Italo

unread,
Oct 11, 2015, 2:02:36 AM10/11/15
to MIT App Inventor Forum
En la pantalla inicial pone esto:


Y en cada pantalla, cuando la cierres, usa estos bloques:



Lo que hace esto es, cerrar la pantalla actual y mandarle un texto a la pantalla anterior. 

El bloque OtherScreenClosed, se ejecuta cuando se cierra una pantalla, y si le mandaste un texto, lo usa para abrir otra pantalla.

Si no le mandas nada, se queda ahi.





Taifun

unread,
Oct 11, 2015, 9:15:05 AM10/11/15
to MIT App Inventor Forum

Italo

unread,
Oct 11, 2015, 10:41:43 AM10/11/15
to MIT App Inventor Forum

Taifun, I have a question:


Why the "close screen" block gets executed if you open another screen before? Isn't that preventing anything below the "open another screen" block from getting executed?

Taifun

unread,
Oct 11, 2015, 12:03:56 PM10/11/15
to MIT App Inventor Forum
this is the Tribblehunter method, how it works see here
Taifun

Italo

unread,
Oct 11, 2015, 12:38:57 PM10/11/15
to MIT App Inventor Forum
Uhm... yes, that's where I got the image I posted in my previous post. All the explanation I see about the question I did is this: (!)
I don't really know what (!) means here.

EstebanZ

unread,
Oct 11, 2015, 1:06:17 PM10/11/15
to MIT App Inventor Forum

Hola, ya lo pude solucionar, básicamente estoy haciendo que cuando se da clic en el botón se abra una nueva ventana y despues se cierre la pagina en la que estabas. 

Italo

unread,
Oct 11, 2015, 1:24:49 PM10/11/15
to MIT App Inventor Forum
No se me habia ocurrido hacerlo asi. Lo unico que veo es que en realidad no necesitas el parametro "Nombre de la pantalla que vas a cerrar", porque ese nombre de pantalla es el mismo de la pantalla actual y ya la cerraste con el bloque "CERRAR PANTALLA".

EstebanZ

unread,
Oct 11, 2015, 1:33:31 PM10/11/15
to MIT App Inventor Forum
osea me podrias dar el ejemplo, porque osea si te entiendo pero como pongo el comando cerrar pantalla

Italo

unread,
Oct 11, 2015, 1:45:01 PM10/11/15
to MIT App Inventor Forum
Es igual, solo que no necesitas poner nada en RESULTADO. Un bloque vacio o ningun bloque, creo que funciona igual.
Pero si lo dejas asi va a funcionar igual, creo. Solamente que el valor no es leido despues por ningun proceso.
Bien pensado!

EstebanZ

unread,
Oct 11, 2015, 1:55:11 PM10/11/15
to MIT App Inventor Forum
Si no fuera a tu ayuda hermano gracias a ti.

Taifun

unread,
Oct 11, 2015, 2:12:09 PM10/11/15
to MIT App Inventor Forum
Uhm... yes, that's where I got the image I posted in my previous post. All the explanation I see about the question I did is this: (!)
I don't really know what (!) means here.

let me copy the relevant part of that page http://puravidaapps.com/tribblehunter.php into this thread
Taifun

The Tribblehunter method presented here opens another screen and at the same time(!) closes the current screen. Using this method there is no need of a manager screen. With this method, only 1 screen is open the same time. Thank you Tribblehunter for this great solution!

Note: This solution does not work together with the App Inventor 2 Companion app in development mode. You have to build your app to be able to test that.



Italo

unread,
Oct 11, 2015, 6:48:46 PM10/11/15
to MIT App Inventor Forum
I don't think you understand my question.
The article you keep repeating doesn't answer it either.
My question is this: How the CLOSE SCREEN block gets to be executed when you open another screen before it gets there?
Is App Inventor 2 capable of opening a screen and keep executing code on the previous one?

Scott Ferguson

unread,
Oct 12, 2015, 12:21:02 AM10/12/15
to mitappinv...@googlegroups.com
"Is App Inventor 2 capable of opening a screen and keep executing code on the previous one?"
I made a test project which contains a clock timer in screen 1 that fires every second.
On Screen1 TimerAllwaysFires is set to true in the designer
I packaged the app and installed it on my tablet.

I started the clock and immediately opened screen 2, counted to 10, then closed screen 2.
The counter value showed 12.
So the Clock continued to run in Screen1 when Screen2 was open.
So the calling screen is kept in memory which explains how returning to a calling screen can resume execution in the other screen closed event block.
When using the Companion app, however when closing a screen the calling screen Initialize block executes so you need to test this with a packaged app as Taifun said.
---
sf

CloseScreenTest.aia

Italo

unread,
Oct 12, 2015, 12:32:22 PM10/12/15
to MIT App Inventor Forum
Thanks for the example Scott.
I like the method EstebanZ posted. It's cleaner and looks more logical. The "Triblehunter" method  doesn't.

Reply all
Reply to author
Forward
0 new messages