<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:blogger='http://schemas.google.com/blogger/2008' xmlns:georss='http://www.georss.org/georss' xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-6895501055750567199</id><updated>2025-11-04T15:45:41.064+01:00</updated><category term="android básico"/><category term="kotlin básico"/><category term="android studio"/><category term="clases"/><category term="ejemplos"/><category term="colecciones"/><category term="funciones"/><category term="control de flujo"/><category term="tipos"/><category term="bucles"/><category term="intellJ IDEA"/><category term="kotlinJS"/><category term="condicionales"/><category term="input/output"/><category term="recursos"/><title type='text'>Kotlin Doc</title><subtitle type='html'>Kotlin &amp;amp; Android</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='https://kotlindoc.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='https://www.blogger.com/feeds/6895501055750567199/posts/default'/><link rel='alternate' type='text/html' href='https://kotlindoc.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><link rel='next' type='application/atom+xml' href='https://www.blogger.com/feeds/6895501055750567199/posts/default?start-index=26&amp;max-results=25'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>93</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-6895501055750567199.post-8164400217347663811</id><published>2019-11-03T00:10:00.000+01:00</published><updated>2019-11-03T00:10:08.746+01:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="ejemplos"/><category scheme="http://www.blogger.com/atom/ns#" term="kotlinJS"/><title type='text'>Ejemplo: JavaScript desde Kotlin</title><content type='html'>&lt;img alt=&quot;JavaScript desde Kotlin&quot; border=&quot;0&quot; data-original-height=&quot;750&quot; data-original-width=&quot;750&quot; height=&quot;320&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiF2z7nQ6rKsBJv2CXTbhd8gmXWZuFlwXZVxvteN48T4pVazvge-f-7ELae7x47vitaVr0KMgmW5OVQ-s-MobqcMlOcqApNRSlLX6BtZs2a9kn7e3bIkc2USj1cHNe3MWVbenSR5dM0hQA/s320/kotlinjs.png&quot; title=&quot;JavaScript desde Kotlin&quot; width=&quot;320&quot; /&gt;&lt;br /&gt;
&lt;br /&gt;
Página web desarrollada con &lt;a href=&quot;https://kotlindoc.blogspot.com/search/label/kotlinJS&quot; title=&quot;Mostrar entradas etiquetadas como KotlinJS&quot;&gt;KotlinJS&lt;/a&gt; con ejemplos de:&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;Cómo utilizar botones HTML para producir acciones (abrir ventanas de alerta, cambios de estilo, actualizar variables).&lt;/li&gt;
&lt;li&gt;Insertar código JavaScript con la función js(&quot;...&quot;).&lt;/li&gt;
&lt;li&gt;Declarar de forma segura API de JavaScript con la palabra reservada &lt;i&gt;external&lt;/i&gt;.&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
Más detalles en &lt;a href=&quot;https://kotlinlang.org/docs/reference/js-interop.html&quot;&gt;Calling JavaScript from Kotlin&lt;/a&gt; (en inglés).&lt;br /&gt;
&lt;br /&gt;
En el navegador aparece así:&lt;br /&gt;
&lt;br /&gt;
&lt;img border=&quot;0&quot; data-original-height=&quot;416&quot; data-original-width=&quot;573&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiTdRZIQwm5wJsJhslOEoOVhZoEmSu492zeLAyKFhWhZnoxOlBLjOpez2MKmJhTxmJNI1VXGP1818uBZMNKrIg1e91i-1efo7mJGpvv6yPto0Y0DQdHMGV1NnOss2IPyAdDnUlIbOuF_So/s1600/KotlinJS.gif&quot; /&gt;&lt;br /&gt;
&lt;br /&gt;
A continuación los archivos principales (&lt;i&gt;main.tk&lt;/i&gt;, &lt;i&gt;index.html&lt;/i&gt; y &lt;i&gt;estilo.css&lt;/i&gt;):&lt;br /&gt;
&lt;pre class=&quot;hl&quot;&gt;&lt;span class=&quot;hl slc&quot;&gt;// main.kt&lt;/span&gt;
&lt;span class=&quot;hl kwa&quot;&gt;import&lt;/span&gt; org&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;w3c&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;dom&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;HTMLButtonElement
&lt;span class=&quot;hl kwa&quot;&gt;import&lt;/span&gt; kotlin&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;browser&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;document

&lt;span class=&quot;hl slc&quot;&gt;// función de JavaScript que podemos usar como si fuera de Kotlin&lt;/span&gt;
external &lt;span class=&quot;hl kwa&quot;&gt;fun&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;alert&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;msg&lt;span class=&quot;hl opt&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;hl kwb&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;

&lt;span class=&quot;hl kwa&quot;&gt;fun&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;main&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;() {&lt;/span&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;var&lt;/span&gt; contador1 &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;hl num&quot;&gt;0&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;var&lt;/span&gt; contador2 &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;hl num&quot;&gt;0&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;var&lt;/span&gt; contador3 &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;hl num&quot;&gt;0&lt;/span&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;val&lt;/span&gt; h1 &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; document&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;createElement&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl str&quot;&gt;&quot;h1&quot;&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; h1&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;textContent &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;hl str&quot;&gt;&quot;Desarrollo Web con KotlinJS&quot;&lt;/span&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;val&lt;/span&gt; p1 &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; document&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;createElement&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl str&quot;&gt;&quot;p&quot;&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; p1&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;textContent &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;hl str&quot;&gt;&quot;Página web desarrollada con Kotlin JS con ejemplos de:&quot;&lt;/span&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;val&lt;/span&gt; ul1 &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; document&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;createElement&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl str&quot;&gt;&quot;ul&quot;&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;val&lt;/span&gt; li1 &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; document&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;createElement&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl str&quot;&gt;&quot;li&quot;&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; li1&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;textContent &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;hl str&quot;&gt;&quot;Cómo utilizar botones HTML para producir acciones.&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;val&lt;/span&gt; li2 &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; document&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;createElement&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl str&quot;&gt;&quot;li&quot;&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; li2&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;textContent &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;hl str&quot;&gt;&quot;Insertar código JavaScript con la función js(&lt;/span&gt;&lt;span class=&quot;hl esc&quot;&gt;\&quot;&lt;/span&gt;&lt;span class=&quot;hl str&quot;&gt;...&lt;/span&gt;&lt;span class=&quot;hl esc&quot;&gt;\&quot;&lt;/span&gt;&lt;span class=&quot;hl str&quot;&gt;)&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;val&lt;/span&gt; li3 &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; document&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;createElement&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl str&quot;&gt;&quot;li&quot;&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; li3&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;textContent &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;hl str&quot;&gt;&quot;Declarar de forma segura API de JavaScript con la palabra reservada&lt;/span&gt; &lt;span class=&quot;hl esc&quot;&gt;\&quot;&lt;/span&gt;&lt;span class=&quot;hl str&quot;&gt;external&lt;/span&gt;&lt;span class=&quot;hl esc&quot;&gt;\&quot;&lt;/span&gt;&lt;span class=&quot;hl str&quot;&gt;.&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; ul1&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;append&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;li1&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; li2&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; li3&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl slc&quot;&gt;// BOTÓN 1&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;val&lt;/span&gt; boton1 &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; document&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;createElement&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl str&quot;&gt;&quot;button&quot;&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;hl kwa&quot;&gt;as&lt;/span&gt; HTMLButtonElement
&amp;nbsp;&amp;nbsp;&amp;nbsp; boton1&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;type &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;hl str&quot;&gt;&quot;button&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; boton1&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;textContent &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;hl str&quot;&gt;&quot;Botón 1&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; boton1&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;addEventListener&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl str&quot;&gt;&quot;click&quot;&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;, {&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;contador1 &lt;span class=&quot;hl opt&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;hl num&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;) {&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; boton1&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;style&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;background &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;hl str&quot;&gt;&quot;#f44336&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwd&quot;&gt;js&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl str&quot;&gt;&quot;alert(&lt;/span&gt;&lt;span class=&quot;hl esc&quot;&gt;\&quot;&lt;/span&gt;&lt;span class=&quot;hl str&quot;&gt;Boton 1 pulsado!&lt;/span&gt;&lt;span class=&quot;hl esc&quot;&gt;\&quot;&lt;/span&gt;&lt;span class=&quot;hl str&quot;&gt;)&quot;&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; contador1 &lt;span class=&quot;hl opt&quot;&gt;+=&lt;/span&gt; &lt;span class=&quot;hl num&quot;&gt;1&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; boton1&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;textContent &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; contador1&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;toString&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;()&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl opt&quot;&gt;})&lt;/span&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl slc&quot;&gt;// BOTÓN 2&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;val&lt;/span&gt; boton2 &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; document&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;createElement&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl str&quot;&gt;&quot;button&quot;&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;hl kwa&quot;&gt;as&lt;/span&gt; HTMLButtonElement
&amp;nbsp;&amp;nbsp;&amp;nbsp; boton2&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;type &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;hl str&quot;&gt;&quot;button&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; boton2&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;textContent &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;hl str&quot;&gt;&quot;Botón 2&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; boton2&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;addEventListener&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl str&quot;&gt;&quot;click&quot;&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;, {&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;contador2 &lt;span class=&quot;hl opt&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;hl num&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;) {&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; boton2&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;style&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;background &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;hl str&quot;&gt;&quot;#555555&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;val&lt;/span&gt; json &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;js&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl str&quot;&gt;&quot;{}&quot;&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; json&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;msg &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;hl str&quot;&gt;&quot;Botón 2 pulsado!&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwd&quot;&gt;js&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl str&quot;&gt;&quot;alert(JSON.stringify(json.msg))&quot;&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; contador2 &lt;span class=&quot;hl opt&quot;&gt;+=&lt;/span&gt; &lt;span class=&quot;hl num&quot;&gt;1&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; boton2&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;textContent &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; contador2&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;toString&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;()&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl opt&quot;&gt;})&lt;/span&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl slc&quot;&gt;// BOTÓN 3&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;val&lt;/span&gt; boton3 &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; document&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;createElement&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl str&quot;&gt;&quot;button&quot;&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;hl kwa&quot;&gt;as&lt;/span&gt; HTMLButtonElement
&amp;nbsp;&amp;nbsp;&amp;nbsp; boton3&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;type &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;hl str&quot;&gt;&quot;button&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; boton3&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;textContent &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;hl str&quot;&gt;&quot;Botón 3&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; boton3&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;addEventListener&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl str&quot;&gt;&quot;click&quot;&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;, {&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;contador3 &lt;span class=&quot;hl opt&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;hl num&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;) {&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; boton3&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;style&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;background &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;hl str&quot;&gt;&quot;#008CBA&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwd&quot;&gt;alert&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl str&quot;&gt;&quot;Boton 3 pulsado!&quot;&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;&amp;nbsp; &lt;span class=&quot;hl slc&quot;&gt;// invoca función de JavaScript&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; contador3 &lt;span class=&quot;hl opt&quot;&gt;+=&lt;/span&gt; &lt;span class=&quot;hl num&quot;&gt;1&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; boton3&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;textContent &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; contador3&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;toString&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;()&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl opt&quot;&gt;})&lt;/span&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp; document&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;body?&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;append&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;h1&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; p1&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; ul1&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; boton1&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; boton2&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; boton3&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt;&lt;/pre&gt;
&lt;pre class=&quot;hl&quot;&gt;&lt;span class=&quot;hl com&quot;&gt;&amp;lt;!--index.html--&amp;gt;&lt;/span&gt;
&lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;!DOCTYPE&lt;/span&gt; html&lt;span class=&quot;hl kwa&quot;&gt;&amp;gt;&lt;/span&gt;
&lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;html&lt;/span&gt; &lt;span class=&quot;hl kwb&quot;&gt;lang&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;en&quot;&lt;/span&gt;&lt;span class=&quot;hl kwa&quot;&gt;&amp;gt;&lt;/span&gt;
&lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;head&amp;gt;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;meta&lt;/span&gt; &lt;span class=&quot;hl kwb&quot;&gt;charset&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;UTF-8&quot;&lt;/span&gt;&lt;span class=&quot;hl kwa&quot;&gt;&amp;gt;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;title&amp;gt;&lt;/span&gt;alertJS&lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;/title&amp;gt;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;link&lt;/span&gt; &lt;span class=&quot;hl kwb&quot;&gt;rel&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;stylesheet&quot;&lt;/span&gt; &lt;span class=&quot;hl kwb&quot;&gt;href&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;estilo.css&quot;&lt;/span&gt;&lt;span class=&quot;hl kwa&quot;&gt;&amp;gt;&lt;/span&gt;
&lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;/head&amp;gt;&lt;/span&gt;
&lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;body&amp;gt;&lt;/span&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;script&lt;/span&gt; &lt;span class=&quot;hl kwb&quot;&gt;src&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;out/production/alertJS/lib/kotlin.js&quot;&lt;/span&gt;&lt;span class=&quot;hl kwa&quot;&gt;&amp;gt;&amp;lt;/script&amp;gt;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;script&lt;/span&gt; &lt;span class=&quot;hl kwb&quot;&gt;src&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;out/production/alertJS/alertJS.js&quot;&lt;/span&gt;&lt;span class=&quot;hl kwa&quot;&gt;&amp;gt;&amp;lt;/script&amp;gt;&lt;/span&gt;

&lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;/body&amp;gt;&lt;/span&gt;
&lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;/html&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;pre class=&quot;hl&quot;&gt;&lt;span class=&quot;hl com&quot;&gt;/* estilo.css */&lt;/span&gt;
button &lt;span class=&quot;hl opt&quot;&gt;{&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;background-color&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;hl num&quot;&gt;#4CAF50&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;color&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;:&lt;/span&gt; white&lt;span class=&quot;hl opt&quot;&gt;;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;padding&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;hl num&quot;&gt;15px 32px&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;text-align&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;:&lt;/span&gt; center&lt;span class=&quot;hl opt&quot;&gt;;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;text-decoration&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;:&lt;/span&gt; none&lt;span class=&quot;hl opt&quot;&gt;;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;display&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;:&lt;/span&gt; block&lt;span class=&quot;hl opt&quot;&gt;;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;font-size&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;hl num&quot;&gt;20px&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;width&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;hl num&quot;&gt;200px&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt;&lt;/pre&gt;</content><link rel='replies' type='application/atom+xml' href='https://kotlindoc.blogspot.com/feeds/8164400217347663811/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='https://kotlindoc.blogspot.com/2019/11/ejemplo-javascript-desde-kotlin.html#comment-form' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='https://www.blogger.com/feeds/6895501055750567199/posts/default/8164400217347663811'/><link rel='self' type='application/atom+xml' href='https://www.blogger.com/feeds/6895501055750567199/posts/default/8164400217347663811'/><link rel='alternate' type='text/html' href='https://kotlindoc.blogspot.com/2019/11/ejemplo-javascript-desde-kotlin.html' title='Ejemplo: JavaScript desde Kotlin'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiF2z7nQ6rKsBJv2CXTbhd8gmXWZuFlwXZVxvteN48T4pVazvge-f-7ELae7x47vitaVr0KMgmW5OVQ-s-MobqcMlOcqApNRSlLX6BtZs2a9kn7e3bIkc2USj1cHNe3MWVbenSR5dM0hQA/s72-c/kotlinjs.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6895501055750567199.post-671309955079971064</id><published>2019-11-02T00:00:00.000+01:00</published><updated>2019-11-01T23:58:54.063+01:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="ejemplos"/><category scheme="http://www.blogger.com/atom/ns#" term="kotlinJS"/><title type='text'>Ejemplo de Kotlin JS para desarollo web</title><content type='html'>&lt;img alt=&quot;Kotlin JS&quot; border=&quot;0&quot; data-original-height=&quot;385&quot; data-original-width=&quot;768&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjEDFlq2PVBW-KkddjcOcBJncjqy5HImEMIlmiYkA0OsUB1zpqPTf0WrRXAv3KMXO5SVSHrdYYwmF5mqpau7OTsyovNWPmh8DPdDzTAtdJ7nhr69oPQPBiPOx7xprpuE6DMNL5fGWOax4Y/s1600/kotlinWeb.png&quot; title=&quot;Kotlin JS&quot; /&gt;&lt;br /&gt;
&lt;br /&gt;
Un ejemplo simple, similar al código que vimos en la entrada &lt;a href=&quot;https://kotlindoc.blogspot.com/2019/11/ejemplo-html-builder-kotlinjs.html&quot;&gt;Ejemplo: Html Builder (KotlinJS)&lt;/a&gt;, sobre cómo usar Kotlin en el desarrollo web en lugar de Javascript. Adaptación del código &lt;i&gt;Kotlin JS for Web development&lt;/i&gt; disponible en el repositorio &lt;a href=&quot;https://github.com/genbetadev/kotlinjs-example&quot;&gt;kotlinjs-example&lt;/a&gt;.&lt;br /&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;pre class=&quot;hl&quot;&gt;&lt;span class=&quot;hl com&quot;&gt;&amp;lt;!--index.html--&amp;gt;&lt;/span&gt;
&lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;!DOCTYPE&lt;/span&gt; html&lt;span class=&quot;hl kwa&quot;&gt;&amp;gt;&lt;/span&gt;
&lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;html&lt;/span&gt; &lt;span class=&quot;hl kwb&quot;&gt;lang&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;en&quot;&lt;/span&gt;&lt;span class=&quot;hl kwa&quot;&gt;&amp;gt;&lt;/span&gt;
&lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;head&amp;gt;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;meta&lt;/span&gt; &lt;span class=&quot;hl kwb&quot;&gt;charset&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;UTF-8&quot;&lt;/span&gt;&lt;span class=&quot;hl kwa&quot;&gt;&amp;gt;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;title&amp;gt;&lt;/span&gt;KotlinJS&lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;/title&amp;gt;&lt;/span&gt;
&lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;/head&amp;gt;&lt;/span&gt;
&lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;body&amp;gt;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;script&lt;/span&gt; &lt;span class=&quot;hl kwb&quot;&gt;src&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;out/production/Kotlin Web/lib/kotlin.js&quot;&lt;/span&gt;&lt;span class=&quot;hl kwa&quot;&gt;&amp;gt;&amp;lt;/script&amp;gt;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;script&lt;/span&gt; &lt;span class=&quot;hl kwb&quot;&gt;src&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;out/production/Kotlin Web/Kotlin Web.js&quot;&lt;/span&gt;&lt;span class=&quot;hl kwa&quot;&gt;&amp;gt;&amp;lt;/script&amp;gt;&lt;/span&gt;
&lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;/body&amp;gt;&lt;/span&gt;
&lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;/html&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;pre class=&quot;hl&quot;&gt;&lt;span class=&quot;hl slc&quot;&gt;//Main.tk&lt;/span&gt;
&lt;span class=&quot;hl kwa&quot;&gt;import&lt;/span&gt; html&lt;span class=&quot;hl opt&quot;&gt;.*&lt;/span&gt;
&lt;span class=&quot;hl kwa&quot;&gt;import&lt;/span&gt; kotlin&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;browser&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;document

&lt;span class=&quot;hl kwa&quot;&gt;fun&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;main&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;() {&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; document&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;body?&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;apply &lt;span class=&quot;hl opt&quot;&gt;{&lt;/span&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwd&quot;&gt;h1&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl str&quot;&gt;&quot;Desarrollo Web con KotlinJS&quot;&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; div &lt;span class=&quot;hl opt&quot;&gt;{&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwd&quot;&gt;p&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl str&quot;&gt;&quot;Test para generar código HTML con Kotlin&quot;&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwd&quot;&gt;p&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl str&quot;&gt;&quot;Iterando sobre un rango con for:&quot;&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ul &lt;span class=&quot;hl opt&quot;&gt;{&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;i &lt;span class=&quot;hl kwa&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;hl num&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl num&quot;&gt;.10&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;) {&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;i &lt;span class=&quot;hl opt&quot;&gt;&amp;lt;&lt;/span&gt; &lt;span class=&quot;hl num&quot;&gt;10&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;li&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl str&quot;&gt;&quot;0&lt;/span&gt;&lt;span class=&quot;hl ipl&quot;&gt;$i&lt;/span&gt;&lt;span class=&quot;hl str&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;hl kwa&quot;&gt;else&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;li&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl str&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;hl ipl&quot;&gt;$i&lt;/span&gt;&lt;span class=&quot;hl str&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt;&lt;/pre&gt;
&lt;pre class=&quot;hl&quot;&gt;&lt;span class=&quot;hl slc&quot;&gt;//html.kt&lt;/span&gt;
&lt;span class=&quot;hl kwa&quot;&gt;package&lt;/span&gt; html

&lt;span class=&quot;hl kwa&quot;&gt;import&lt;/span&gt; org&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;w3c&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;dom&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;Element
&lt;span class=&quot;hl kwa&quot;&gt;import&lt;/span&gt; kotlin&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;browser&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;document

&lt;span class=&quot;hl slc&quot;&gt;// enumeramos las etiquetas HTML&lt;/span&gt;
&lt;span class=&quot;hl kwa&quot;&gt;enum class&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;HtmlTag&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl kwa&quot;&gt;val&lt;/span&gt; text&lt;span class=&quot;hl opt&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;hl kwb&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;) {&lt;/span&gt;
    &lt;span class=&quot;hl kwd&quot;&gt;H1&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl str&quot;&gt;&quot;h1&quot;&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;),&lt;/span&gt;
    &lt;span class=&quot;hl kwd&quot;&gt;DIV&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl str&quot;&gt;&quot;div&quot;&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;),&lt;/span&gt;
    &lt;span class=&quot;hl kwd&quot;&gt;P&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl str&quot;&gt;&quot;p&quot;&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;),&lt;/span&gt;
    &lt;span class=&quot;hl kwd&quot;&gt;UL&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl str&quot;&gt;&quot;ul&quot;&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;),&lt;/span&gt;
    &lt;span class=&quot;hl kwd&quot;&gt;LI&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl str&quot;&gt;&quot;li&quot;&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;hl slc&quot;&gt;// funciones sobre objetos de tipo Element que devuelven el resultado&lt;/span&gt;
&lt;span class=&quot;hl slc&quot;&gt;// de una función que toma como primer argumento un valor del enum&lt;/span&gt;
&lt;span class=&quot;hl kwa&quot;&gt;fun&lt;/span&gt; Element&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;h1&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;text&lt;span class=&quot;hl opt&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;hl kwb&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;):&lt;/span&gt; Element &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;textElement&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;HtmlTag&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;H1&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; text&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;hl kwa&quot;&gt;fun&lt;/span&gt; Element&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;div&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;f&lt;span class=&quot;hl opt&quot;&gt;:&lt;/span&gt; Element&lt;span class=&quot;hl opt&quot;&gt;.() -&amp;gt;&lt;/span&gt; &lt;span class=&quot;hl kwb&quot;&gt;Unit&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;) =&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;structuralElement&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;HtmlTag&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;DIV&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; f&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;hl kwa&quot;&gt;fun&lt;/span&gt; Element&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;p&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;text&lt;span class=&quot;hl opt&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;hl kwb&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;):&lt;/span&gt; Element &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;textElement&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;HtmlTag&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;P&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; text&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;hl kwa&quot;&gt;fun&lt;/span&gt; Element&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;ul&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;f&lt;span class=&quot;hl opt&quot;&gt;:&lt;/span&gt; Element&lt;span class=&quot;hl opt&quot;&gt;.() -&amp;gt;&lt;/span&gt; &lt;span class=&quot;hl kwb&quot;&gt;Unit&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;) =&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;structuralElement&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;HtmlTag&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;UL&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; f&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;hl kwa&quot;&gt;fun&lt;/span&gt; Element&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;li&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;text&lt;span class=&quot;hl opt&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;hl kwb&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;) =&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;textElement&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;HtmlTag&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;LI&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; text&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;

&lt;span class=&quot;hl kwa&quot;&gt;private fun&lt;/span&gt; Element&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;textElement&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;tag&lt;span class=&quot;hl opt&quot;&gt;:&lt;/span&gt; HtmlTag&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; text&lt;span class=&quot;hl opt&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;hl kwb&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;):&lt;/span&gt; Element &lt;span class=&quot;hl opt&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;hl kwa&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;createTag&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;tag&lt;span class=&quot;hl opt&quot;&gt;) {&lt;/span&gt; textContent &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; text &lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;hl kwa&quot;&gt;private fun&lt;/span&gt; Element&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;structuralElement&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;tag&lt;span class=&quot;hl opt&quot;&gt;:&lt;/span&gt; HtmlTag&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; f&lt;span class=&quot;hl opt&quot;&gt;:&lt;/span&gt; Element&lt;span class=&quot;hl opt&quot;&gt;.() -&amp;gt;&lt;/span&gt; &lt;span class=&quot;hl kwb&quot;&gt;Unit&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;):&lt;/span&gt; Element &lt;span class=&quot;hl opt&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;hl kwa&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;createTag&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;tag&lt;span class=&quot;hl opt&quot;&gt;) {&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;f&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;() }&lt;/span&gt;
&lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;hl kwa&quot;&gt;private fun&lt;/span&gt; Element&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;createTag&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;tag&lt;span class=&quot;hl opt&quot;&gt;:&lt;/span&gt; HtmlTag&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; f&lt;span class=&quot;hl opt&quot;&gt;:&lt;/span&gt; Element&lt;span class=&quot;hl opt&quot;&gt;.() -&amp;gt;&lt;/span&gt; &lt;span class=&quot;hl kwb&quot;&gt;Unit&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;):&lt;/span&gt; Element &lt;span class=&quot;hl opt&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;hl kwa&quot;&gt;val&lt;/span&gt; element &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; document&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;createElement&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;tag&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;text&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;
    element&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;f&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;()&lt;/span&gt;
    &lt;span class=&quot;hl kwd&quot;&gt;append&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;element&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;hl kwa&quot;&gt;return&lt;/span&gt; element
&lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt;
&lt;/pre&gt;
El resultado se ve así en el navegador:&lt;br /&gt;&lt;br /&gt;
&lt;img border=&quot;0&quot; data-original-height=&quot;407&quot; data-original-width=&quot;529&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhKAbim2bAyjoQv3pljQMxT71Jt8CGc3QbVkzOtxwtjWe_ChYt_Fx9t9gwTdpUAF6QGFYfuL4cZqnRFLX7haWmMAD7OqaQdajxFbNqe88tw5fx64_U3M4ezDzJIZuI2U3pxVxC9zHxtc6A/s1600/kotlinJS.png&quot; /&gt;</content><link rel='replies' type='application/atom+xml' href='https://kotlindoc.blogspot.com/feeds/671309955079971064/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='https://kotlindoc.blogspot.com/2019/11/ejemplo-de-kotlin-js-para-desarollo-web.html#comment-form' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='https://www.blogger.com/feeds/6895501055750567199/posts/default/671309955079971064'/><link rel='self' type='application/atom+xml' href='https://www.blogger.com/feeds/6895501055750567199/posts/default/671309955079971064'/><link rel='alternate' type='text/html' href='https://kotlindoc.blogspot.com/2019/11/ejemplo-de-kotlin-js-para-desarollo-web.html' title='Ejemplo de Kotlin JS para desarollo web'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjEDFlq2PVBW-KkddjcOcBJncjqy5HImEMIlmiYkA0OsUB1zpqPTf0WrRXAv3KMXO5SVSHrdYYwmF5mqpau7OTsyovNWPmh8DPdDzTAtdJ7nhr69oPQPBiPOx7xprpuE6DMNL5fGWOax4Y/s72-c/kotlinWeb.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6895501055750567199.post-2067968075011630226</id><published>2019-11-01T15:53:00.002+01:00</published><updated>2019-11-01T15:53:15.893+01:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="ejemplos"/><category scheme="http://www.blogger.com/atom/ns#" term="kotlinJS"/><title type='text'>Ejemplo: Html Builder (KotlinJS)</title><content type='html'>&lt;img alt=&quot;Ejemplo: Html Builder&quot; border=&quot;0&quot; data-original-height=&quot;600&quot; data-original-width=&quot;1000&quot; height=&quot;384&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhCzy_Rki3nUSeOQDvIHkFHfe9U2Mm4vesPWgIa8-B0OXfVDeFK598O8iPg1iugt4QqhBa_jrVffk_61iXT0RPOYROIctODiDPZxfUnVTVIETDxOVlia-_1ERfQRgD2vPGpdxuw74Oqn04/s640/kotlinJSlogo.png&quot; title=&quot;Ejemplo: Html Builder&quot; width=&quot;640&quot; /&gt;&lt;br /&gt;
&lt;br /&gt;
Ejemplo para crear una web html con Kotlin ilustrando y ampliando el contenido expuesto en la entrada &lt;a href=&quot;https://kotlindoc.blogspot.com/2019/10/introduccion-kotlinjs-desarrollo-web.html&quot;&gt;Introducción a KotlinJS: Desarrollo web con Kotlin&lt;/a&gt;.&lt;br /&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;br /&gt;
Observa en el código que &lt;i&gt;getHTML&lt;/i&gt; se refiere a una función que toma como argumento una expresión &lt;i&gt;lambda&lt;/i&gt; que utiliza una instancia de la clase HTML, y &lt;i&gt;headTag&lt;/i&gt; y &lt;i&gt;bodyTag&lt;/i&gt; son funciones miembro de la clase HTML, y agregamos el texto a las etiquetas html invocando el operador &lt;i&gt;String.unaryPlus()&lt;/i&gt;. Para más detalles puedes ver (en inglés): &lt;a href=&quot;https://kotlinlang.org/docs/reference/type-safe-builders.html&quot;&gt;Type-Safe Builders&lt;/a&gt;
&lt;br /&gt;
&lt;pre class=&quot;hl&quot;&gt;&lt;span class=&quot;hl com&quot;&gt;&amp;lt;!--index.html--&amp;gt;&lt;/span&gt;
&lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;!DOCTYPE&lt;/span&gt; html&lt;span class=&quot;hl kwa&quot;&gt;&amp;gt;&lt;/span&gt;
&lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;html&lt;/span&gt; &lt;span class=&quot;hl kwb&quot;&gt;lang&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;en&quot;&lt;/span&gt;&lt;span class=&quot;hl kwa&quot;&gt;&amp;gt;&lt;/span&gt;
&lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;head&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;meta&lt;/span&gt; &lt;span class=&quot;hl kwb&quot;&gt;charset&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;UTF-8&quot;&lt;/span&gt;&lt;span class=&quot;hl kwa&quot;&gt;&amp;gt;&lt;/span&gt;
&lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;/head&amp;gt;&lt;/span&gt;

&lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;body&amp;gt;&lt;/span&gt;

    &lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;script&lt;/span&gt; &lt;span class=&quot;hl kwb&quot;&gt;src&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;out/production/html/lib/kotlin.js&quot;&lt;/span&gt;&lt;span class=&quot;hl kwa&quot;&gt;&amp;gt;&amp;lt;/script&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;script&lt;/span&gt; &lt;span class=&quot;hl kwb&quot;&gt;src&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;out/production/html/html.js&quot;&lt;/span&gt;&lt;span class=&quot;hl kwa&quot;&gt;&amp;gt;&amp;lt;/script&amp;gt;&lt;/span&gt;

&lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;/body&amp;gt;&lt;/span&gt;
&lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;/html&amp;gt;&lt;/span&gt;
&lt;/pre&gt;
&lt;pre class=&quot;hl&quot;&gt;&lt;span class=&quot;hl slc&quot;&gt;//html.kt&lt;/span&gt;
&lt;span class=&quot;hl kwa&quot;&gt;package&lt;/span&gt; html

&lt;span class=&quot;hl kwa&quot;&gt;import&lt;/span&gt; kotlin&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;browser&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;document

&lt;span class=&quot;hl kwa&quot;&gt;fun&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;main&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;() {&lt;/span&gt;

    &lt;span class=&quot;hl kwa&quot;&gt;val&lt;/span&gt; codeHTML &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; getHTML &lt;span class=&quot;hl opt&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;hl slc&quot;&gt;// &amp;lt;head&amp;gt;&lt;/span&gt;
        headTag &lt;span class=&quot;hl opt&quot;&gt;{&lt;/span&gt;
            title &lt;span class=&quot;hl opt&quot;&gt;{ +&lt;/span&gt;&lt;span class=&quot;hl str&quot;&gt;&quot;KotlinJS&quot;&lt;/span&gt; &lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt;
        &lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt;
        &lt;span class=&quot;hl slc&quot;&gt;// &amp;lt;body&amp;gt;&lt;/span&gt;
        bodyTag &lt;span class=&quot;hl opt&quot;&gt;{&lt;/span&gt;
            h1Tag &lt;span class=&quot;hl opt&quot;&gt;{ +&lt;/span&gt;&lt;span class=&quot;hl str&quot;&gt;&quot;Desarrollo web con Kotlin&quot;&lt;/span&gt; &lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt;
            pTag &lt;span class=&quot;hl opt&quot;&gt;{&lt;/span&gt;
                &lt;span class=&quot;hl opt&quot;&gt;+&lt;/span&gt;&lt;span class=&quot;hl str&quot;&gt;&quot;Página web con etiquetas de marcado&quot;&lt;/span&gt;
                &lt;span class=&quot;hl opt&quot;&gt;+&lt;/span&gt;&lt;span class=&quot;hl str&quot;&gt;&quot;HTML &amp;lt;h1&amp;gt;, &amp;lt;p&amp;gt;, &amp;lt;b&amp;gt;, &amp;lt;a&amp;gt;, &amp;lt;ul&amp;gt;, &amp;lt;li&amp;gt;&quot;&lt;/span&gt;
                &lt;span class=&quot;hl opt&quot;&gt;+&lt;/span&gt;&lt;span class=&quot;hl str&quot;&gt;&quot;desarrollada con Kotlin&quot;&lt;/span&gt;
            &lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt;
            pTag &lt;span class=&quot;hl opt&quot;&gt;{&lt;/span&gt;
                bTag &lt;span class=&quot;hl opt&quot;&gt;{ +&lt;/span&gt;&lt;span class=&quot;hl str&quot;&gt;&quot;Kotlin Doc&quot;&lt;/span&gt; &lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt;
                &lt;span class=&quot;hl opt&quot;&gt;+&lt;/span&gt;&lt;span class=&quot;hl str&quot;&gt;&quot;comparte y divulga en español&quot;&lt;/span&gt;
                &lt;span class=&quot;hl opt&quot;&gt;+&lt;/span&gt;&lt;span class=&quot;hl str&quot;&gt;&quot;información y ejemplos sobre programación con Kotlin y Android. Visita&quot;&lt;/span&gt;
                &lt;span class=&quot;hl kwd&quot;&gt;aTag&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;href &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;hl str&quot;&gt;&quot;https://kotlindoc.blogspot.com&quot;&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;) {&lt;/span&gt;
                    &lt;span class=&quot;hl opt&quot;&gt;+&lt;/span&gt;&lt;span class=&quot;hl str&quot;&gt;&quot;Kotlin Doc&quot;&lt;/span&gt;
                &lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt;
            &lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt;
            pTag &lt;span class=&quot;hl opt&quot;&gt;{&lt;/span&gt;
                &lt;span class=&quot;hl opt&quot;&gt;+&lt;/span&gt;&lt;span class=&quot;hl str&quot;&gt;&quot;La tabla de multiplicar del 2 iterando sobre un rango con un bucle for:&quot;&lt;/span&gt;
                ulTag &lt;span class=&quot;hl opt&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;hl kwa&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;i &lt;span class=&quot;hl kwa&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;hl num&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl num&quot;&gt;.10&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt; li &lt;span class=&quot;hl opt&quot;&gt;{ +&lt;/span&gt;&lt;span class=&quot;hl str&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;hl ipl&quot;&gt;$i&lt;/span&gt; &lt;span class=&quot;hl str&quot;&gt;* 2 =&lt;/span&gt; &lt;span class=&quot;hl ipl&quot;&gt;${i * 2}&lt;/span&gt;&lt;span class=&quot;hl str&quot;&gt;&quot;&lt;/span&gt; &lt;span class=&quot;hl opt&quot;&gt;} }&lt;/span&gt;
            &lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt;
        &lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt;
    &lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt;
    document&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;body?&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;appendChild&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;codeHTML&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;elemento&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;hl slc&quot;&gt;// Clase abstracta&lt;/span&gt;
&lt;span class=&quot;hl kwa&quot;&gt;abstract class&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;TagHTML&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;name&lt;span class=&quot;hl opt&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;hl kwb&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;) {&lt;/span&gt;
    &lt;span class=&quot;hl kwa&quot;&gt;val&lt;/span&gt; elemento &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; document&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;createElement&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;name&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;hl kwa&quot;&gt;protected fun&lt;/span&gt; &lt;span class=&quot;hl opt&quot;&gt;&amp;lt;&lt;/span&gt;T &lt;span class=&quot;hl opt&quot;&gt;:&lt;/span&gt; TagHTML&lt;span class=&quot;hl opt&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;initTag&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;tag&lt;span class=&quot;hl opt&quot;&gt;:&lt;/span&gt; T&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; init&lt;span class=&quot;hl opt&quot;&gt;:&lt;/span&gt; T&lt;span class=&quot;hl opt&quot;&gt;.() -&amp;gt;&lt;/span&gt; &lt;span class=&quot;hl kwb&quot;&gt;Unit&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;):&lt;/span&gt; T &lt;span class=&quot;hl opt&quot;&gt;{&lt;/span&gt;
        tag&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;init&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;()&lt;/span&gt;
        elemento&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;appendChild&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;tag&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;elemento&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;
        &lt;span class=&quot;hl kwa&quot;&gt;return&lt;/span&gt; tag
    &lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;hl slc&quot;&gt;// Clase Abstracta que herada de TagHTML&lt;/span&gt;
&lt;span class=&quot;hl kwa&quot;&gt;abstract class&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;TagTextHTML&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;name&lt;span class=&quot;hl opt&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;hl kwb&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;) :&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;TagHTML&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;name&lt;span class=&quot;hl opt&quot;&gt;) {&lt;/span&gt;
    operator &lt;span class=&quot;hl kwa&quot;&gt;fun&lt;/span&gt; &lt;span class=&quot;hl kwb&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;unaryPlus&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;() {&lt;/span&gt;
        elemento&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;appendChild&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;document&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;createTextNode&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl str&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;hl ipl&quot;&gt;$this&lt;/span&gt; &lt;span class=&quot;hl str&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;))&lt;/span&gt;
    &lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;hl slc&quot;&gt;// Clases que heredan de TagTextHTML&lt;/span&gt;
&lt;span class=&quot;hl kwa&quot;&gt;class&lt;/span&gt; HTML &lt;span class=&quot;hl opt&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;TagTextHTML&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl str&quot;&gt;&quot;html&quot;&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;) {&lt;/span&gt;
    &lt;span class=&quot;hl kwa&quot;&gt;fun&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;headTag&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;init&lt;span class=&quot;hl opt&quot;&gt;:&lt;/span&gt; Head&lt;span class=&quot;hl opt&quot;&gt;.() -&amp;gt;&lt;/span&gt; &lt;span class=&quot;hl kwb&quot;&gt;Unit&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;) =&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;initTag&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;Head&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(),&lt;/span&gt; init&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;hl kwa&quot;&gt;fun&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;bodyTag&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;init&lt;span class=&quot;hl opt&quot;&gt;:&lt;/span&gt; Body&lt;span class=&quot;hl opt&quot;&gt;.() -&amp;gt;&lt;/span&gt; &lt;span class=&quot;hl kwb&quot;&gt;Unit&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;) =&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;initTag&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;Body&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(),&lt;/span&gt; init&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;hl kwa&quot;&gt;class&lt;/span&gt; Head &lt;span class=&quot;hl opt&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;TagTextHTML&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl str&quot;&gt;&quot;head&quot;&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;) {&lt;/span&gt;
    &lt;span class=&quot;hl kwa&quot;&gt;fun&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;title&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;init&lt;span class=&quot;hl opt&quot;&gt;:&lt;/span&gt; Title&lt;span class=&quot;hl opt&quot;&gt;.() -&amp;gt;&lt;/span&gt; &lt;span class=&quot;hl kwb&quot;&gt;Unit&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;) =&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;initTag&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;Title&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(),&lt;/span&gt; init&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;hl kwa&quot;&gt;class&lt;/span&gt; Title &lt;span class=&quot;hl opt&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;TagTextHTML&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl str&quot;&gt;&quot;title&quot;&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;

&lt;span class=&quot;hl slc&quot;&gt;// Clase abstracta&lt;/span&gt;
&lt;span class=&quot;hl kwa&quot;&gt;abstract class&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;BodyTag&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;name&lt;span class=&quot;hl opt&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;hl kwb&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;) :&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;TagTextHTML&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;name&lt;span class=&quot;hl opt&quot;&gt;) {&lt;/span&gt;
    &lt;span class=&quot;hl kwa&quot;&gt;fun&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;bTag&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;init&lt;span class=&quot;hl opt&quot;&gt;:&lt;/span&gt; B&lt;span class=&quot;hl opt&quot;&gt;.() -&amp;gt;&lt;/span&gt; &lt;span class=&quot;hl kwb&quot;&gt;Unit&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;) =&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;initTag&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;B&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(),&lt;/span&gt; init&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;hl kwa&quot;&gt;fun&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;pTag&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;init&lt;span class=&quot;hl opt&quot;&gt;:&lt;/span&gt; P&lt;span class=&quot;hl opt&quot;&gt;.() -&amp;gt;&lt;/span&gt; &lt;span class=&quot;hl kwb&quot;&gt;Unit&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;) =&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;initTag&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;P&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(),&lt;/span&gt; init&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;hl kwa&quot;&gt;fun&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;h1Tag&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;init&lt;span class=&quot;hl opt&quot;&gt;:&lt;/span&gt; H1&lt;span class=&quot;hl opt&quot;&gt;.() -&amp;gt;&lt;/span&gt; &lt;span class=&quot;hl kwb&quot;&gt;Unit&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;) =&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;initTag&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;H1&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(),&lt;/span&gt; init&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;hl kwa&quot;&gt;fun&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;ulTag&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;init&lt;span class=&quot;hl opt&quot;&gt;:&lt;/span&gt; UL&lt;span class=&quot;hl opt&quot;&gt;.() -&amp;gt;&lt;/span&gt; &lt;span class=&quot;hl kwb&quot;&gt;Unit&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;) =&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;initTag&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;UL&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(),&lt;/span&gt; init&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;hl kwa&quot;&gt;fun&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;aTag&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;href&lt;span class=&quot;hl opt&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;hl kwb&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; init&lt;span class=&quot;hl opt&quot;&gt;:&lt;/span&gt; A&lt;span class=&quot;hl opt&quot;&gt;.() -&amp;gt;&lt;/span&gt; &lt;span class=&quot;hl kwb&quot;&gt;Unit&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;) {&lt;/span&gt;
        &lt;span class=&quot;hl kwa&quot;&gt;val&lt;/span&gt; a &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;initTag&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;A&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(),&lt;/span&gt; init&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;
        a&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;href &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; href
    &lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;hl slc&quot;&gt;// Clases que heredan de BodyTag&lt;/span&gt;
&lt;span class=&quot;hl kwa&quot;&gt;class&lt;/span&gt; Body &lt;span class=&quot;hl opt&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;BodyTag&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl str&quot;&gt;&quot;body&quot;&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;

&lt;span class=&quot;hl kwa&quot;&gt;class&lt;/span&gt; UL &lt;span class=&quot;hl opt&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;BodyTag&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl str&quot;&gt;&quot;ul&quot;&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;) {&lt;/span&gt;
    &lt;span class=&quot;hl kwa&quot;&gt;fun&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;li&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;init&lt;span class=&quot;hl opt&quot;&gt;:&lt;/span&gt; LI&lt;span class=&quot;hl opt&quot;&gt;.() -&amp;gt;&lt;/span&gt; &lt;span class=&quot;hl kwb&quot;&gt;Unit&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;) =&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;initTag&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;LI&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(),&lt;/span&gt; init&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;hl kwa&quot;&gt;class&lt;/span&gt; B &lt;span class=&quot;hl opt&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;BodyTag&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl str&quot;&gt;&quot;b&quot;&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;

&lt;span class=&quot;hl kwa&quot;&gt;class&lt;/span&gt; LI &lt;span class=&quot;hl opt&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;BodyTag&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl str&quot;&gt;&quot;li&quot;&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;

&lt;span class=&quot;hl kwa&quot;&gt;class&lt;/span&gt; P &lt;span class=&quot;hl opt&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;BodyTag&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl str&quot;&gt;&quot;p&quot;&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;

&lt;span class=&quot;hl kwa&quot;&gt;class&lt;/span&gt; H1 &lt;span class=&quot;hl opt&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;BodyTag&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl str&quot;&gt;&quot;h1&quot;&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;

&lt;span class=&quot;hl kwa&quot;&gt;class&lt;/span&gt; A &lt;span class=&quot;hl opt&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;BodyTag&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl str&quot;&gt;&quot;a&quot;&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;) {&lt;/span&gt;
    &lt;span class=&quot;hl kwa&quot;&gt;var&lt;/span&gt; href&lt;span class=&quot;hl opt&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;hl kwb&quot;&gt;String&lt;/span&gt;
        &lt;span class=&quot;hl kwd&quot;&gt;get&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;() =&lt;/span&gt; elemento&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;getAttribute&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl str&quot;&gt;&quot;href&quot;&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt; ?&lt;span class=&quot;hl opt&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;hl str&quot;&gt;&quot;&quot;&lt;/span&gt;
        &lt;span class=&quot;hl kwd&quot;&gt;set&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;value&lt;span class=&quot;hl opt&quot;&gt;) =&lt;/span&gt; elemento&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;setAttribute&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl str&quot;&gt;&quot;href&quot;&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; value&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;hl slc&quot;&gt;// función que toma como argumento una expresión lambda que utiliza una instancia de la clase HTML&lt;/span&gt;
&lt;span class=&quot;hl kwa&quot;&gt;fun&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;getHTML&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;init&lt;span class=&quot;hl opt&quot;&gt;:&lt;/span&gt; HTML&lt;span class=&quot;hl opt&quot;&gt;.() -&amp;gt;&lt;/span&gt; &lt;span class=&quot;hl kwb&quot;&gt;Unit&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;):&lt;/span&gt; HTML &lt;span class=&quot;hl opt&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;hl kwa&quot;&gt;val&lt;/span&gt; html &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;HTML&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;()&lt;/span&gt;
    html&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;init&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;()&lt;/span&gt;
    &lt;span class=&quot;hl kwa&quot;&gt;return&lt;/span&gt; html
&lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt;
&lt;/pre&gt;
&lt;br /&gt;
Lo que se visualiza en el navegador de esta manera:&lt;br /&gt;
&lt;br /&gt;
&lt;img border=&quot;0&quot; data-original-height=&quot;552&quot; data-original-width=&quot;603&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgB6p0vFIq0peyCSXSdPddwTW9cF0N6DjQKUzWHBKpEP_ZCt0NaKwheQphlff2JLk3q6OYBwaYfaUD0fItvIi0fXwG7UNJ0ULaR44iS_rDDfBYxFc4ILPaysdQy8dUdo6P2aXVM0doNlBI/s1600/kotlinJS.png&quot; /&gt;</content><link rel='replies' type='application/atom+xml' href='https://kotlindoc.blogspot.com/feeds/2067968075011630226/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='https://kotlindoc.blogspot.com/2019/11/ejemplo-html-builder-kotlinjs.html#comment-form' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='https://www.blogger.com/feeds/6895501055750567199/posts/default/2067968075011630226'/><link rel='self' type='application/atom+xml' href='https://www.blogger.com/feeds/6895501055750567199/posts/default/2067968075011630226'/><link rel='alternate' type='text/html' href='https://kotlindoc.blogspot.com/2019/11/ejemplo-html-builder-kotlinjs.html' title='Ejemplo: Html Builder (KotlinJS)'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhCzy_Rki3nUSeOQDvIHkFHfe9U2Mm4vesPWgIa8-B0OXfVDeFK598O8iPg1iugt4QqhBa_jrVffk_61iXT0RPOYROIctODiDPZxfUnVTVIETDxOVlia-_1ERfQRgD2vPGpdxuw74Oqn04/s72-c/kotlinJSlogo.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6895501055750567199.post-2723864628347850514</id><published>2019-10-29T08:00:00.000+01:00</published><updated>2019-10-29T08:00:16.205+01:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="intellJ IDEA"/><category scheme="http://www.blogger.com/atom/ns#" term="kotlinJS"/><title type='text'>Introducción a KotlinJS: Desarrollo web con Kotlin</title><content type='html'>&lt;img alt=&quot;Introducción a KotlinJS: Desarrollo web con Kotlin&quot; border=&quot;0&quot; data-original-height=&quot;383&quot; data-original-width=&quot;736&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh1yxMBIJt4oFmc6vioFhSyDALB0MVnqMYM9qvQyYhVGLGUnLDSIhLbEPELeUYzNrXq3wepKipVJ6AnmHHqDz5_rCDKMAJX2GkebYXAefsbCD0A0gGO2c_lz40MCSE583gkyIFmYMYkbgA/s1600/kotlinJS.png&quot; title=&quot;Introducción a KotlinJS: Desarrollo web con Kotlin&quot; /&gt;&lt;br /&gt;
&lt;br /&gt;
Hasta ahora estamos escribiendo Kotlin principalmente para el desarrollo de aplicaciones en Android, pero Kotlin es un lenguaje de programación versátil con cuatro ámbitos principales de aplicación: Android, JVM, nativo y, lo que nos interesa ahora, &lt;b&gt;desarrollo web&lt;/b&gt;.&lt;a name=&#39;more&#39;&gt;&lt;/a&gt; Esto es así porque Kotlin también puede ser compilado a código fuente de JavaScript, con la diferencia de que con Kotlin se puede disfrutar de la experiencia de utilizar un lenguaje fuertemente tipado y de gran potencia.&lt;br /&gt;
&lt;br /&gt;
Hay varias formas de compilar Kotlin a JavaScript, siendo el enfoque recomendado usar &lt;i&gt;Gradle&lt;/i&gt;, aunque también se pueden crear proyectos JavaScript directamente desde &lt;i&gt;IntelliJ IDEA&lt;/i&gt;, usar &lt;i&gt;Maven&lt;/i&gt; o compilar el código manualmente desde la línea de comandos. De momento vamos a ver un ejemplo sencillo de cómo usar &lt;b&gt;KotlinJS&lt;/b&gt; (Kotlin a JavaScript) para el desarrollo web.&lt;br /&gt;
&lt;br /&gt;
Abrimos &lt;i&gt;IntelliJ Idea&lt;/i&gt; y creamos un nuevo proyecto seleccionando Kotlin y JS | IDEA:&lt;br /&gt;
&lt;br /&gt;
&lt;img border=&quot;0&quot; data-original-height=&quot;555&quot; data-original-width=&quot;741&quot; height=&quot;479&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi830CCq8-6TPWMF7ah8eC-H38Mej7Tvi1MoPR0jHj7n55yw-TNbP6slA1R-MV0DzQHwE0IUKyB9_QQxU7gsiSWEf-iB4y3KvHISNRp54ca07k4TfgAFi1ih0ffE4VsQ5Ouzaw9TrUQw1g/s640/newProject.png&quot; width=&quot;640&quot; /&gt;&lt;br /&gt;
&lt;br /&gt;
Asignamos un nombre al proyecto y seleccionamos una librería (en caso de no existir la creamos con el botón &lt;i&gt;Create&lt;/i&gt;):&lt;br /&gt;
&lt;br /&gt;
&lt;img border=&quot;0&quot; data-original-height=&quot;555&quot; data-original-width=&quot;741&quot; height=&quot;479&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiMkCgaexanrcM99qaGJRMM9DfaFmtVkMMlALvl3S20vdXDoreJvcEPGE8h-jge39DJG-HmgJCkfKdki4zqweB45b2FnS1Y_e_Rv90fGTl6NcCX0fFYlyFTY_-2uv7FT7qFxFxbZv7HRjA/s640/newProject2.png&quot; width=&quot;640&quot; /&gt;&lt;br /&gt;
&lt;br /&gt;
Observa la estructura de archivos que se ha creado. En la carpeta &lt;i&gt;src&lt;/i&gt; creamos un archivo tipo Kotlin, por ejemplo &lt;i&gt;kotlinJS.kt&lt;/i&gt;, y en la raíz del proyecto creamos un archivo html (&lt;i&gt;File -&amp;gt; New -&amp;gt; HTML File&lt;/i&gt;), por ejemplo &lt;i&gt;index.html&lt;/i&gt;, y un archivo para contener el estilo, por ejemplo &lt;i&gt;estilo.css&lt;/i&gt; (también se puede crear un archivo xsl desde &lt;i&gt;File -&amp;gt; New -&amp;gt; XSLT Stylesheet&lt;/i&gt;).&lt;br /&gt;
&lt;br /&gt;
Ahora ya podemos ejecutar &lt;i&gt;Build -&amp;gt; Build Project&lt;/i&gt;, lo que genera una nueva carpeta llamada out, donde ahora nos interesan dos archivos:&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;out/production/KotlinJS/lib/kotlin.js&lt;/li&gt;
&lt;li&gt;out/production/KotlinJS/KotlinJS.js&lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;
Ahora tenemos esta estructura de archivos:&lt;br /&gt;
&lt;br /&gt;
&lt;img border=&quot;0&quot; data-original-height=&quot;435&quot; data-original-width=&quot;500&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjha_E94szJVXmHYJJEabMovFQSc2IMecLPSIwEeVB1P2VNf1xWMQcucof5OIiUKjygyB4t2UfLtSrJBJYE6wftuNTPLUVz2ngPRnTs3qAllw8hcOCN9S7e_D-VpTFFVixsk1F9nrXizr0/s1600/archivos.png&quot; /&gt;&lt;br /&gt;
&lt;br /&gt;
Abrimos el archivo &lt;i&gt;index.html&lt;/i&gt; y cambiamos el título y añadimos las referencias a esos dos archivos y al archivo de estilo, quedando de esta manera:&lt;br /&gt;
&lt;pre class=&quot;hl&quot;&gt;&lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;!DOCTYPE&lt;/span&gt; html&lt;span class=&quot;hl kwa&quot;&gt;&amp;gt;&lt;/span&gt;
&lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;html&lt;/span&gt; &lt;span class=&quot;hl kwb&quot;&gt;lang&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;es&quot;&lt;/span&gt;&lt;span class=&quot;hl kwa&quot;&gt;&amp;gt;&lt;/span&gt;
&lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;head&amp;gt;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;meta&lt;/span&gt; &lt;span class=&quot;hl kwb&quot;&gt;charset&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;UTF-8&quot;&lt;/span&gt;&lt;span class=&quot;hl kwa&quot;&gt;&amp;gt;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;title&amp;gt;&lt;/span&gt;Desarrollo Web con KotlinJS&lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;/title&amp;gt;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;link&lt;/span&gt; &lt;span class=&quot;hl kwb&quot;&gt;rel&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;stylesheet&quot;&lt;/span&gt; &lt;span class=&quot;hl kwb&quot;&gt;href&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;estilo.css&quot;&lt;/span&gt;&lt;span class=&quot;hl kwa&quot;&gt;&amp;gt;&lt;/span&gt;
&lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;/head&amp;gt;&lt;/span&gt;
&lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;body&amp;gt;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;script&lt;/span&gt; &lt;span class=&quot;hl kwb&quot;&gt;src&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;out/production/KotlinJS/lib/kotlin.js&quot;&lt;/span&gt;&lt;span class=&quot;hl kwa&quot;&gt;&amp;gt;&amp;lt;/script&amp;gt;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;script&lt;/span&gt; &lt;span class=&quot;hl kwb&quot;&gt;src&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;out/production/KotlinJS/KotlinJS.js&quot;&lt;/span&gt;&lt;span class=&quot;hl kwa&quot;&gt;&amp;gt;&amp;lt;/script&amp;gt;&lt;/span&gt;
&lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;/body&amp;gt;&lt;/span&gt;
&lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;/html&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;br /&gt;
Y en el archivo &lt;i&gt;kotlinJS.kt&lt;/i&gt; podemos crear un par de elementos &lt;i&gt;html&lt;/i&gt; que añadimos a la etiqueta &lt;i&gt;body&lt;/i&gt;:&lt;br /&gt;
&lt;pre class=&quot;hl&quot;&gt;&lt;span class=&quot;hl kwa&quot;&gt;import&lt;/span&gt; kotlin&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;browser&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;document

&lt;span class=&quot;hl kwa&quot;&gt;fun&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;main&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;() {&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;val&lt;/span&gt; h1 &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; document&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;createElement&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl str&quot;&gt;&quot;h1&quot;&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; h1&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;textContent &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;hl str&quot;&gt;&quot;Hola KotlinJS!&quot;&lt;/span&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;val&lt;/span&gt; p1 &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; document&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;createElement&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl str&quot;&gt;&quot;p&quot;&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; p1&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;textContent &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;hl str&quot;&gt;&quot;Mi primera web con Kotlin.&quot;&lt;/span&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp; document&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;body?&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;append&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;h1&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; p1&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt;&lt;/pre&gt;
&lt;br /&gt;
Y en el archivo &lt;i&gt;estilo.css&lt;/i&gt; establecemos un estilo:&lt;br /&gt;
&lt;pre class=&quot;hl&quot;&gt;body &lt;span class=&quot;hl opt&quot;&gt;{&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;background-color&lt;/span&gt; &lt;span class=&quot;hl opt&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;hl num&quot;&gt;#d8da3d&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;font-family&lt;/span&gt; &lt;span class=&quot;hl opt&quot;&gt;:&lt;/span&gt; arial&lt;span class=&quot;hl opt&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt;

h1 &lt;span class=&quot;hl opt&quot;&gt;{&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;font-size&lt;/span&gt; &lt;span class=&quot;hl opt&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;hl num&quot;&gt;36pt&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;font-family&lt;/span&gt; &lt;span class=&quot;hl opt&quot;&gt;:&lt;/span&gt; verdana&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; arial&lt;span class=&quot;hl opt&quot;&gt;;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;text-align&lt;/span&gt; &lt;span class=&quot;hl opt&quot;&gt;:&lt;/span&gt; center&lt;span class=&quot;hl opt&quot;&gt;;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;color&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;:&lt;/span&gt; white&lt;span class=&quot;hl opt&quot;&gt;;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;background-color&lt;/span&gt; &lt;span class=&quot;hl opt&quot;&gt;:&lt;/span&gt; teal&lt;span class=&quot;hl opt&quot;&gt;;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;padding&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;hl num&quot;&gt;10&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;%;&lt;/span&gt;
&lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt;
p &lt;span class=&quot;hl opt&quot;&gt;{&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;font-size&lt;/span&gt; &lt;span class=&quot;hl opt&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;hl num&quot;&gt;16pt&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;font-family&lt;/span&gt; &lt;span class=&quot;hl opt&quot;&gt;:&lt;/span&gt; arial&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt;helvetica&lt;span class=&quot;hl opt&quot;&gt;;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;font-weight&lt;/span&gt; &lt;span class=&quot;hl opt&quot;&gt;:&lt;/span&gt; normal&lt;span class=&quot;hl opt&quot;&gt;;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;color&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;:&lt;/span&gt; teal&lt;span class=&quot;hl opt&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt;&lt;/pre&gt;
&lt;br /&gt;
Volvemos a reconstruir con &lt;i&gt;Build Project&lt;/i&gt; y desde el archivo &lt;i&gt;index&lt;/i&gt; abrimos un navegador para ver el resultado (en la esquina superior derecha aparecen los iconos de los navegadores configurados, o alternativamente desde &lt;i&gt;View -&amp;gt; Open in Browser&lt;/i&gt;; en caso de pulsar sobre un navegador no instalado, se abre la ventana de advertencia &lt;i&gt;Browser Error&lt;/i&gt;, y pulsando sobre &lt;i&gt;Fix&lt;/i&gt; abrimos una ventana para editar los navegadores). Así se ve en el navegador:&lt;br /&gt;
&lt;br /&gt;
&lt;img border=&quot;0&quot; data-original-height=&quot;512&quot; data-original-width=&quot;492&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh0ahilNqtbbNUN_MEkVPbMWtDzEYIaYQpQy6pi_x733hImsYcvR0xTZtrMrt5vAmoo6OVqR3ilTjtoFzyw_48cdZ1e9DxadMWJ99LJB-y2bAtrr_YzJNcBN92-d3IK8F4kUT_AYXxsOIE/s1600/web.png&quot; /&gt;</content><link rel='replies' type='application/atom+xml' href='https://kotlindoc.blogspot.com/feeds/2723864628347850514/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='https://kotlindoc.blogspot.com/2019/10/introduccion-kotlinjs-desarrollo-web.html#comment-form' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='https://www.blogger.com/feeds/6895501055750567199/posts/default/2723864628347850514'/><link rel='self' type='application/atom+xml' href='https://www.blogger.com/feeds/6895501055750567199/posts/default/2723864628347850514'/><link rel='alternate' type='text/html' href='https://kotlindoc.blogspot.com/2019/10/introduccion-kotlinjs-desarrollo-web.html' title='Introducción a KotlinJS: Desarrollo web con Kotlin'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh1yxMBIJt4oFmc6vioFhSyDALB0MVnqMYM9qvQyYhVGLGUnLDSIhLbEPELeUYzNrXq3wepKipVJ6AnmHHqDz5_rCDKMAJX2GkebYXAefsbCD0A0gGO2c_lz40MCSE583gkyIFmYMYkbgA/s72-c/kotlinJS.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6895501055750567199.post-7094473545648144562</id><published>2019-10-28T08:00:00.000+01:00</published><updated>2019-10-28T08:00:08.054+01:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="android básico"/><category scheme="http://www.blogger.com/atom/ns#" term="android studio"/><title type='text'>Android: Diseño adaptado a la orientación de pantalla</title><content type='html'>&lt;img alt=&quot;Android: Diseño adaptado a la orientación de pantalla&quot; border=&quot;0&quot; data-original-height=&quot;517&quot; data-original-width=&quot;800&quot; height=&quot;413&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgV5xJlk_GJ-tHGaT3Ejdfruc1TQ1lIg1ZpjBdGczdQtub4ovkkuunXDbhAMFVnDPQpnimiQJRfWOU-9ccroc8QDiTOuSxw9-SBdkl8Bgo5w938871j7o96ip7910c0xiPTCe0Bw5kz3Fg/s640/rotacion.png&quot; title=&quot;Android: Diseño adaptado a la orientación de pantalla&quot; width=&quot;640&quot; /&gt;&lt;br /&gt;
&lt;br /&gt;
A la hora de desarrollar una aplicación habitualmente creamos un diseño en vertical puesto que es la orientación por defecto, aunque suele ser conveniente que el diseño sea lo suficientemente flexible para adaptarse a la rotación del dispositivo y mostrarse de manera correcta también en horizontal.&lt;br /&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;br /&gt;
Si quieres que tu aplicación sea igualmente funcional en ambas orientaciones (&lt;i&gt;portrait&lt;/i&gt; y &lt;i&gt;landscape&lt;/i&gt;), &lt;i&gt;Android Studio&lt;/i&gt; nos facilita las cosas.&lt;br /&gt;
&lt;br /&gt;
Antes de nada, cuando ejecutes tu aplicación en el emulador de Android asegúrate que en los ajustes está activada la opción de rotación automática (&lt;i&gt;Auto-rotate&lt;/i&gt;) como se ve en la imagen:&lt;br /&gt;
&lt;br /&gt;
&lt;img border=&quot;0&quot; data-original-height=&quot;750&quot; data-original-width=&quot;422&quot; height=&quot;640&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiRwNpcRTq-RCsTyQx5hvO5m9YACb7KHisvwfynwt43iJ9TFgB-XpvAkSsYj6NOsUZHQQQs1Q_QAlFHtsyyj2k5uAC0cNg6Q32nE9NdEo97mhA7ZUoIVwvxBHI2UV149eCJRAPKAzox1cg/s640/autorotate.png&quot; width=&quot;360&quot; /&gt;&lt;br /&gt;
&lt;br /&gt;
Nuestra aplicación de ejemplo (para esta entrada he utilizado código del repositorio en Github de &lt;a href=&quot;https://github.com/google-developer-training&quot;&gt;Google Developer Training&lt;/a&gt;) se ve así en modo vertical:&lt;br /&gt;
&lt;br /&gt;
&lt;img border=&quot;0&quot; data-original-height=&quot;750&quot; data-original-width=&quot;422&quot; height=&quot;640&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgHA3hrzfXdcCu0NG1XofIviA4Hawf4xAd1wQnrodLZOdW2zT63ec9l_sarv7lad5RdVbwqwCPQRPS7bopHeURaVthHxQDz8FBHzkmGfyQeb4S_BkbA7o6GORjYuz4NdaLYSpSsXXF-Zmc/s640/vertical.png&quot; width=&quot;360&quot; /&gt;&lt;br /&gt;
&lt;br /&gt;
Al rotar el dispositivo (en el emulador) la aplicación se muestra así en modo apaisado:&lt;br /&gt;
&lt;br /&gt;
&lt;img border=&quot;0&quot; data-original-height=&quot;422&quot; data-original-width=&quot;750&quot; height=&quot;360&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj0nOfygydjG8Dz7_T8hiTL7NYYHFVTS5WJHuJQOcFxIap_gzOmGItzxQyJZb_pCRxzNrL2C8TzcVbTVaa2oWFxhSZdZCp3OI-fgf-xHY0BFxyupc838w2fI_CM44ZaI3K-2VC3FiuYBa0/s640/horizontal.png&quot; width=&quot;640&quot; /&gt;&lt;br /&gt;
&lt;br /&gt;
Comprobamos que la imagen se corta y que la disposición del diseño no queda optimizada para esta orientación.&lt;br /&gt;
&lt;br /&gt;
Para solucionarlo abrimos el archivo de diseño, en nuestro ejemplo &lt;i&gt;layout/activity_main.xml&lt;/i&gt;, y desde la pestaña &lt;i&gt;Design&lt;/i&gt; pulsamos sobre el icono &lt;i&gt;Orientation for Preview&lt;/i&gt;, donde está activada la opción &lt;i&gt;Portrait&lt;/i&gt;; seleccionamos &lt;i&gt;Landscape&lt;/i&gt; y comprobamos que se ve igual que en el emulador (no podíamos esperar otra cosa).&lt;br /&gt;
&lt;br /&gt;
En &lt;i&gt;Orientation for Preview&lt;/i&gt; pulsamos sobre &lt;i&gt;Create Landscape Variation&lt;/i&gt;, lo que crea un nuevo archivo: &lt;i&gt;layout-land/activity_main.xml&lt;/i&gt; que es una copia del archivo de diseño original. Sobre este archivo debemos hacer los cambios para que el diseño se ajuste correctamente en horizontal.&lt;br /&gt;
&lt;br /&gt;
Una vez hechos los cambios oportunos en el diseño (se podría hacer mejor, pero para el ejemplo simplemente he cambiado el escalado de la imagen de fondo y la distribución del texto inferior), volvemos a ejecutar la aplicación en el emulador, y comprobamos que al rotar el dispositivo la aplicación toma automáticamente el diseño que corresponde a cada orientación:&lt;br /&gt;
&lt;br /&gt;
&lt;img border=&quot;0&quot; data-original-height=&quot;422&quot; data-original-width=&quot;750&quot; height=&quot;360&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgE9f07ZHR365GmUthPcDIbrDQOeJPRXKVlklF01k7iZmAnHt7H0ZTDmlsnh1gbFlmv94q0nEXCMm-R1F1E8PhmPKQYAHYjnAPaQN88jQles4g0Ef2LS2xX4jjQGnenez5z5-UKwxuiUDY/s640/horizontal2.png&quot; width=&quot;640&quot; /&gt;
</content><link rel='replies' type='application/atom+xml' href='https://kotlindoc.blogspot.com/feeds/7094473545648144562/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='https://kotlindoc.blogspot.com/2019/10/android-diseno-adaptado-la-orientacion.html#comment-form' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='https://www.blogger.com/feeds/6895501055750567199/posts/default/7094473545648144562'/><link rel='self' type='application/atom+xml' href='https://www.blogger.com/feeds/6895501055750567199/posts/default/7094473545648144562'/><link rel='alternate' type='text/html' href='https://kotlindoc.blogspot.com/2019/10/android-diseno-adaptado-la-orientacion.html' title='Android: Diseño adaptado a la orientación de pantalla'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgV5xJlk_GJ-tHGaT3Ejdfruc1TQ1lIg1ZpjBdGczdQtub4ovkkuunXDbhAMFVnDPQpnimiQJRfWOU-9ccroc8QDiTOuSxw9-SBdkl8Bgo5w938871j7o96ip7910c0xiPTCe0Bw5kz3Fg/s72-c/rotacion.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6895501055750567199.post-4769723328801965913</id><published>2019-10-27T08:00:00.000+01:00</published><updated>2019-10-27T08:00:01.064+01:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="android básico"/><title type='text'>Material Design: Paleta de colores</title><content type='html'>&lt;img alt=&quot;Material Design&quot; border=&quot;0&quot; data-original-height=&quot;450&quot; data-original-width=&quot;900&quot; height=&quot;320&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEizjiMCELMzq3JXYq11UWXIt_0BXWua-odDDyZT70ZhgbMDmKitF5cvhXvIYS4CuBybcBTTyIz_GtZ02Ok78YLf7Vqu4vqeIPCs4_9-arLhYdTJdE0YRNNIL8YeBavxSz2hOgBX79-q9S4/s640/colores.png&quot; title=&quot;Material Design&quot; width=&quot;640&quot; /&gt;&lt;br /&gt;
&lt;br /&gt;
A partir de la versión 5.0 de Android (API 21), Google introduce una guía para el diseño visual de las aplicaciones, conocida como &lt;a href=&quot;https://material.io/&quot;&gt;&lt;i&gt;Material Design&lt;/i&gt;&lt;/a&gt;, que pretende proporcionar una experiencia consistente a través de distintas plataformas y aplicaciones.&lt;br /&gt;&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;
&lt;br /&gt;
Uno de sus principios básicos es, a diferencia del &lt;i&gt;Flat Design&lt;/i&gt;, dar peso o materialidad a los elementos de la interfaz de usuario aportando apariencia de volumen o profundidad con sombras, bordes, capas y animaciones. También propone transmitir significado a través del color, utilizando para ello determinados tonos y combinaciones.&lt;br /&gt;
&lt;br /&gt;
En cuanto al &lt;b&gt;color&lt;/b&gt;, cada aplicación debe definir, dentro de cierto abanico de colores, su propia paleta que la identifique y diferencie del resto de aplicaciones. Por ello, si decides seguir las especificaciones de &lt;i&gt;Material Design&lt;/i&gt;, una de las primeras decisiones respecto al diseño será escoger la paleta de colores que vas a utilizar.&lt;br /&gt;
&lt;br /&gt;
En la web puedes encontrar distintas &lt;b&gt;herramientas online&lt;/b&gt; especialmente útiles para este cometido, como por ejemplo &lt;a href=&quot;https://www.materialpalette.com/&quot;&gt;Material Palette&lt;/a&gt; y &lt;a href=&quot;https://material.io/resources/color/&quot;&gt;Color Tool&lt;/a&gt;. En cualquiera de las dos se deben seleccionar los colores primario y secundario para la aplicación, lo que nos permite ver una previsualización del diseño y finalmente exportar y guardar en un archivo con formato xml para utilizar en nuestra aplicación.&lt;br /&gt;
&lt;br /&gt;
&lt;img alt=&quot;Material Palette&quot; border=&quot;0&quot; data-original-height=&quot;748&quot; data-original-width=&quot;1075&quot; height=&quot;445&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiK1vURdT7q44ZhoFAqphpcEifnbL-HjsKSBk3SpQJsajvb1aWMny3Zjzp3u83kV312wDbwLSWme27rzjJQ6kzzuHiPA-IxJ1lYFZjRtcHzF3I65tG27pbyAec281qRta2LZxetna3gnh0/s640/colorpalete.png&quot; title=&quot;Material Palette&quot; width=&quot;640&quot; /&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;img alt=&quot;Color Tool&quot; border=&quot;0&quot; data-original-height=&quot;748&quot; data-original-width=&quot;1087&quot; height=&quot;440&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgDpkobVb_TDdDqqcaHttaxEOBLFTypmE8CV0kzfCLsL584hJqPnATMlaquJFPfzaHZq-bGs5-wMkFyeks3351pisDAB0MA8KAoG2K9ZGtFY1vYx-mxkWbEFcD-3M9Wu6dVBLM7I3FF4kk/s640/colortool.png&quot; title=&quot;Color Tool&quot; width=&quot;640&quot; /&gt;&lt;br /&gt;
&lt;br /&gt;
De esta manera hemos conseguido una manera rápida y sencilla de seleccionar los colores para nuestra aplicación siguiendo las directrices de estilo de &lt;i&gt;Material Design&lt;/i&gt;.&lt;br /&gt;
&lt;br /&gt;
Más información sobre el sistema de colores en &lt;i&gt;Material Design&lt;/i&gt; en &lt;a href=&quot;https://material.io/design/color/&quot;&gt;The color system - Material Design&lt;/a&gt; (en inglés).</content><link rel='replies' type='application/atom+xml' href='https://kotlindoc.blogspot.com/feeds/4769723328801965913/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='https://kotlindoc.blogspot.com/2019/10/material-design-paleta-de-colores.html#comment-form' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='https://www.blogger.com/feeds/6895501055750567199/posts/default/4769723328801965913'/><link rel='self' type='application/atom+xml' href='https://www.blogger.com/feeds/6895501055750567199/posts/default/4769723328801965913'/><link rel='alternate' type='text/html' href='https://kotlindoc.blogspot.com/2019/10/material-design-paleta-de-colores.html' title='Material Design: Paleta de colores'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEizjiMCELMzq3JXYq11UWXIt_0BXWua-odDDyZT70ZhgbMDmKitF5cvhXvIYS4CuBybcBTTyIz_GtZ02Ok78YLf7Vqu4vqeIPCs4_9-arLhYdTJdE0YRNNIL8YeBavxSz2hOgBX79-q9S4/s72-c/colores.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6895501055750567199.post-435424355667376156</id><published>2019-10-26T07:58:00.000+02:00</published><updated>2019-10-26T08:01:01.120+02:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="android básico"/><title type='text'>Introducción al ciclo de vida de una actividad en Android</title><content type='html'>&lt;img alt=&quot;Introducción al ciclo de vida de una actividad en Android&quot; border=&quot;0&quot; data-original-height=&quot;332&quot; data-original-width=&quot;775&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEghS73hrnPHr0txkUqeYHxz8GlU6kf7mkN3BFBC4AkoScQrj1qJkKu9ev7Po1Ec0VPXuWlIUTpCqXpT277JJtV8fqCP4ds2BXlJ1WcELNfAVwkaqv62gSdUinCjoPeHw99pgZLld0hyphenhyphenObQ/s1600/mariposa-min.png&quot; title=&quot;Introducción al ciclo de vida de una actividad en Android&quot; /&gt;&lt;br /&gt;
&lt;br /&gt;
En Android toda actividad (y también todo fragmento) tiene lo que se conoce como &lt;b&gt;ciclo de vida&lt;/b&gt; (&lt;i&gt;activity lifecycle&lt;/i&gt;), término que hace alusión a los ciclos de vida de los animales, especialmente gráfico en los diferentes estados que atraviesa la mariposa en su proceso de metamorfosis.&lt;br /&gt;&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;
&lt;br /&gt;
En concreto, el &lt;b&gt;ciclo de vida de una actividad&lt;/b&gt; es un conjunto de estados a través de los cuales se desarrolla una actividad, empezando cuando se crea por primera vez y terminando cuando se destruye (y su memoria es recuperada por el sistema). A medida que el usuario navega entre actividades y dentro y fuera de una aplicación, cada actividad se mueve entre distintos estados dentro del ciclo de vida de la actividad.&lt;br /&gt;
&lt;br /&gt;
La siguiente imagen muestra los estados del ciclo de vida de una actividad:&lt;br /&gt;
&lt;br /&gt;
&lt;img alt=&quot;Activity lifecycle&quot; border=&quot;0&quot; data-original-height=&quot;807&quot; data-original-width=&quot;690&quot; height=&quot;640&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjgWWc09u2msT2GwNR1V_soxLZZi_rLz5woPNOW6ACDRxHuoFy0kv7OJek3vbooPiIxiWkg6h_SsRGtvFlz5FhnJ_sYuDaAoNpimdJvvBXZvDNnqgTLnXDAt6VQNflWWVxe_EOr-XdReKU/s640/lifecycle.png&quot; title=&quot;Activity lifecycle&quot; width=&quot;547&quot; /&gt;&lt;br /&gt;
&lt;br /&gt;
Entonces una actividad en Android puede estar en uno de esos estados, lo que determina si la actividad tiene instancia en la memoria, es visible para el usuario o está en primer plano y acepta interacción del usuario (tiene el foco):&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;&lt;b&gt;Activa&lt;/b&gt; (&lt;i&gt;Resumed / Running&lt;/i&gt;): La actividad está encima de la pila, lo que quiere decir que es visible y tiene el foco.&lt;/li&gt;
&lt;li&gt;&lt;b&gt;Visible&lt;/b&gt; (&lt;i&gt;Started / Paused&lt;/i&gt;): La actividad es visible pero no tiene el foco. Se alcanza este estado cuando otra actividad pasa a activa con alguna parte transparente o que no ocupa toda la pantalla. Cuando una actividad está tapada por completo, pasa a estar parada.&lt;/li&gt;
&lt;li&gt;&lt;b&gt;Parada&lt;/b&gt; (&lt;i&gt;Created / Stopped&lt;/i&gt;): Cuando la actividad no es visible. El programador debe guardar el estado de la interfaz de usuario, preferencias, etc.&lt;/li&gt;
&lt;li&gt;&lt;b&gt;Destruida&lt;/b&gt; (&lt;i&gt;Destroyed&lt;/i&gt;): Cuando la actividad termina al invocarse el método &lt;i&gt;finish()&lt;/i&gt;, o es matada por el sistema.&lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;
La clase &lt;i&gt;Activity&lt;/i&gt; (y cualquier subclase de &lt;i&gt;Activity&lt;/i&gt;, como &lt;i&gt;AppCompatActivity&lt;/i&gt;) implementa un conjunto de métodos para invocar cada estado del ciclo de vida. Android invoca automáticamente estos métodos cuando la actividad se mueve de un estado a otro, pero podemos sobrescribirlos (&lt;i&gt;override&lt;/i&gt;) para realizar tareas específicas en respuesta a los cambios de estado del ciclo de vida.&lt;br /&gt;
&lt;br /&gt;
Por tanto, cada vez que una actividad cambia de estado se van a generar eventos que
 podrán ser capturados por ciertos métodos de la actividad. Dentro del ciclo de vida de una actividad existen métodos específicos para activar un estado desde otro estado, existiendo siete métodos como se ve en la siguiente imagen (en el ciclo de vida de un fragmento además existen otros métodos específicos):&lt;br /&gt;
&lt;br /&gt;
&lt;img alt=&quot;Activity lifecycle&quot; border=&quot;0&quot; data-original-height=&quot;1022&quot; data-original-width=&quot;900&quot; height=&quot;640&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjkAOUdb4VJL4Ir82vpwoW5lwnPbHLz0RIGZqQ_hsL_tEHGDXf4G8SV5OLLXEQ5p24oHtEmryl0yoAp0dI31346wWQUjq1bccIQwDI8DVzcMLAUz-mWrRbC_VyudsK1N8Gdb5Enj0qgwww/s640/lifecycle2.png&quot; title=&quot;Activity lifecycle&quot; width=&quot;563&quot; /&gt;&lt;br /&gt;
&lt;br /&gt;
Más información sobre el ciclo de vida de las actividades en &lt;a href=&quot;https://developer.android.com/guide/components/activities.html?hl=es&quot;&gt;Android Developers: Actividades&lt;/a&gt;.</content><link rel='replies' type='application/atom+xml' href='https://kotlindoc.blogspot.com/feeds/435424355667376156/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='https://kotlindoc.blogspot.com/2019/10/introduccion-al-ciclo-de-vida-de-una.html#comment-form' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='https://www.blogger.com/feeds/6895501055750567199/posts/default/435424355667376156'/><link rel='self' type='application/atom+xml' href='https://www.blogger.com/feeds/6895501055750567199/posts/default/435424355667376156'/><link rel='alternate' type='text/html' href='https://kotlindoc.blogspot.com/2019/10/introduccion-al-ciclo-de-vida-de-una.html' title='Introducción al ciclo de vida de una actividad en Android'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEghS73hrnPHr0txkUqeYHxz8GlU6kf7mkN3BFBC4AkoScQrj1qJkKu9ev7Po1Ec0VPXuWlIUTpCqXpT277JJtV8fqCP4ds2BXlJ1WcELNfAVwkaqv62gSdUinCjoPeHw99pgZLld0hyphenhyphenObQ/s72-c/mariposa-min.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6895501055750567199.post-2120437251174029921</id><published>2019-10-25T12:25:00.001+02:00</published><updated>2019-10-26T09:48:57.581+02:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="android básico"/><title type='text'>Android: log con Timber</title><content type='html'>&lt;img alt=&quot;Android: log con Timber&quot; border=&quot;0&quot; data-original-height=&quot;336&quot; data-original-width=&quot;642&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhK0OWNNP9ZJPGs4lyELL69hAvg96lK200hRV2Eh2FnXAGekY83wiFMIO5gJ6SDgkJu3EU3kCHR17i698RYv5_XMBixs1WG73x5wVowou9cPvADzC1Vu5OyM8BAjjM5NOLL4O3zhPnrSfw/s1600/timber.jpeg&quot; title=&quot;Android: log con Timber&quot; /&gt;&lt;br /&gt;
&lt;br /&gt;
En entradas anteriores, como por ejemplo en &lt;a href=&quot;https://kotlindoc.blogspot.com/2019/06/anatomia-de-una-app-basica.html&quot;&gt;Anatomía de una app básica&lt;/a&gt; y en &lt;a href=&quot;https://kotlindoc.blogspot.com/2019/07/fundamentos-de-android-interaccion-del.html&quot;&gt;Fundamentos de Android: Interacción del usuario&lt;/a&gt;, ya hemos visto el uso de la clase &lt;i&gt;Log&lt;/i&gt; para ver el historial de &lt;i&gt;log&lt;/i&gt; o registro de eventos o acciones en una aplicación.

Por ejemplo, para comprobar el estado &lt;i&gt;Created&lt;/i&gt; dentro del &lt;a href=&quot;https://kotlindoc.blogspot.com/2019/10/introduccion-al-ciclo-de-vida-de-una.html&quot;&gt;ciclo de vida de la actividad&lt;/a&gt; de una aplicación, dentro del método &lt;i&gt;onCreate&lt;/i&gt; podemos incluir:&lt;br /&gt;&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;
&lt;pre class=&quot;hl&quot;&gt;&lt;span class=&quot;hl slc&quot;&gt;// requiere import android.util.Log&lt;/span&gt;
Log&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl str&quot;&gt;&quot;MainActivity&quot;&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;hl str&quot;&gt;&quot;Activity Status: Created&quot;&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;
&lt;/pre&gt;
En la clase &lt;i&gt;Log&lt;/i&gt; tenemos tres elementos:&lt;br /&gt;
&lt;ol&gt;
&lt;li&gt;i que significa que se trata de un menseje de carácter informativo (también puede ser, entre otras opciones, e para errores o w para advertencias o &lt;i&gt;warnings&lt;/i&gt;),&lt;/li&gt;
&lt;li&gt;el primer parámetro que es una etiqueta o &lt;i&gt;tag&lt;/i&gt; que nos sirve para localizar más fácilmente los mensajes y en muchas ocasiones suele ser el nombre de la clase, y&lt;/li&gt;
&lt;li&gt;el segundo parámetro que contiene el mensaje. &lt;/li&gt;
&lt;/ol&gt;
Después podemos hacer un seguimiento de este &lt;i&gt;log&lt;/i&gt; a través de la pestaña &lt;i&gt;Logcat&lt;/i&gt;, y para encontrarlo más fácilmente podemos filtrar nuestro mensaje dentro de los múltiples mensajes del &lt;i&gt;Logcat&lt;/i&gt; escribiendo &lt;i&gt;I/MainActivity&lt;/i&gt; en el campo de búsqueda.&lt;br /&gt;
&lt;br /&gt;
Una alternativa al uso de la clase &lt;i&gt;Log&lt;/i&gt; es la biblioteca &lt;i&gt;Timber&lt;/i&gt;, que es una biblioteca de código abierto desarrollada por &lt;a href=&quot;https://github.com/JakeWharton&quot;&gt;Jake Wharton&lt;/a&gt; que proporciona funciones adicionales de registro, con ciertas ventajas sobre la clase integrada &lt;i&gt;Log&lt;/i&gt;, como que genera automáticamente la etiqueta según el nombre de la clase, ayuda a evitar mostrar registros en una versión de lanzamiento o permite la integración con bibliotecas de informes de fallos.&lt;br /&gt;
&lt;br /&gt;
Para utilizar &lt;i&gt;Timber&lt;/i&gt; debemos añadirlo a &lt;i&gt;Gradle&lt;/i&gt;. Concretamente en el archivo &lt;i&gt;build.gradle (Module: app)&lt;/i&gt;, en la sección de dependencias debemos añadir:
&lt;br /&gt;
&lt;pre class=&quot;hl&quot;&gt;dependencies &lt;span class=&quot;hl opt&quot;&gt;{&lt;/span&gt;
   &lt;span class=&quot;hl opt&quot;&gt;...&lt;/span&gt;
   implementation &lt;span class=&quot;hl str&quot;&gt;&#39;com.jakewharton.timber:timber:4.7.1&#39;&lt;/span&gt;
&lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt;
&lt;/pre&gt;
Ten en cuenta que el número de versión puede cambiar, por lo que debes comprobarlo en el la &lt;a href=&quot;https://github.com/JakeWharton/timber#download&quot;&gt;web del proyecto&lt;/a&gt; en &lt;i&gt;GitHub&lt;/i&gt; (el número de versión se muestra bajo el encabezado &lt;i&gt;Download&lt;/i&gt;).&lt;br /&gt;
&lt;br /&gt;
La implementación de &lt;i&gt;DebugTree&lt;/i&gt; determinará automáticamente desde qué clase se está llamando y usará ese nombre de clase como etiqueta:
&lt;br /&gt;
&lt;pre class=&quot;hl&quot;&gt;Timber&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;plant&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;Timber&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;DebugTree&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;())&lt;/span&gt;
&lt;/pre&gt;
Aunque podemos hacer esta implementación en el método &lt;i&gt;onCreate&lt;/i&gt;, suele ser recomendable hacerla dentro de otra clase de la aplicación (como una subclase de &lt;i&gt;Application&lt;/i&gt;) e incluir esta clase en el archivo &lt;i&gt;AndroidManifest.xml&lt;/i&gt;. Por ejemplo (código extraído de &lt;a href=&quot;https://codelabs.developers.google.com/android-kotlin-fundamentals/&quot;&gt;Android Kotlin Fundamentals Course&lt;/a&gt;):
&lt;br /&gt;
&lt;pre class=&quot;hl&quot;&gt;&lt;span class=&quot;hl slc&quot;&gt;//ClickerApplication.kt&lt;/span&gt;
&lt;span class=&quot;hl kwa&quot;&gt;package&lt;/span&gt; com&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;example&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;android&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;dessertclicker

&lt;span class=&quot;hl kwa&quot;&gt;import&lt;/span&gt; android&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;app&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;Application
&lt;span class=&quot;hl kwa&quot;&gt;import&lt;/span&gt; timber&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;log&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;Timber

&lt;span class=&quot;hl kwa&quot;&gt;class&lt;/span&gt; ClickerApplication&lt;span class=&quot;hl opt&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;Application&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;() {&lt;/span&gt;

    &lt;span class=&quot;hl kwa&quot;&gt;override fun&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;onCreate&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;() {&lt;/span&gt;
        &lt;span class=&quot;hl kwa&quot;&gt;super&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;onCreate&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;()&lt;/span&gt;

        Timber&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;plant&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;Timber&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;DebugTree&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;())&lt;/span&gt;
    &lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt;
&lt;/pre&gt;
Y en el archivo &lt;i&gt;AndroidManifest.xml&lt;/i&gt;, en la parte superior del elemento &lt;i&gt;application&lt;/i&gt; añadimos:
&lt;br /&gt;
&lt;pre class=&quot;hl&quot;&gt;&lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;application&lt;/span&gt;
   android:&lt;span class=&quot;hl kwb&quot;&gt;name&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;.ClickerApplication&quot;&lt;/span&gt;
...
&lt;/pre&gt;
Ahora ya podemos sustituir la clase &lt;i&gt;Log&lt;/i&gt; por &lt;i&gt;Timber&lt;/i&gt; de esta manera:
&lt;br /&gt;
&lt;pre class=&quot;hl&quot;&gt;&lt;span class=&quot;hl slc&quot;&gt;// requiere import timber.log.Timber&lt;/span&gt;
&lt;span class=&quot;hl slc&quot;&gt;// ya no se requiere import android.util.Log&lt;/span&gt;
&lt;span class=&quot;hl slc&quot;&gt;// Log.i(&quot;MainActivity&quot;, &quot;Activity Status: Created&quot;)&lt;/span&gt;
Timber&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl str&quot;&gt;&quot;Activity Status: Created&quot;&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;
&lt;/pre&gt;
Y comprobamos en &lt;i&gt;Logcat&lt;/i&gt; que aparece el mensaje (en el campo de búsqueda podemos escribir simplemente el nombre de la actividad, por ejemplo &lt;i&gt;MainActivity&lt;/i&gt;).</content><link rel='replies' type='application/atom+xml' href='https://kotlindoc.blogspot.com/feeds/2120437251174029921/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='https://kotlindoc.blogspot.com/2019/10/android-log-con-timber.html#comment-form' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='https://www.blogger.com/feeds/6895501055750567199/posts/default/2120437251174029921'/><link rel='self' type='application/atom+xml' href='https://www.blogger.com/feeds/6895501055750567199/posts/default/2120437251174029921'/><link rel='alternate' type='text/html' href='https://kotlindoc.blogspot.com/2019/10/android-log-con-timber.html' title='Android: log con Timber'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhK0OWNNP9ZJPGs4lyELL69hAvg96lK200hRV2Eh2FnXAGekY83wiFMIO5gJ6SDgkJu3EU3kCHR17i698RYv5_XMBixs1WG73x5wVowou9cPvADzC1Vu5OyM8BAjjM5NOLL4O3zhPnrSfw/s72-c/timber.jpeg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6895501055750567199.post-8308066227082455850</id><published>2019-10-21T18:13:00.002+02:00</published><updated>2019-10-21T18:13:29.255+02:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="bucles"/><category scheme="http://www.blogger.com/atom/ns#" term="control de flujo"/><category scheme="http://www.blogger.com/atom/ns#" term="kotlin básico"/><title type='text'>Bucles con repeat</title><content type='html'>&lt;img alt=&quot;Bucles con repeat&quot; border=&quot;0&quot; data-original-height=&quot;309&quot; data-original-width=&quot;500&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhLWU2olEsgOGkecpld_RaPEbGpUPQ0erhazZNGGEEgVaYYDPVr7-K-Y1yKwHNnRFkMpsJ1nLU2Juk6QvhiWFCwq4YO7xhQmQIzOtOBTJEKF4S5JZopqfxy28OUJTKZBz1TKiHmhXr87FI/s1600/repeat.png&quot; title=&quot;Bucles con repeat&quot; /&gt;&lt;br /&gt;
Hasta ahora hemos creado &lt;a href=&quot;https://kotlindoc.blogspot.com/search/label/bucles&quot;&gt;bucles&lt;/a&gt; con instrucciones como &lt;i&gt;for&lt;/i&gt;, &lt;i&gt;while&lt;/i&gt; y &lt;i&gt;do/while&lt;/i&gt;, pero la biblioteca estándar de Kotlin también contiene otra instrucción, &lt;i&gt;repeat&lt;/i&gt;, que nos permite otra forma de crear estructuras de repetición.&lt;br /&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;br /&gt;
En concreto, la función &lt;i&gt;repeat()&lt;/i&gt; nos sirve para ejecutar una acción una cantidad determinada de veces tomando como parámetros una función &lt;i&gt;lambda&lt;/i&gt; y un índice entero de veces de iteración:
&lt;br /&gt;
&lt;pre class=&quot;hl&quot;&gt;&lt;span class=&quot;hl kwd&quot;&gt;repeat&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl num&quot;&gt;10&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;) { ... }&lt;/span&gt;
&lt;/pre&gt;
Por ejemplo:
&lt;br /&gt;
&lt;pre class=&quot;hl&quot;&gt;&lt;span class=&quot;hl kwa&quot;&gt;fun&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;main&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;() {&lt;/span&gt;
    &lt;span class=&quot;hl kwd&quot;&gt;repeat&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl num&quot;&gt;5&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;) {&lt;/span&gt; i &lt;span class=&quot;hl opt&quot;&gt;-&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;hl kwd&quot;&gt;println&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl str&quot;&gt;&quot;Paso&lt;/span&gt; &lt;span class=&quot;hl ipl&quot;&gt;${i + 1}&lt;/span&gt; &lt;span class=&quot;hl str&quot;&gt;de 5&quot;&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt;
&lt;/pre&gt;
Otro ejemplo:
&lt;br /&gt;
&lt;pre class=&quot;hl&quot;&gt;&lt;span class=&quot;hl kwa&quot;&gt;fun&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;main&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;() {&lt;/span&gt;

    &lt;span class=&quot;hl slc&quot;&gt;// saluda 3 veces&lt;/span&gt;
    &lt;span class=&quot;hl kwd&quot;&gt;repeat&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl num&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;) {&lt;/span&gt;
        &lt;span class=&quot;hl kwd&quot;&gt;println&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl str&quot;&gt;&quot;Hola&quot;&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt;

    &lt;span class=&quot;hl kwd&quot;&gt;repeat&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl num&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;) {&lt;/span&gt;
        &lt;span class=&quot;hl kwd&quot;&gt;error&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl str&quot;&gt;&quot;¡Esta acción no debería ejecutarse!&quot;&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt;
&lt;/pre&gt;
Y aplicada a una secuencia de caracteres la podemos utilizar de esta manera para conseguir el mismo resultado que en el ejemplo anterior:
&lt;br /&gt;
&lt;pre class=&quot;hl&quot;&gt;&lt;span class=&quot;hl kwd&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl str&quot;&gt;&quot;Hola&lt;/span&gt;&lt;span class=&quot;hl esc&quot;&gt;\n&lt;/span&gt;&lt;span class=&quot;hl str&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;repeat&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl num&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;))&lt;/span&gt;
&lt;/pre&gt;
En este caso, un índice negativo lanza la excepción &lt;i&gt;IllegalArgumentException&lt;/i&gt;. Otro ejemplo:
&lt;br /&gt;
&lt;pre class=&quot;hl&quot;&gt;&lt;span class=&quot;hl kwa&quot;&gt;val&lt;/span&gt; str &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;hl str&quot;&gt;&quot;*&quot;&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;repeat&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl num&quot;&gt;10&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;hl kwd&quot;&gt;println&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;str&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;  &lt;span class=&quot;hl slc&quot;&gt;// **********&lt;/span&gt;
&lt;/pre&gt;</content><link rel='replies' type='application/atom+xml' href='https://kotlindoc.blogspot.com/feeds/8308066227082455850/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='https://kotlindoc.blogspot.com/2019/10/bucles-con-repeat.html#comment-form' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='https://www.blogger.com/feeds/6895501055750567199/posts/default/8308066227082455850'/><link rel='self' type='application/atom+xml' href='https://www.blogger.com/feeds/6895501055750567199/posts/default/8308066227082455850'/><link rel='alternate' type='text/html' href='https://kotlindoc.blogspot.com/2019/10/bucles-con-repeat.html' title='Bucles con repeat'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhLWU2olEsgOGkecpld_RaPEbGpUPQ0erhazZNGGEEgVaYYDPVr7-K-Y1yKwHNnRFkMpsJ1nLU2Juk6QvhiWFCwq4YO7xhQmQIzOtOBTJEKF4S5JZopqfxy28OUJTKZBz1TKiHmhXr87FI/s72-c/repeat.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6895501055750567199.post-8233829459337088487</id><published>2019-10-20T18:14:00.002+02:00</published><updated>2019-10-20T18:18:01.968+02:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="kotlin básico"/><title type='text'>Expresiones frecuentes en Kotlin</title><content type='html'>&lt;img alt=&quot;Modismos en Kotlin&quot; border=&quot;0&quot; data-original-height=&quot;450&quot; data-original-width=&quot;800&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhMevirAQ1w3wCGgc_YaX1oyJFsFp2csRhQuhnbQBfIu2418iKtP3XRAjx6106KeqtnxOOzddkcc7iOkpp5sI_LaZ3qgVVPWyXi82HxFwc0pbj6wPr95X5rUKbvNXLpAIxxNkFpdr7BIfo/s1600/modismos-min.jpg&quot; title=&quot;Modismos en Kotlin&quot; /&gt;
&lt;br /&gt;&lt;br /&gt;
Colección de expresiones de uso frecuente (modismos) en Kotlin.&lt;br /&gt;&lt;br /&gt;&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;
&lt;h2&gt;Variables&lt;/h2&gt;
Intercambiar dos variables:&lt;br /&gt;
&lt;pre class=&quot;hl&quot;&gt;&lt;span class=&quot;hl kwa&quot;&gt;var&lt;/span&gt; a &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;hl num&quot;&gt;1&lt;/span&gt;
&lt;span class=&quot;hl kwa&quot;&gt;var&lt;/span&gt; b &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;hl num&quot;&gt;2&lt;/span&gt;
a &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; b&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;also &lt;span class=&quot;hl opt&quot;&gt;{&lt;/span&gt; b &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; a &lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt;&lt;/pre&gt;
&lt;br /&gt;
Propiedad &lt;i&gt;lazy&lt;/i&gt;:&lt;br /&gt;
&lt;pre class=&quot;hl&quot;&gt;&lt;span class=&quot;hl kwa&quot;&gt;val&lt;/span&gt; p&lt;span class=&quot;hl opt&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;hl kwb&quot;&gt;String&lt;/span&gt; by lazy &lt;span class=&quot;hl opt&quot;&gt;{&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl slc&quot;&gt;// calcula el valor del string&lt;/span&gt;
&lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;
&lt;h2&gt;&lt;i&gt;String&lt;/i&gt;&lt;/h2&gt;
Interpolación de &lt;i&gt;Strings&lt;/i&gt;:&lt;br /&gt;
&lt;pre class=&quot;hl&quot;&gt;&lt;span class=&quot;hl kwd&quot;&gt;println&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl str&quot;&gt;&quot;Nombre:&lt;/span&gt; &lt;span class=&quot;hl ipl&quot;&gt;$nombre&lt;/span&gt;&lt;span class=&quot;hl str&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;&lt;/pre&gt;
&lt;br /&gt;
&lt;h2&gt;Expresiones&lt;/h2&gt;
Expresión &lt;i&gt;if&lt;/i&gt;:&lt;br /&gt;
&lt;pre class=&quot;hl&quot;&gt;&lt;span class=&quot;hl kwa&quot;&gt;fun&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;foo&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;param&lt;span class=&quot;hl opt&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;hl kwb&quot;&gt;Int&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;) {&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;val&lt;/span&gt; result &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;hl kwa&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;param &lt;span class=&quot;hl opt&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;hl num&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;) {&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl str&quot;&gt;&quot;one&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;hl kwa&quot;&gt;else if&lt;/span&gt; &lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;param &lt;span class=&quot;hl opt&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;hl num&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;) {&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl str&quot;&gt;&quot;two&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;hl kwa&quot;&gt;else&lt;/span&gt; &lt;span class=&quot;hl opt&quot;&gt;{&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl str&quot;&gt;&quot;three&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt;&lt;/pre&gt;
&lt;br /&gt;
Expresión &lt;i&gt;try/catch&lt;/i&gt;:&lt;br /&gt;
&lt;pre class=&quot;hl&quot;&gt;&lt;span class=&quot;hl kwa&quot;&gt;fun&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;test&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;() {&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;val&lt;/span&gt; result &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;hl kwa&quot;&gt;try&lt;/span&gt; &lt;span class=&quot;hl opt&quot;&gt;{&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwd&quot;&gt;count&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;()&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;catch&lt;/span&gt; &lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;e&lt;span class=&quot;hl opt&quot;&gt;:&lt;/span&gt; ArithmeticException&lt;span class=&quot;hl opt&quot;&gt;) {&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;throw&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;IllegalStateException&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;e&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl slc&quot;&gt;// trabajando con result&lt;/span&gt;
&lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt;&lt;/pre&gt;
&lt;br /&gt;
&lt;h2&gt;Colecciones&lt;/h2&gt;
Lista de solo lectura:&lt;br /&gt;
&lt;pre class=&quot;hl&quot;&gt;&lt;span class=&quot;hl kwa&quot;&gt;val&lt;/span&gt; list &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;listOf&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl str&quot;&gt;&quot;a&quot;&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;hl str&quot;&gt;&quot;b&quot;&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;hl str&quot;&gt;&quot;c&quot;&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;&lt;/pre&gt;
&lt;br /&gt;
Lista mutable:&lt;br /&gt;
&lt;pre class=&quot;hl&quot;&gt;&lt;span class=&quot;hl kwa&quot;&gt;val&lt;/span&gt; lista &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;listOf&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl str&quot;&gt;&amp;quot;a&amp;quot;&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;hl str&quot;&gt;&amp;quot;b&amp;quot;&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;hl str&quot;&gt;&amp;quot;c&amp;quot;&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;hl kwa&quot;&gt;val&lt;/span&gt; listaMutable &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;mutableListOf&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl str&quot;&gt;&amp;quot;a&amp;quot;&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;hl str&quot;&gt;&amp;quot;b&amp;quot;&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;hl str&quot;&gt;&amp;quot;c&amp;quot;&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;).&lt;/span&gt;apply &lt;span class=&quot;hl opt&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;hl kwd&quot;&gt;add&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl str&quot;&gt;&amp;quot;d&amp;quot;&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;hl kwd&quot;&gt;remove&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl str&quot;&gt;&amp;quot;b&amp;quot;&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt;
&lt;/pre&gt;&lt;br /&gt;
Mapa de solo lectura:&lt;br /&gt;
&lt;pre class=&quot;hl&quot;&gt;&lt;span class=&quot;hl kwa&quot;&gt;val&lt;/span&gt; map &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;mapOf&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl str&quot;&gt;&quot;a&quot;&lt;/span&gt; to &lt;span class=&quot;hl num&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;hl str&quot;&gt;&quot;b&quot;&lt;/span&gt; to &lt;span class=&quot;hl num&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;hl str&quot;&gt;&quot;c&quot;&lt;/span&gt; to &lt;span class=&quot;hl num&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;&lt;/pre&gt;
&lt;br /&gt;
Mapa mutable:&lt;br /&gt;
&lt;pre class=&quot;hl&quot;&gt;&lt;span class=&quot;hl kwa&quot;&gt;val&lt;/span&gt; mapa &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;mutableMapOf&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl str&quot;&gt;&amp;quot;a&amp;quot;&lt;/span&gt; to &lt;span class=&quot;hl num&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;hl str&quot;&gt;&amp;quot;b&amp;quot;&lt;/span&gt; to &lt;span class=&quot;hl num&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;hl str&quot;&gt;&amp;quot;c&amp;quot;&lt;/span&gt; to &lt;span class=&quot;hl num&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;
mapa&lt;span class=&quot;hl opt&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;hl str&quot;&gt;&amp;quot;a&amp;quot;&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;] =&lt;/span&gt; &lt;span class=&quot;hl num&quot;&gt;10&lt;/span&gt;
&lt;/pre&gt;
&lt;br /&gt;
Acceder a un mapa:&lt;br /&gt;
&lt;pre class=&quot;hl&quot;&gt;&lt;span class=&quot;hl kwd&quot;&gt;println&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;map&lt;span class=&quot;hl opt&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;hl str&quot;&gt;&quot;key&quot;&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;])&lt;/span&gt;
map&lt;span class=&quot;hl opt&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;hl str&quot;&gt;&quot;key&quot;&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;] =&lt;/span&gt; value&lt;/pre&gt;
&lt;br /&gt;
Filtrar una lista:&lt;br /&gt;
&lt;pre class=&quot;hl&quot;&gt;&lt;span class=&quot;hl kwa&quot;&gt;val&lt;/span&gt; positivos &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; list&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;filter &lt;span class=&quot;hl opt&quot;&gt;{&lt;/span&gt; x &lt;span class=&quot;hl opt&quot;&gt;-&amp;gt;&lt;/span&gt; x &lt;span class=&quot;hl opt&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;hl num&quot;&gt;0&lt;/span&gt; &lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt;&lt;/pre&gt;
O, alternativamente y más corto:&lt;br /&gt;
&lt;pre class=&quot;hl&quot;&gt;&lt;span class=&quot;hl kwa&quot;&gt;val&lt;/span&gt; positivos &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; list&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;filter &lt;span class=&quot;hl opt&quot;&gt;{&lt;/span&gt; it &lt;span class=&quot;hl opt&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;hl num&quot;&gt;0&lt;/span&gt; &lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt;&lt;/pre&gt;
&lt;br /&gt;
Comprobar la presencia de un elemento en una colección:&lt;br /&gt;
&lt;pre class=&quot;hl&quot;&gt;&lt;span class=&quot;hl kwa&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl str&quot;&gt;&quot;fulano@example.com&quot;&lt;/span&gt; &lt;span class=&quot;hl kwa&quot;&gt;in&lt;/span&gt; emailsList&lt;span class=&quot;hl opt&quot;&gt;) { ... }&lt;/span&gt;

&lt;span class=&quot;hl kwa&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl str&quot;&gt;&quot;mengano@example.com&quot;&lt;/span&gt; &lt;span class=&quot;hl opt&quot;&gt;!&lt;/span&gt;&lt;span class=&quot;hl kwa&quot;&gt;in&lt;/span&gt; emailsList&lt;span class=&quot;hl opt&quot;&gt;) { ... }&lt;/span&gt;&lt;/pre&gt;
&lt;br /&gt;
Recorrer un mapa o lista de pares:&lt;br /&gt;
&lt;pre class=&quot;hl&quot;&gt;&lt;span class=&quot;hl kwa&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;hl opt&quot;&gt;((&lt;/span&gt;k&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; v&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;hl kwa&quot;&gt;in&lt;/span&gt; map&lt;span class=&quot;hl opt&quot;&gt;) {&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwd&quot;&gt;println&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl str&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;hl ipl&quot;&gt;$k&lt;/span&gt; &lt;span class=&quot;hl str&quot;&gt;-&amp;gt;&lt;/span&gt; &lt;span class=&quot;hl ipl&quot;&gt;$v&lt;/span&gt;&lt;span class=&quot;hl str&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt;&lt;/pre&gt;
Otra opción:
&lt;pre class=&quot;hl&quot;&gt;&lt;span class=&quot;hl kwa&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;map &lt;span class=&quot;hl kwa&quot;&gt;in&lt;/span&gt; mapa&lt;span class=&quot;hl opt&quot;&gt;) {&lt;/span&gt;
    &lt;span class=&quot;hl kwd&quot;&gt;println&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl str&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;hl ipl&quot;&gt;${map.key}&lt;/span&gt; &lt;span class=&quot;hl str&quot;&gt;-&amp;gt;&lt;/span&gt; &lt;span class=&quot;hl ipl&quot;&gt;${map.value}&lt;/span&gt;&lt;span class=&quot;hl str&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt;
&lt;/pre&gt;
&lt;br /&gt;
&lt;h2&gt;Rangos&lt;/h2&gt;
Usar rangos:&lt;br /&gt;
&lt;pre class=&quot;hl&quot;&gt;&lt;span class=&quot;hl kwa&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;i &lt;span class=&quot;hl kwa&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;hl num&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl num&quot;&gt;.100&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;) { ... }&lt;/span&gt;&amp;nbsp; &lt;span class=&quot;hl slc&quot;&gt;// incluye 100&lt;/span&gt;
&lt;span class=&quot;hl kwa&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;i &lt;span class=&quot;hl kwa&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;hl num&quot;&gt;1&lt;/span&gt; until &lt;span class=&quot;hl num&quot;&gt;100&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;) { ... }&lt;/span&gt; &lt;span class=&quot;hl slc&quot;&gt;// no incluye 100&lt;/span&gt;
&lt;span class=&quot;hl kwa&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;x &lt;span class=&quot;hl kwa&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;hl num&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl num&quot;&gt;.10&lt;/span&gt; step &lt;span class=&quot;hl num&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;) { ... }&lt;/span&gt;
&lt;span class=&quot;hl kwa&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;x &lt;span class=&quot;hl kwa&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;hl num&quot;&gt;10&lt;/span&gt; downTo &lt;span class=&quot;hl num&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;) { ... }&lt;/span&gt;
&lt;span class=&quot;hl kwa&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;x &lt;span class=&quot;hl kwa&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;hl num&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl num&quot;&gt;.10&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;) { ... }&lt;/span&gt;&lt;/pre&gt;
&lt;br /&gt;
&lt;h2&gt;Gestión de tipos nulos&lt;/h2&gt;
Si no null:&lt;br /&gt;
&lt;pre class=&quot;hl&quot;&gt;&lt;span class=&quot;hl kwa&quot;&gt;val&lt;/span&gt; files &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;File&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl str&quot;&gt;&quot;Test&quot;&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;).&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;listFiles&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;()&lt;/span&gt;

&lt;span class=&quot;hl kwd&quot;&gt;println&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;files?&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;size&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;&lt;/pre&gt;
&lt;br /&gt;
Si no null con &lt;i&gt;else&lt;/i&gt;:&lt;br /&gt;
&lt;pre class=&quot;hl&quot;&gt;&lt;span class=&quot;hl kwa&quot;&gt;val&lt;/span&gt; files &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;File&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl str&quot;&gt;&quot;Test&quot;&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;).&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;listFiles&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;()&lt;/span&gt;

&lt;span class=&quot;hl kwd&quot;&gt;println&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;files?&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;size ?&lt;span class=&quot;hl opt&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;hl str&quot;&gt;&quot;empty&quot;&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;&lt;/pre&gt;
&lt;br /&gt;
Ejecutar una declaración si es nulo:&lt;br /&gt;
&lt;pre class=&quot;hl&quot;&gt;&lt;span class=&quot;hl kwa&quot;&gt;val&lt;/span&gt; values &lt;span class=&quot;hl opt&quot;&gt;= ...&lt;/span&gt;
&lt;span class=&quot;hl kwa&quot;&gt;val&lt;/span&gt; email &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; values&lt;span class=&quot;hl opt&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;hl str&quot;&gt;&quot;email&quot;&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;]&lt;/span&gt; ?&lt;span class=&quot;hl opt&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;hl kwa&quot;&gt;throw&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;IllegalStateException&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl str&quot;&gt;&quot;Email is missing!&quot;&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;&lt;/pre&gt;
&lt;br /&gt;
Obtener el primer elemento de una colección que puede estar vacía:&lt;br /&gt;
&lt;pre class=&quot;hl&quot;&gt;&lt;span class=&quot;hl kwa&quot;&gt;val&lt;/span&gt; emails &lt;span class=&quot;hl opt&quot;&gt;= ...&lt;/span&gt; &lt;span class=&quot;hl slc&quot;&gt;// puede estar vacía&lt;/span&gt;
&lt;span class=&quot;hl kwa&quot;&gt;val&lt;/span&gt; mainEmail &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; emails&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;firstOrNull&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;()&lt;/span&gt; ?&lt;span class=&quot;hl opt&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;hl str&quot;&gt;&quot;&quot;&lt;/span&gt;&lt;/pre&gt;
&lt;br /&gt;
Ejecutar una declaración si es nulo:&lt;br /&gt;
&lt;pre class=&quot;hl&quot;&gt;&lt;span class=&quot;hl kwa&quot;&gt;val&lt;/span&gt; value &lt;span class=&quot;hl opt&quot;&gt;= ...&lt;/span&gt;

value?&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;let &lt;span class=&quot;hl opt&quot;&gt;{&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl opt&quot;&gt;...&lt;/span&gt; &lt;span class=&quot;hl slc&quot;&gt;// ejecuta este bloque si no null&lt;/span&gt;
&lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt;&lt;/pre&gt;
&lt;br /&gt;
Valor nulable del mapa si no es nulo:&lt;br /&gt;
&lt;pre class=&quot;hl&quot;&gt;&lt;span class=&quot;hl kwa&quot;&gt;val&lt;/span&gt; value &lt;span class=&quot;hl opt&quot;&gt;= ...&lt;/span&gt;

&lt;span class=&quot;hl kwa&quot;&gt;val&lt;/span&gt; mapped &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; value?&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;let &lt;span class=&quot;hl opt&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;transformValue&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;it&lt;span class=&quot;hl opt&quot;&gt;) }&lt;/span&gt; ?&lt;span class=&quot;hl opt&quot;&gt;:&lt;/span&gt; defaultValueIfValueIsNull&lt;/pre&gt;
&lt;br /&gt;
Boolean anulable:&lt;br /&gt;
&lt;pre class=&quot;hl&quot;&gt;&lt;span class=&quot;hl kwa&quot;&gt;val&lt;/span&gt; b&lt;span class=&quot;hl opt&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;hl kwb&quot;&gt;Boolean&lt;/span&gt;? &lt;span class=&quot;hl opt&quot;&gt;= ...&lt;/span&gt;
&lt;span class=&quot;hl kwa&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;b &lt;span class=&quot;hl opt&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;hl kwa&quot;&gt;true&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;) {&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl opt&quot;&gt;...&lt;/span&gt;
&lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;hl kwa&quot;&gt;else&lt;/span&gt; &lt;span class=&quot;hl opt&quot;&gt;{&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl slc&quot;&gt;// `b` is false or null&lt;/span&gt;
&lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt;&lt;/pre&gt;
&lt;br /&gt;
&lt;h2&gt;Funciones&lt;/h2&gt;
Valores predeterminados para parámetros de función&lt;br /&gt;
&lt;pre class=&quot;hl&quot;&gt;&lt;span class=&quot;hl kwa&quot;&gt;fun&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;foo&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;a&lt;span class=&quot;hl opt&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;hl kwb&quot;&gt;Int&lt;/span&gt; &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;hl num&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; b&lt;span class=&quot;hl opt&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;hl kwb&quot;&gt;String&lt;/span&gt; &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;hl str&quot;&gt;&quot;&quot;&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;) { ... }&lt;/span&gt;&lt;/pre&gt;
&lt;br /&gt;
Declaración de retorno con &lt;i&gt;when&lt;/i&gt;:&lt;br /&gt;
&lt;pre class=&quot;hl&quot;&gt;&lt;span class=&quot;hl kwa&quot;&gt;fun&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;transform&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;color&lt;span class=&quot;hl opt&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;hl kwb&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;):&lt;/span&gt; &lt;span class=&quot;hl kwb&quot;&gt;Int&lt;/span&gt; &lt;span class=&quot;hl opt&quot;&gt;{&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;return when&lt;/span&gt; &lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;color&lt;span class=&quot;hl opt&quot;&gt;) {&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl str&quot;&gt;&quot;Red&quot;&lt;/span&gt; &lt;span class=&quot;hl opt&quot;&gt;-&amp;gt;&lt;/span&gt; &lt;span class=&quot;hl num&quot;&gt;0&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl str&quot;&gt;&quot;Green&quot;&lt;/span&gt; &lt;span class=&quot;hl opt&quot;&gt;-&amp;gt;&lt;/span&gt; &lt;span class=&quot;hl num&quot;&gt;1&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl str&quot;&gt;&quot;Blue&quot;&lt;/span&gt; &lt;span class=&quot;hl opt&quot;&gt;-&amp;gt;&lt;/span&gt; &lt;span class=&quot;hl num&quot;&gt;2&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;else&lt;/span&gt; &lt;span class=&quot;hl opt&quot;&gt;-&amp;gt;&lt;/span&gt; &lt;span class=&quot;hl kwa&quot;&gt;throw&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;IllegalArgumentException&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl str&quot;&gt;&quot;Invalid color param value&quot;&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt;&lt;/pre&gt;
&lt;br /&gt;
Funciones de extensión:&lt;br /&gt;
&lt;pre class=&quot;hl&quot;&gt;&lt;span class=&quot;hl kwa&quot;&gt;fun&lt;/span&gt; &lt;span class=&quot;hl kwb&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;spaceToCamelCase&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;() { ... }&lt;/span&gt;

&lt;span class=&quot;hl str&quot;&gt;&quot;Convert this to camelcase&quot;&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;spaceToCamelCase&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;()&lt;/span&gt;&lt;/pre&gt;
Otro ejemplo:&lt;br /&gt;
&lt;pre class=&quot;hl&quot;&gt;&lt;span class=&quot;hl kwa&quot;&gt;fun&lt;/span&gt; &lt;span class=&quot;hl kwb&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;invertirTexto&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;():&lt;/span&gt; &lt;span class=&quot;hl kwb&quot;&gt;String&lt;/span&gt; &lt;span class=&quot;hl opt&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;hl kwa&quot;&gt;var&lt;/span&gt; textoInvertido &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;hl str&quot;&gt;&amp;quot;&amp;quot;&lt;/span&gt;
    &lt;span class=&quot;hl kwa&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;i &lt;span class=&quot;hl kwa&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl kwa&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;length &lt;span class=&quot;hl opt&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;hl num&quot;&gt;1&lt;/span&gt; downTo &lt;span class=&quot;hl num&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;)) {&lt;/span&gt;
        textoInvertido &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; textoInvertido &lt;span class=&quot;hl opt&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;hl kwa&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;get&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;i&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt;
    &lt;span class=&quot;hl kwa&quot;&gt;return&lt;/span&gt; textoInvertido
&lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt;
&lt;/pre&gt;
&lt;br /&gt;
Métodos que devuelven Unit:&lt;br /&gt;
&lt;pre class=&quot;hl&quot;&gt;&lt;span class=&quot;hl kwa&quot;&gt;fun&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;arrayOfMinusOnes&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;size&lt;span class=&quot;hl opt&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;hl kwb&quot;&gt;Int&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;):&lt;/span&gt; IntArray &lt;span class=&quot;hl opt&quot;&gt;{&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;IntArray&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;size&lt;span class=&quot;hl opt&quot;&gt;).&lt;/span&gt;apply &lt;span class=&quot;hl opt&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;fill&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(-&lt;/span&gt;&lt;span class=&quot;hl num&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;) }&lt;/span&gt;
&lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt;&lt;/pre&gt;
&lt;br /&gt;
Funciones de una sola expresión:&lt;br /&gt;
&lt;pre class=&quot;hl&quot;&gt;&lt;span class=&quot;hl kwa&quot;&gt;fun&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;theAnswer&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;() =&lt;/span&gt; &lt;span class=&quot;hl num&quot;&gt;42&lt;/span&gt;&lt;/pre&gt;
que es equivalente a:&lt;br /&gt;
&lt;pre class=&quot;hl&quot;&gt;&lt;span class=&quot;hl kwa&quot;&gt;fun&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;theAnswer&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;():&lt;/span&gt; &lt;span class=&quot;hl kwb&quot;&gt;Int&lt;/span&gt; &lt;span class=&quot;hl opt&quot;&gt;{&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;hl num&quot;&gt;42&lt;/span&gt;
&lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt;&lt;/pre&gt;
&lt;br /&gt;
Esto se puede combinar con otras expresiones idiomáticas, lo que lleva a un código más corto. Por ejemplo, con la expresión &lt;i&gt;when&lt;/i&gt;:&lt;br /&gt;
&lt;pre class=&quot;hl&quot;&gt;&lt;span class=&quot;hl kwa&quot;&gt;fun&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;transform&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;color&lt;span class=&quot;hl opt&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;hl kwb&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;):&lt;/span&gt; &lt;span class=&quot;hl kwb&quot;&gt;Int&lt;/span&gt; &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;hl kwa&quot;&gt;when&lt;/span&gt; &lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;color&lt;span class=&quot;hl opt&quot;&gt;) {&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl str&quot;&gt;&quot;Red&quot;&lt;/span&gt; &lt;span class=&quot;hl opt&quot;&gt;-&amp;gt;&lt;/span&gt; &lt;span class=&quot;hl num&quot;&gt;0&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl str&quot;&gt;&quot;Green&quot;&lt;/span&gt; &lt;span class=&quot;hl opt&quot;&gt;-&amp;gt;&lt;/span&gt; &lt;span class=&quot;hl num&quot;&gt;1&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl str&quot;&gt;&quot;Blue&quot;&lt;/span&gt; &lt;span class=&quot;hl opt&quot;&gt;-&amp;gt;&lt;/span&gt; &lt;span class=&quot;hl num&quot;&gt;2&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;else&lt;/span&gt; &lt;span class=&quot;hl opt&quot;&gt;-&amp;gt;&lt;/span&gt; &lt;span class=&quot;hl kwa&quot;&gt;throw&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;IllegalArgumentException&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl str&quot;&gt;&quot;Invalid color param value&quot;&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt;&lt;/pre&gt;
&lt;br /&gt;
Función genérica que requiere la información de tipo genérico:&lt;br /&gt;
&lt;pre class=&quot;hl&quot;&gt;&lt;span class=&quot;hl slc&quot;&gt;//&amp;nbsp; public final class Gson {&lt;/span&gt;
&lt;span class=&quot;hl slc&quot;&gt;//&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ...&lt;/span&gt;
&lt;span class=&quot;hl slc&quot;&gt;//&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; public &amp;lt;T&amp;gt; T fromJson(JsonElement json, Class&amp;lt;T&amp;gt; classOfT) throws JsonSyntaxException {&lt;/span&gt;
&lt;span class=&quot;hl slc&quot;&gt;//&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ...&lt;/span&gt;

inline &lt;span class=&quot;hl kwa&quot;&gt;fun&lt;/span&gt; &lt;span class=&quot;hl opt&quot;&gt;&amp;lt;&lt;/span&gt;reified T&lt;span class=&quot;hl opt&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;hl kwb&quot;&gt;Any&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;&amp;gt;&lt;/span&gt; Gson&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;fromJson&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;json&lt;span class=&quot;hl opt&quot;&gt;:&lt;/span&gt; JsonElement&lt;span class=&quot;hl opt&quot;&gt;):&lt;/span&gt; T &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;hl kwa&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;fromJson&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;json&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; T&lt;span class=&quot;hl opt&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl kwa&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;java&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;&lt;/pre&gt;
&lt;br /&gt;
&lt;h2&gt;Clases y objetos&lt;/h2&gt;
Crear objetos o clases (DTO – Data Transfer Object, POCO – Plain Old CLR Object, POJO Plain Old Java Object) con funcionalidades getters y setters (en caso de var) para todas las propiedades:&lt;br /&gt;
&lt;pre class=&quot;hl&quot;&gt;data &lt;span class=&quot;hl kwa&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;Cliente&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl kwa&quot;&gt;val&lt;/span&gt; nombre&lt;span class=&quot;hl opt&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;hl kwb&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;hl kwa&quot;&gt;val&lt;/span&gt; email&lt;span class=&quot;hl opt&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;hl kwb&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;&lt;/pre&gt;
&lt;br /&gt;
Comprobación de instancias:&lt;br /&gt;
&lt;pre class=&quot;hl&quot;&gt;&lt;span class=&quot;hl kwa&quot;&gt;when&lt;/span&gt; &lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;x&lt;span class=&quot;hl opt&quot;&gt;) {&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;is&lt;/span&gt; Foo &lt;span class=&quot;hl opt&quot;&gt;-&amp;gt; ...&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;is&lt;/span&gt; Bar &lt;span class=&quot;hl opt&quot;&gt;-&amp;gt; ...&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;else&lt;/span&gt;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl opt&quot;&gt;-&amp;gt; ...&lt;/span&gt;
&lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt;&lt;/pre&gt;
&lt;br /&gt;
Crear un singleton:&lt;br /&gt;
&lt;pre class=&quot;hl&quot;&gt;&lt;span class=&quot;hl kwa&quot;&gt;object&lt;/span&gt; Resource &lt;span class=&quot;hl opt&quot;&gt;{&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;val&lt;/span&gt; nombre &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;hl str&quot;&gt;&quot;Nombre&quot;&lt;/span&gt;
&lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt;&lt;/pre&gt;
O un objeto anónimo:&lt;br /&gt;
&lt;pre class=&quot;hl&quot;&gt;&lt;span class=&quot;hl kwa&quot;&gt;val&lt;/span&gt; resource &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;hl kwa&quot;&gt;object&lt;/span&gt; &lt;span class=&quot;hl opt&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;hl kwa&quot;&gt;val&lt;/span&gt; nombre &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;hl str&quot;&gt;&amp;quot;Kotlin&amp;quot;&lt;/span&gt;
&lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt;
&lt;/pre&gt;
&lt;br /&gt;
Llamar a varios métodos en una instancia de objeto (&lt;i&gt;with&lt;/i&gt;):&lt;br /&gt;
&lt;pre class=&quot;hl&quot;&gt;&lt;span class=&quot;hl kwa&quot;&gt;class&lt;/span&gt; Turtle &lt;span class=&quot;hl opt&quot;&gt;{&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;fun&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;penDown&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;()&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;fun&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;penUp&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;()&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;fun&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;turn&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;degrees&lt;span class=&quot;hl opt&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;hl kwb&quot;&gt;Double&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;fun&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;forward&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;pixels&lt;span class=&quot;hl opt&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;hl kwb&quot;&gt;Double&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;hl kwa&quot;&gt;val&lt;/span&gt; myTurtle &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;Turtle&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;()&lt;/span&gt;
&lt;span class=&quot;hl kwd&quot;&gt;with&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;myTurtle&lt;span class=&quot;hl opt&quot;&gt;) {&lt;/span&gt; &lt;span class=&quot;hl slc&quot;&gt;// dibujar un cuadrado de 100 pix&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwd&quot;&gt;penDown&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;()&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;for&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;i &lt;span class=&quot;hl kwa&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;hl num&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl num&quot;&gt;.4&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;) {&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwd&quot;&gt;forward&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl num&quot;&gt;100.0&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwd&quot;&gt;turn&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl num&quot;&gt;90.0&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwd&quot;&gt;penUp&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;()&lt;/span&gt;
&lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt;&lt;/pre&gt;
&lt;br /&gt;
&lt;h2&gt;Acceso a recursos (Java 7)&lt;/h2&gt;
&lt;pre class=&quot;hl&quot;&gt;&lt;span class=&quot;hl kwa&quot;&gt;val&lt;/span&gt; stream &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; Files&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;newInputStream&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;Paths&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;get&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl str&quot;&gt;&quot;/some/file.txt&quot;&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;))&lt;/span&gt;
stream&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;buffered&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;().&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;reader&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;().&lt;/span&gt;use &lt;span class=&quot;hl opt&quot;&gt;{&lt;/span&gt; reader &lt;span class=&quot;hl opt&quot;&gt;-&amp;gt;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwd&quot;&gt;println&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;reader&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;readText&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;())&lt;/span&gt;
&lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt;&lt;/pre&gt;
&lt;br /&gt;Esta entrada es una traducción libre y adaptada de &lt;a href=&quot;https://kotlinlang.org/docs/reference/idioms.html&quot;&gt;Idioms, a collection of random and frequently used idioms in Kotlin&lt;/a&gt;, disponible en la web oficial de Kotlin.</content><link rel='replies' type='application/atom+xml' href='https://kotlindoc.blogspot.com/feeds/8233829459337088487/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='https://kotlindoc.blogspot.com/2019/10/expresiones-frecuentes-en-kotlin.html#comment-form' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='https://www.blogger.com/feeds/6895501055750567199/posts/default/8233829459337088487'/><link rel='self' type='application/atom+xml' href='https://www.blogger.com/feeds/6895501055750567199/posts/default/8233829459337088487'/><link rel='alternate' type='text/html' href='https://kotlindoc.blogspot.com/2019/10/expresiones-frecuentes-en-kotlin.html' title='Expresiones frecuentes en Kotlin'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhMevirAQ1w3wCGgc_YaX1oyJFsFp2csRhQuhnbQBfIu2418iKtP3XRAjx6106KeqtnxOOzddkcc7iOkpp5sI_LaZ3qgVVPWyXi82HxFwc0pbj6wPr95X5rUKbvNXLpAIxxNkFpdr7BIfo/s72-c/modismos-min.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6895501055750567199.post-4615364612676236720</id><published>2019-10-08T19:36:00.000+02:00</published><updated>2019-10-08T19:36:03.070+02:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="android studio"/><title type='text'>Android Studio con corrector ortográfico en español</title><content type='html'>&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;img alt=&quot;Android Studio con corrector ortográfico en español&quot; border=&quot;0&quot; data-original-height=&quot;500&quot; data-original-width=&quot;750&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjNrXTwDBuOG-omWMJYZ0tNrug2xmmlJnhjslRG-K-iw7vDy7uZNFZpTzWw8lUN1EkgPfPwM2jF34WyD8oXTchxczsp59zVVGxUeokLctFKihWYr4_rvrPGcqNX4Okzp_VZH9lDmTjbmTo/s1600/code.jpg&quot; title=&quot;Android Studio con corrector ortográfico en español&quot; /&gt;&lt;/div&gt;
&lt;br /&gt;
Con frecuencia &lt;i&gt;Android Studio&lt;/i&gt; nos lanza alertas &quot;&lt;i&gt;Typo: in word&lt;/i&gt;&quot; en relación, por ejemplo, al nombre de una variable. Este tipo de advertencias nos avisan de posibles errores ortográficos, aunque realmente significan que esa palabra no es reconocida, y más concretamente que esa palabra no está en el diccionario, o mejor dicho, en ninguno de los diccionarios instalados.&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;
Por tanto no se trata de ningún error de código, y no hay que alarmarse. Esta inspección del corrector ortográfico (&lt;i&gt;Spellchecker&lt;/i&gt;) ayuda a localizar errores tipográficos y errores ortográficos en el código, tanto en comentarios como en literales, y corregirlos con un solo clic.&lt;br /&gt;
&lt;br /&gt;
Ante estas advertencias podemos actuar de distinta manera: agregar la palabra al diccionario instalado, desactivar el corrector ortográfico, ignorar las alertas o, la solución que recomiendo, instalar el diccionario correspondiente a tu idioma.&lt;br /&gt;
&lt;br /&gt;
Por defecto &lt;i&gt;Android Studio&lt;/i&gt; incluye el diccionario en inglés, como podemos ver en &lt;i&gt;File -&amp;gt; Settings -&amp;gt; Editor -&amp;gt; Spelling -&amp;gt; Dictionaries&lt;/i&gt;. Para añadir el diccionario en español primero lo descargamos desde &lt;a href=&quot;http://www.winedt.org/dictASCII.html&quot;&gt;WinEdt ASCII Dictionaries&lt;/a&gt; y descomprimimos el archivo descargado. En la ventana anterior de &lt;i&gt;Android Studio&lt;/i&gt;, en &lt;i&gt;Dictionaries&lt;/i&gt;, pulsamos sobre + y seleccionamos el archivo descargado con extensión dic.&lt;br /&gt;
&lt;br /&gt;
Si &lt;i&gt;Android Studio&lt;/i&gt; no lo reconoce en el momento, reinicia y ya no aparecerán este tipo de advertencias (salvo que la palabra esté mal escrita o no esté incluida en el diccionario).&lt;br /&gt;
&lt;br /&gt;
Nota de reconocimiento: Este diccionario ASCII en español ha sido elaborado originalmente por Juan L. Varona de la Universidad de La Rioja y modificado por Juan I. Montijano y sus colegas.</content><link rel='replies' type='application/atom+xml' href='https://kotlindoc.blogspot.com/feeds/4615364612676236720/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='https://kotlindoc.blogspot.com/2019/10/android-studio-con-corrector.html#comment-form' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='https://www.blogger.com/feeds/6895501055750567199/posts/default/4615364612676236720'/><link rel='self' type='application/atom+xml' href='https://www.blogger.com/feeds/6895501055750567199/posts/default/4615364612676236720'/><link rel='alternate' type='text/html' href='https://kotlindoc.blogspot.com/2019/10/android-studio-con-corrector.html' title='Android Studio con corrector ortográfico en español'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjNrXTwDBuOG-omWMJYZ0tNrug2xmmlJnhjslRG-K-iw7vDy7uZNFZpTzWw8lUN1EkgPfPwM2jF34WyD8oXTchxczsp59zVVGxUeokLctFKihWYr4_rvrPGcqNX4Okzp_VZH9lDmTjbmTo/s72-c/code.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6895501055750567199.post-4053980021919842571</id><published>2019-09-07T17:30:00.002+02:00</published><updated>2019-09-07T17:30:16.517+02:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="android básico"/><title type='text'>Android: Diálogo para introducir datos</title><content type='html'>&lt;img alt=&quot;Android: Diálogo para introducir datos&quot; border=&quot;0&quot; data-original-height=&quot;420&quot; data-original-width=&quot;540&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiWJGxC9RNQ15GhvDGjkZD8pG_zsRXRI17bXaPwRinXnrhhFLnZU-kqloqdohgqnn8Sl8kHuhzKER3zSfWNKGR_dOq_Nh84z2RYXHa5VYxdzzXCq1daKXf3rL_uO8Fbm9p6PlwqVvCNgJM/s1600/dialogo.png&quot; title=&quot;Android: Diálogo para introducir datos&quot; /&gt;&lt;br /&gt;&lt;br /&gt;
En esta entrada vamos a ver dos métodos para mostrar un diálogo que sirve para que el usuario introduzca algún dato que la aplicación le solicita.&lt;br /&gt;
&lt;br /&gt;
El primer método utiliza la clase &lt;i&gt;AlertDialog&lt;/i&gt; para activar un recurso de diseño con un &lt;i&gt;EditText&lt;/i&gt;, y luego configura los botones Aceptar y Cancelar:&lt;br /&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;
&lt;pre class=&quot;hl&quot;&gt;&lt;span class=&quot;hl kwa&quot;&gt;fun&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;mostrarDialogo&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;() {&lt;/span&gt;
    &lt;span class=&quot;hl kwa&quot;&gt;val&lt;/span&gt; context &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;hl kwa&quot;&gt;this&lt;/span&gt;
    &lt;span class=&quot;hl kwa&quot;&gt;val&lt;/span&gt; builder &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; AlertDialog&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;Builder&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;context&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;
    builder&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;setTitle&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl str&quot;&gt;&amp;quot;New List&amp;quot;&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;

    &lt;span class=&quot;hl slc&quot;&gt;// recurso de diseño xml con un EditText&lt;/span&gt;
    &lt;span class=&quot;hl kwa&quot;&gt;val&lt;/span&gt; view &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; layoutInflater&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;inflate&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;R&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;layout&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;dialog_new_list&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;hl kwa&quot;&gt;null&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;hl kwa&quot;&gt;val&lt;/span&gt; listEditText &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; view&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;editText_newList &lt;span class=&quot;hl kwa&quot;&gt;as&lt;/span&gt; EditText
    builder&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;setView&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;view&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;

    builder&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;setPositiveButton&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;android&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;R&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;string&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;ok&lt;span class=&quot;hl opt&quot;&gt;) {&lt;/span&gt; dialog&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; p1 &lt;span class=&quot;hl opt&quot;&gt;-&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;hl kwa&quot;&gt;val&lt;/span&gt; newList &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; listEditText&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;text
        &lt;span class=&quot;hl kwa&quot;&gt;var&lt;/span&gt; isValid &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;hl kwa&quot;&gt;true&lt;/span&gt;
        &lt;span class=&quot;hl kwa&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;newList&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;isBlank&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;()) {&lt;/span&gt;
            isValid &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;hl kwa&quot;&gt;false&lt;/span&gt;
        &lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt;
        &lt;span class=&quot;hl kwa&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;isValid&lt;span class=&quot;hl opt&quot;&gt;) {&lt;/span&gt;
            &lt;span class=&quot;hl kwa&quot;&gt;val&lt;/span&gt; nameList &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; listEditText&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;text&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;toString&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;()&lt;/span&gt;
            &lt;span class=&quot;hl slc&quot;&gt;// hacer algo con el valor obtenido&lt;/span&gt;
        &lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt;
        &lt;span class=&quot;hl kwa&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;hl opt&quot;&gt;(!&lt;/span&gt;isValid&lt;span class=&quot;hl opt&quot;&gt;) {&lt;/span&gt;
            dialog&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;dismiss&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;()&lt;/span&gt;
        &lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt;
    &lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt;

    builder&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;setNegativeButton&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;android&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;R&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;string&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;cancel&lt;span class=&quot;hl opt&quot;&gt;) {&lt;/span&gt; dialog&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; p1 &lt;span class=&quot;hl opt&quot;&gt;-&amp;gt;&lt;/span&gt;
        dialog&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;cancel&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;()&lt;/span&gt;
    &lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt;

    builder&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;show&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;()&lt;/span&gt;
&lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt;
&lt;/pre&gt;
&lt;br /&gt;
El segundo método utiliza la clase &lt;i&gt;DialogFragment&lt;/i&gt; como contenedor:&lt;br /&gt;&lt;pre class=&quot;hl&quot;&gt;&lt;span class=&quot;hl slc&quot;&gt;// EditTextDialog.kt&lt;/span&gt;
&lt;span class=&quot;hl kwa&quot;&gt;class&lt;/span&gt; EditTextDialog &lt;span class=&quot;hl opt&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;DialogFragment&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;() {&lt;/span&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp; companion &lt;span class=&quot;hl kwa&quot;&gt;object&lt;/span&gt; &lt;span class=&quot;hl opt&quot;&gt;{&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;private&lt;/span&gt; const &lt;span class=&quot;hl kwa&quot;&gt;val&lt;/span&gt; EXTRA_TITLE &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;hl str&quot;&gt;&quot;title&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;private&lt;/span&gt; const &lt;span class=&quot;hl kwa&quot;&gt;val&lt;/span&gt; EXTRA_HINT &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;hl str&quot;&gt;&quot;hint&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;private&lt;/span&gt; const &lt;span class=&quot;hl kwa&quot;&gt;val&lt;/span&gt; EXTRA_LAYOUT &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;hl str&quot;&gt;&quot;layout&quot;&lt;/span&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;fun&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;newInstance&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;title&lt;span class=&quot;hl opt&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;hl kwb&quot;&gt;String&lt;/span&gt;? &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;hl kwa&quot;&gt;null&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; hint&lt;span class=&quot;hl opt&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;hl kwb&quot;&gt;String&lt;/span&gt;? &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;hl kwa&quot;&gt;null&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; layout&lt;span class=&quot;hl opt&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;hl kwb&quot;&gt;Int&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;):&lt;/span&gt; EditTextDialog &lt;span class=&quot;hl opt&quot;&gt;{&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;val&lt;/span&gt; dialog &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;EditTextDialog&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;()&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;val&lt;/span&gt; args &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;Bundle&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;().&lt;/span&gt;apply &lt;span class=&quot;hl opt&quot;&gt;{&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwd&quot;&gt;putString&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;EXTRA_TITLE&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; title&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwd&quot;&gt;putString&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;EXTRA_HINT&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; hint&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwd&quot;&gt;putInt&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;EXTRA_LAYOUT&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; layout&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; dialog&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;arguments &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; args
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;return&lt;/span&gt; dialog
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp; lateinit &lt;span class=&quot;hl kwa&quot;&gt;var&lt;/span&gt; editText&lt;span class=&quot;hl opt&quot;&gt;:&lt;/span&gt; EditText
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;var&lt;/span&gt; onOk&lt;span class=&quot;hl opt&quot;&gt;: (() -&amp;gt;&lt;/span&gt; &lt;span class=&quot;hl kwb&quot;&gt;Unit&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;? &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;hl kwa&quot;&gt;null&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;var&lt;/span&gt; onCancel&lt;span class=&quot;hl opt&quot;&gt;: (() -&amp;gt;&lt;/span&gt; &lt;span class=&quot;hl kwb&quot;&gt;Unit&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;? &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;hl kwa&quot;&gt;null&lt;/span&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;override fun&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;onCreateDialog&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;savedInstanceState&lt;span class=&quot;hl opt&quot;&gt;:&lt;/span&gt; Bundle?&lt;span class=&quot;hl opt&quot;&gt;):&lt;/span&gt; Dialog &lt;span class=&quot;hl opt&quot;&gt;{&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;val&lt;/span&gt; title &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; arguments?&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;getString&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;EXTRA_TITLE&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;val&lt;/span&gt; hint &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; arguments?&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;getString&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;EXTRA_HINT&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;val&lt;/span&gt; layout &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; arguments?&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;getInt&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;EXTRA_LAYOUT&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;val&lt;/span&gt; view &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;hl kwa&quot;&gt;when&lt;/span&gt; &lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;layout&lt;span class=&quot;hl opt&quot;&gt;) {&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;is&lt;/span&gt; &lt;span class=&quot;hl kwb&quot;&gt;Int&lt;/span&gt; &lt;span class=&quot;hl opt&quot;&gt;-&amp;gt; {&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; activity&lt;span class=&quot;hl opt&quot;&gt;!!.&lt;/span&gt;layoutInflater&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;inflate&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;layout&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;hl kwa&quot;&gt;null&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;else&lt;/span&gt; &lt;span class=&quot;hl opt&quot;&gt;-&amp;gt;&lt;/span&gt; &lt;span class=&quot;hl kwa&quot;&gt;null&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;view &lt;span class=&quot;hl opt&quot;&gt;!=&lt;/span&gt; &lt;span class=&quot;hl kwa&quot;&gt;null&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;) {&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;when&lt;/span&gt; &lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;layout&lt;span class=&quot;hl opt&quot;&gt;) {&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; R&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;layout&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;dialog_new_list &lt;span class=&quot;hl opt&quot;&gt;-&amp;gt;&lt;/span&gt; editText &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; view&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;editText_newList
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; R&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;layout&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;dialog_new_item &lt;span class=&quot;hl opt&quot;&gt;-&amp;gt;&lt;/span&gt; editText &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; view&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;editText_newItem
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; editText&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;hint &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; hint

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;val&lt;/span&gt; builder &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; AlertDialog&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;Builder&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;context&lt;span class=&quot;hl opt&quot;&gt;!!)&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;setTitle&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;title&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;setView&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;view&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;setPositiveButton&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;android&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;R&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;string&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;ok&lt;span class=&quot;hl opt&quot;&gt;) {&lt;/span&gt; _&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; _ &lt;span class=&quot;hl opt&quot;&gt;-&amp;gt;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;hl opt&quot;&gt;(!&lt;/span&gt;editText&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;text&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;isBlank&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;()) {&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; onOk?&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;invoke&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;()&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;hl kwa&quot;&gt;else&lt;/span&gt; &lt;span class=&quot;hl opt&quot;&gt;{&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; onCancel?&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;invoke&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;()&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;setNegativeButton&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;android&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;R&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;string&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;cancel&lt;span class=&quot;hl opt&quot;&gt;) {&lt;/span&gt; _&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; _ &lt;span class=&quot;hl opt&quot;&gt;-&amp;gt;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; onCancel?&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;invoke&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;()&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;return&lt;/span&gt; builder&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;create&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;()&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt;&lt;/pre&gt;
Y para utilizarlo desde una actividad creamos una nueva instancia de esta manera:&lt;br /&gt;&lt;pre class=&quot;hl&quot;&gt;&lt;span class=&quot;hl kwa&quot;&gt;val&lt;/span&gt; dialogo &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; EditTextDialog&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;newInstance&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; title &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;hl str&quot;&gt;&quot;Add new List&quot;&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; hint &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;hl str&quot;&gt;&quot;Name List&quot;&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; layout &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; R&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;layout&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;dialog_new_list
&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;
dialogo&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;onOk &lt;span class=&quot;hl opt&quot;&gt;= {&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;val&lt;/span&gt; name &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; dialogo&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;editText&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;text&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;toString&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;()&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl slc&quot;&gt;// hacer algo con el valor obtenido&lt;/span&gt;
&lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt;
dialogo&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;onCancel &lt;span class=&quot;hl opt&quot;&gt;= {&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; Toast&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;makeText&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl kwa&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;hl str&quot;&gt;&quot;Operación cancelada&quot;&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; Toast&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;LENGTH_SHORT&lt;span class=&quot;hl opt&quot;&gt;).&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;show&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;()&lt;/span&gt;
&lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt;
dialogo&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;show&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;supportFragmentManager&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;hl str&quot;&gt;&quot;editDescription&quot;&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;&lt;/pre&gt;</content><link rel='replies' type='application/atom+xml' href='https://kotlindoc.blogspot.com/feeds/4053980021919842571/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='https://kotlindoc.blogspot.com/2019/09/android-dialogo-para-introducir-datos.html#comment-form' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='https://www.blogger.com/feeds/6895501055750567199/posts/default/4053980021919842571'/><link rel='self' type='application/atom+xml' href='https://www.blogger.com/feeds/6895501055750567199/posts/default/4053980021919842571'/><link rel='alternate' type='text/html' href='https://kotlindoc.blogspot.com/2019/09/android-dialogo-para-introducir-datos.html' title='Android: Diálogo para introducir datos'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiWJGxC9RNQ15GhvDGjkZD8pG_zsRXRI17bXaPwRinXnrhhFLnZU-kqloqdohgqnn8Sl8kHuhzKER3zSfWNKGR_dOq_Nh84z2RYXHa5VYxdzzXCq1daKXf3rL_uO8Fbm9p6PlwqVvCNgJM/s72-c/dialogo.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6895501055750567199.post-1683688579928587180</id><published>2019-09-04T21:26:00.001+02:00</published><updated>2019-09-07T17:31:50.324+02:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="android básico"/><title type='text'>Crear Views dinámicamente</title><content type='html'>&lt;img alt=&quot;Crear Views dinámicamente&quot; border=&quot;0&quot; data-original-height=&quot;452&quot; data-original-width=&quot;732&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhZB3ruhzIUq112YFFpNNs9HqpHGszx9ugypqH8Xp6BXFl3vxYxZ2pBLytsIrEyb9iDJDsY0i7v-sGVz3sqcpld71OtJhr0l8R_wO8mPSjBIdGV91yh3-s5lFgu-yE8_BbbpEaxK9u4NS0/s1600/viewdinamica-compressor.png&quot; title=&quot;Crear Views dinámicamente&quot; /&gt;
&lt;br /&gt;
&lt;br /&gt;
Hasta ahora hemos visto la manera de crear elementos de diseño de manera estática a la vez que diseñamos el aspecto visual, organizados como recursos en los archivos de diseño XML, pero en muchas aplicaciones nos interesa crear elementos visuales programáticamente, esto es, desde el código fuente en función de la dinámica de la propia aplicación.&lt;br /&gt;&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;
&lt;br /&gt;
En general los pasos a seguir son:&lt;br /&gt;
&lt;ol&gt;
&lt;li&gt;Crear el contenedor, por ejemplo un &lt;i&gt;LinearLayout&lt;/i&gt;, en el archivo xml de diseño.&lt;/li&gt;
&lt;li&gt;Crear el elemento visual (&lt;i&gt;view&lt;/i&gt;) que nos interesa desde el archivo de la actividad.&lt;/li&gt;
&lt;li&gt;Agregarle propiedades, por ejemplo, un texto, un tamaño de texto, color, márgenes...&lt;/li&gt;
&lt;li&gt;Agregar un método, usualmente un evento al hacer clic sobre el elemento.&lt;/li&gt;
&lt;li&gt;Añadirlo al contenedor.&lt;/li&gt;
&lt;/ol&gt;
&lt;br /&gt;
De momento dejo un par de ejemplos para crear dos tipos de &lt;i&gt;views&lt;/i&gt; (&lt;i&gt;TextView&lt;/i&gt; y &lt;i&gt;CheckBox&lt;/i&gt;), pero próximamente actualizaré esta entrada con más ejemplos:
&lt;br /&gt;
&lt;pre class=&quot;hl&quot;&gt;&lt;span class=&quot;hl slc&quot;&gt;// creando TextView&lt;/span&gt;
&lt;span class=&quot;hl kwa&quot;&gt;val&lt;/span&gt; textLista &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;TextView&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl kwa&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;
textLista&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;textSize &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;hl num&quot;&gt;20&lt;/span&gt;f
textLista&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;text &lt;span class=&quot;hl opt&quot;&gt;= ...&lt;/span&gt;
textLista&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;setOnClickListener &lt;span class=&quot;hl opt&quot;&gt;{ ... }&lt;/span&gt;
&lt;span class=&quot;hl slc&quot;&gt;// añade el TextView al LinearLayout&lt;/span&gt;
layoutListas&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;addView&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;textLista&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;


&lt;span class=&quot;hl slc&quot;&gt;// creando CheckBox&lt;/span&gt;
&lt;span class=&quot;hl kwa&quot;&gt;val&lt;/span&gt; textItem &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;CheckBox&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl kwa&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;
textItem&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;text &lt;span class=&quot;hl opt&quot;&gt;= ...&lt;/span&gt;
textItem&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;textSize &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;hl num&quot;&gt;24&lt;/span&gt;F
textItem&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;isChecked &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;hl kwa&quot;&gt;false&lt;/span&gt;
layoutItems&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;addView&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;textItem&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;
&lt;/pre&gt;</content><link rel='replies' type='application/atom+xml' href='https://kotlindoc.blogspot.com/feeds/1683688579928587180/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='https://kotlindoc.blogspot.com/2019/09/crear-views-dinamicamente.html#comment-form' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='https://www.blogger.com/feeds/6895501055750567199/posts/default/1683688579928587180'/><link rel='self' type='application/atom+xml' href='https://www.blogger.com/feeds/6895501055750567199/posts/default/1683688579928587180'/><link rel='alternate' type='text/html' href='https://kotlindoc.blogspot.com/2019/09/crear-views-dinamicamente.html' title='Crear Views dinámicamente'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhZB3ruhzIUq112YFFpNNs9HqpHGszx9ugypqH8Xp6BXFl3vxYxZ2pBLytsIrEyb9iDJDsY0i7v-sGVz3sqcpld71OtJhr0l8R_wO8mPSjBIdGV91yh3-s5lFgu-yE8_BbbpEaxK9u4NS0/s72-c/viewdinamica-compressor.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6895501055750567199.post-4826302756043177716</id><published>2019-08-25T10:26:00.001+02:00</published><updated>2019-08-25T10:43:13.402+02:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="android básico"/><category scheme="http://www.blogger.com/atom/ns#" term="android studio"/><title type='text'>Navegando por la aplicación (2ª parte)</title><content type='html'>&lt;img alt=&quot;Navegando por la aplicación (2ª parte)&quot; border=&quot;0&quot; data-original-height=&quot;591&quot; data-original-width=&quot;882&quot; height=&quot;428&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjssoBObM_Rp8YcxaYNNAcDkkf4NV7S4DoHinFoifOE8kbbgWfrPub86coKOWbki5lwfxtm8V3Av5ws6KbDUSvZ39AICuPCQAnDXuFg5qdnumQ1j-elDozokpCeEz0WloS79ITzil8Ai3s/s640/rutas.png&quot; title=&quot;Navegando por la aplicación (2ª parte)&quot; width=&quot;640&quot; /&gt;&lt;br /&gt;
&lt;br /&gt;
En esta entrada, que es una continuación de &lt;a href=&quot;https://kotlindoc.blogspot.com/2019/08/navegando-entre-fragmentos.html&quot;&gt;Navegando entre fragmentos&lt;/a&gt;, vamos a ver cómo facilitar al usuario otras maneras de navegar por una aplicación, y concretamente, partiendo de la aplicación &lt;i&gt;Test CI&lt;/i&gt; que vimos en esa entrada, vamos a añadir nuevas posibilidades para moverse entre fragmentos. Para ello vamos a presentar el contenido secuenciado en tres pasos a modo de objetivos:&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;br /&gt;
&lt;ol&gt;
&lt;li&gt;Añadir un botón a la barra de la aplicación.&lt;/li&gt;
&lt;li&gt;Crear un menú de opciones.&lt;/li&gt;
&lt;li&gt;Crear un cajón de navegación.&lt;/li&gt;
&lt;/ol&gt;
&lt;br /&gt;
&lt;h2&gt;
1. Añadir un botón Up a la barra de la aplicación&lt;/h2&gt;
Usualmente en la &lt;b&gt;barra de la aplicación&lt;/b&gt; encontramos en el centro un título descriptivo acerca de la aplicación o la pantalla concreta, a su derecha un botón con el icono de tres puntos verticales para acceder al menú de opciones y, dependiendo de la pantalla, el botón &lt;i&gt;Arriba&lt;/i&gt; (&lt;i&gt;the Up button&lt;/i&gt;) a la izquierda en forma de flecha apuntando hacia la izquierda.&lt;br /&gt;
&lt;br /&gt;
En cuanto al título, para establecer desde un fragmento el título que aparece en la barra de la aplicación podemos invocar &lt;i&gt;supportActionBar.title&lt;/i&gt;; por ejemplo en el caso del fragmento de inicio, &lt;i&gt;TitleFragment.kt&lt;/i&gt;, dentro de &lt;i&gt;onCreate&lt;/i&gt;, sería:&lt;br /&gt;
&lt;pre class=&quot;hl&quot;&gt;&lt;span class=&quot;hl slc&quot;&gt;// requiere import androidx.appcompat.app.AppCompatActivity&lt;/span&gt;
&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;activity &lt;span class=&quot;hl kwa&quot;&gt;as&lt;/span&gt; AppCompatActivity&lt;span class=&quot;hl opt&quot;&gt;).&lt;/span&gt;supportActionBar?&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;title &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;getString&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;R&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;string&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;app_name&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;&lt;/pre&gt;
Repetimos lo anterior para todos los fragmentos (excepto en &lt;i&gt;TestFragment.kt&lt;/i&gt; puesto que ya lo tiene) asignando a cada uno su respectivo recurso de texto almacenado en &lt;i&gt;values/strings.xml&lt;/i&gt;.&lt;br /&gt;
&lt;br /&gt;
En &lt;a href=&quot;https://kotlindoc.blogspot.com/2019/08/navegando-entre-fragmentos.html&quot;&gt;Navegando entre fragmentos&lt;/a&gt; ya configuramos el botón &lt;i&gt;Atrás&lt;/i&gt; del dispositivo para navegar a la pantalla que nos interesaba en cada caso, pero además podemos añadir un botón &lt;i&gt;Up&lt;/i&gt; en la barra de la aplicación con un comportamiento similar. Una diferencia importante entre los botones &lt;i&gt;Arriba&lt;/i&gt; y &lt;i&gt;Atrás&lt;/i&gt; es que el primero es dependiente de la aplicación y navega dentro de ella sin salir de la aplicación, mientras que el segundo es dependiente del dispositivo y navega hacia atrás en la pila posterior de destinos o &lt;i&gt;back stack&lt;/i&gt; del sistema. Y en nuestra aplicación nos interesa incluir un botón &lt;i&gt;Up&lt;/i&gt; que aparezca en todas las pantalla excepto en la pantalla de inicio (la pantalla de título: &lt;i&gt;fragment_title.xml&lt;/i&gt;) puesto que esta pantalla está en la parte superior de la jerarquía de la aplicación.&lt;br /&gt;
&lt;br /&gt;
Recuerda que en su momento ya incluimos las dependencias de navegación a los archivos de &lt;i&gt;Gradle&lt;/i&gt; (revisar la entrada &lt;a href=&quot;https://kotlindoc.blogspot.com/2019/08/navegando-entre-fragmentos.html&quot;&gt;Navegando entre fragmentos&lt;/a&gt;), y los componentes de navegación incluyen una biblioteca llamada &lt;i&gt;NavigationUI&lt;/i&gt; que permite que el controlador de navegación se integre con la barra de aplicaciones para implementar el comportamiento del botón &lt;i&gt;Up&lt;/i&gt;. Vamos a utilizarlo.&lt;br /&gt;
&lt;br /&gt;
En el archivo &lt;i&gt;MainActivity.kt&lt;/i&gt;, dentro del método &lt;i&gt;onCreate&lt;/i&gt; agregamos el código para localizar el objeto del controlador de navegación (recuerda que en &lt;i&gt;activity_main.xml&lt;/i&gt; se identificó el fragmento como &lt;i&gt;myNavHostFragment&lt;/i&gt; para crear el &lt;i&gt;NavHostFragment&lt;/i&gt;):&lt;br /&gt;
&lt;pre class=&quot;hl&quot;&gt;&lt;span class=&quot;hl slc&quot;&gt;// requiere import androidx.navigation.findNavController&lt;/span&gt;
&lt;span class=&quot;hl kwa&quot;&gt;val&lt;/span&gt; navController &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;hl kwa&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;findNavController&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;R&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;id&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;myNavHostFragment&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;&lt;/pre&gt;
Inmediatamente después, vinculamos el controlador de navegación a la barra de la aplicación:&lt;br /&gt;
&lt;pre class=&quot;hl&quot;&gt;&lt;span class=&quot;hl slc&quot;&gt;// requiere import androidx.navigation.ui.NavigationUI&lt;/span&gt;
NavigationUI&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;setupActionBarWithNavController&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl kwa&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; navController&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;&lt;/pre&gt;
Y ahora, fuera del método &lt;i&gt;onCreate&lt;/i&gt;, sobrescribimos el método &lt;i&gt;onSupportNavigateUp&lt;/i&gt; para invocar &lt;i&gt;navigationUp&lt;/i&gt; en el controlador de navegación:&lt;br /&gt;
&lt;pre class=&quot;hl&quot;&gt;&lt;span class=&quot;hl kwa&quot;&gt;override fun&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;onSupportNavigateUp&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;():&lt;/span&gt; &lt;span class=&quot;hl kwb&quot;&gt;Boolean&lt;/span&gt; &lt;span class=&quot;hl opt&quot;&gt;{&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;val&lt;/span&gt; navController &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;hl kwa&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;findNavController&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;R&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;id&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;myNavHostFragment&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;return&lt;/span&gt; navController&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;navigateUp&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;()&lt;/span&gt;
&lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt;&lt;/pre&gt;
Ejecutamos la aplicación para comprobar que el botón &lt;i&gt;Up&lt;/i&gt; aparece en la barra de la aplicación de todas las pantallas excepto en la pantalla de inicio, y que al pulsarlo siempre nos lleva a la pantalla de inicio independientemente de la pantalla donde nos encontremos. Además cada pantalla aparece con su correspondiente título en la barra de la aplicación. Primer objetivo conseguido, a por el segundo.&lt;br /&gt;
&lt;br /&gt;
&lt;h2&gt;
2. Crear un menú de opciones&lt;/h2&gt;
En Android se accede al menú de opciones desde el botón de tres puntos verticales situado en la barra de la aplicación. Vamos a incorporarlo a nuestra aplicación y en el menú de opciones vamos a añadir un elemento (&lt;i&gt;Acerca de&lt;/i&gt;) para que, cuando el usuario lo pulse, la aplicación navegue al fragmento &lt;i&gt;AboutFragment&lt;/i&gt; y muestre la información que contiene este fragmento.&lt;br /&gt;
&lt;br /&gt;
Primero, con el botón &lt;i&gt;New Destination&lt;/i&gt; agregamos el fragmento &lt;i&gt;aboutFragment&lt;/i&gt; al gráfico de navegación:&lt;br /&gt;
&lt;br /&gt;
&lt;img border=&quot;0&quot; data-original-height=&quot;620&quot; data-original-width=&quot;928&quot; height=&quot;427&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgAJYqhziD0tWfaEJpIkltJFd7ZHZyE3LNptRaIBq7hc4eQFE3nhdaI_ucLGNSgLR0y40CydMZCPHcmVpdVucFUERoZEWMKG5rFLvoTWaFJrVM4hFYAjabe7yaXkW8OZDlDztMvm2r3nxs/s640/image1.png&quot; width=&quot;640&quot; /&gt;&lt;br /&gt;
&lt;br /&gt;
Después debemos agregar el recurso de menú de opciones: desde la carpeta &lt;i&gt;res&lt;/i&gt;, &lt;i&gt;New&lt;/i&gt; -&amp;gt; &lt;i&gt;Android Resource File&lt;/i&gt;, y en la nueva ventana que se abre ajustamos el nombre (&lt;i&gt;options_menu&lt;/i&gt;) y el tipo (&lt;i&gt;Menu&lt;/i&gt;):&lt;br /&gt;
&lt;br /&gt;
&lt;img border=&quot;0&quot; data-original-height=&quot;479&quot; data-original-width=&quot;826&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEihD1hvuTupCV5vPR4oUuCIGebWd46qlJ0ZDhrMTunL4Ce0qcE3rrrukxFlSxWvrt7-vSmrFyG85twLDkrjNFJn3uKqeYmHIexfecb912bIHguCwNjFbYqJUTqso4_Rnz7NGFwTkAE1-T0/s1600/image2.png&quot; /&gt;&lt;br /&gt;
&lt;br /&gt;
Abrimos &lt;i&gt;menu/options_menu.xml&lt;/i&gt; en vista &lt;i&gt;Design&lt;/i&gt; para ver el editor de diseño. Desde la paleta de elementos arrastramos &lt;i&gt;Menu Item&lt;/i&gt; al árbol de componentes bajo el elemento &lt;i&gt;menu&lt;/i&gt;:&lt;br /&gt;
&lt;br /&gt;
&lt;img border=&quot;0&quot; data-original-height=&quot;770&quot; data-original-width=&quot;858&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgvdaAKfOIl1jOvXNOjbR1-11aPnljEKijXI3t6eiuXtogDcVMcIUrE2ZOSoh3ccOYt0vG-eJkkWVoeOkuhaLB3ldkTIZkoR4-x0D8_r0M5Jykhkt3yDV1-6-7KDTHmaeHk7vNnN0AUA4k/s1600/image3.png&quot; /&gt;&lt;br /&gt;
&lt;br /&gt;
Seleccionamos el nuevo &lt;i&gt;Item&lt;/i&gt; y desde el panel de atributos ajustamos el ID en &lt;i&gt;aboutFragment&lt;/i&gt; (asegúrate de que este valor es el mismo que el valor de la ID del fragmento en el gráfico de navegación) y el título en &lt;i&gt;@string/about&lt;/i&gt;.&lt;br /&gt;
&lt;br /&gt;
Ahora falta incorporle un controlador &lt;i&gt;onClick&lt;/i&gt;. En el archivo &lt;i&gt;TitleFragment.kt&lt;/i&gt;, dentro del método &lt;i&gt;onCreateView&lt;/i&gt; y por supuesto antes de &lt;i&gt;return&lt;/i&gt;, invocamos el método &lt;i&gt;setHasOptionsMenu&lt;/i&gt; con el argumento &lt;i&gt;true&lt;/i&gt;:&lt;br /&gt;
&lt;pre class=&quot;hl&quot;&gt;&lt;span class=&quot;hl kwd&quot;&gt;setHasOptionsMenu&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl kwa&quot;&gt;true&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;&lt;/pre&gt;
Ahora, fuera y después del método &lt;i&gt;onCreateView&lt;/i&gt;, sobrescribimos el método &lt;i&gt;onCreateOptionsMenu&lt;/i&gt; y, en él, agregamos el menú de opciones y activamos (inflamos) el archivo de recursos del menú:&lt;br /&gt;
&lt;pre class=&quot;hl&quot;&gt;&lt;span class=&quot;hl slc&quot;&gt;// import android.view.*&lt;/span&gt;
&lt;span class=&quot;hl kwa&quot;&gt;override fun&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;onCreateOptionsMenu&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;menu&lt;span class=&quot;hl opt&quot;&gt;:&lt;/span&gt; Menu?&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; inflater&lt;span class=&quot;hl opt&quot;&gt;:&lt;/span&gt; MenuInflater?&lt;span class=&quot;hl opt&quot;&gt;) {&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;super&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;onCreateOptionsMenu&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;menu&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; inflater&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; inflater?&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;inflate&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;R&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;menu&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;options_menu&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; menu&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt;&lt;/pre&gt;
Sobrescribimos el método &lt;i&gt;onOptionsItemSelected&lt;/i&gt; para seleccionar la acción adecuada cuando se pulsa el elemento del menú, esto es, navegar hasta el fragmento que tiene la misma identificación (id) que el elemento del menú:&lt;br /&gt;
&lt;pre class=&quot;hl&quot;&gt;&lt;span class=&quot;hl slc&quot;&gt;// import androidx.navigation.ui.NavigationUI&lt;/span&gt;
&lt;span class=&quot;hl kwa&quot;&gt;override fun&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;onOptionsItemSelected&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;item&lt;span class=&quot;hl opt&quot;&gt;:&lt;/span&gt; MenuItem?&lt;span class=&quot;hl opt&quot;&gt;):&lt;/span&gt; &lt;span class=&quot;hl kwb&quot;&gt;Boolean&lt;/span&gt; &lt;span class=&quot;hl opt&quot;&gt;{&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;return&lt;/span&gt; NavigationUI&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;onNavDestinationSelected&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;item&lt;span class=&quot;hl opt&quot;&gt;!!,&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; view&lt;span class=&quot;hl opt&quot;&gt;!!.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;findNavController&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;())&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl opt&quot;&gt;||&lt;/span&gt; &lt;span class=&quot;hl kwa&quot;&gt;super&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;onOptionsItemSelected&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;item&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt;&lt;/pre&gt;
Ejecutamos en el emulador para comprobar que ahora en la barra de la aplicación de la pantalla de inicio aparece, a la derecha, el botón de tres puntos verticales, y al pulsarlo se muestra un menú con el ítem &lt;i&gt;Acerca de&lt;/i&gt;, que nos lleva a la pantalla del fragmento correspondiente. ¡Segundo objetivo conseguido!&lt;br /&gt;
&lt;br /&gt;
&lt;h2&gt;
3. Crear un cajón de navegación&lt;/h2&gt;
El cajón de navegación (&lt;i&gt;the navigation drawer&lt;/i&gt;) forma parte de Material (&lt;i&gt;Material library&lt;/i&gt; o &lt;i&gt;Material Components for Android library&lt;/i&gt;, biblioteca utilizada para implementar modelos siguiendo las reglas &lt;i&gt;Material Design&lt;/i&gt; de Google) y consiste en un panel que se desliza desde el borde de la pantalla y que generalmente contiene un encabezado y un menú. En dispositivos del tamaño de un &lt;i&gt;smartphone&lt;/i&gt; este cajón está oculto cuando no se usa, y suele mostrarse con dos acciones del usuario: con un movimiento de deslizamiento desde un borde de la pantalla hacia el otro (en nuestra aplicación haremos que aparezca cuando el usuario deslice de izquierda a derecha) y pulsando el botón de tres líneas horizontales (&lt;i&gt;nav drawer button&lt;/i&gt; o &lt;i&gt;hamburger icon&lt;/i&gt;) que está en la barra de la aplicación.&lt;br /&gt;
&lt;br /&gt;
En nuestra aplicación el cajón de navegación contendrá dos elementos de menú, uno como el recién creado item &lt;i&gt;Acerca de&lt;/i&gt; y un segundo elemento que apuntará al fragmento (&lt;i&gt;InfoFragment&lt;/i&gt;) con información sobre el funcionamiento de la aplicación.&lt;br /&gt;
&lt;br /&gt;
Primero debemos agregar la &lt;i&gt;Material library&lt;/i&gt; al proyecto. Para ello, en el archivo &lt;i&gt;build.gradle (Module:app)&lt;/i&gt; añadimos la dependencia correspondiente:&lt;br /&gt;
&lt;pre class=&quot;hl&quot;&gt;dependencies &lt;span class=&quot;hl opt&quot;&gt;{&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl opt&quot;&gt;...&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; implementation &lt;span class=&quot;hl str&quot;&gt;&quot;com.google.android.material:material:$supportlibVersion&quot;&lt;/span&gt;
&lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt;&lt;/pre&gt;
Y sincronizamos el proyecto.&lt;br /&gt;
&lt;br /&gt;
En el gráfico de navegación añadimos el fragmento &lt;i&gt;infoFragment&lt;/i&gt; (ID: infoFragment):&lt;br /&gt;
&lt;br /&gt;
&lt;img border=&quot;0&quot; data-original-height=&quot;642&quot; data-original-width=&quot;954&quot; height=&quot;430&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiUtJHbM_vHAxiLszvLWmX9FKkIQ2RqKFZ_vt8oDjijMuB-hJuD5V6iDvZuch3VOmh7Tj2xFh0ddItJv2rywXNmw5P4EH7aHQN5RyAeiFt2yFY6K6k5tnxLeI905qt9pcTZvC5ISIxqdRY/s640/image4.png&quot; width=&quot;640&quot; /&gt;&lt;br /&gt;
&lt;br /&gt;
Después, para crear el cajón de navegación, desde la carpeta &lt;i&gt;res&lt;/i&gt; -&amp;gt; &lt;i&gt;New&lt;/i&gt; -&amp;gt; &lt;i&gt;Android Resource File&lt;/i&gt; y ajustamos los valores &lt;i&gt;File name: navdrawer_menu&lt;/i&gt; y &lt;i&gt;Resource type: Menu&lt;/i&gt;.&lt;br /&gt;
&lt;br /&gt;
En &lt;i&gt;menu/navdrawer_menu.xml&lt;/i&gt; (vista &lt;i&gt;Design&lt;/i&gt;) agregamos dos elementos &lt;i&gt;Menu Item&lt;/i&gt; desde la paleta de elementos hasta el árbol de componentes, bajo el elemento &lt;i&gt;menu&lt;/i&gt;. Para el primer Item establecemos &lt;i&gt;id: infoFragment&lt;/i&gt; (la ID del fragmento en el gráfico de navegación), como título &lt;i&gt;@string/info&lt;/i&gt; y como icono una imagen desde res/drawable (&lt;i&gt;@drawable/ic_code&lt;/i&gt;). Para el segundo Item ajustamos la id a &lt;i&gt;aboutFragment&lt;/i&gt; (comprueba que coincide con la id en el gráfico de navegación), el título a &lt;i&gt;@string/about&lt;/i&gt; y el icono a &lt;i&gt;@drawable/ic_mid_mapping&lt;/i&gt;.&lt;br /&gt;
&lt;br /&gt;
Abrimos &lt;i&gt;layout/activity_main.xml&lt;/i&gt; en vista &lt;i&gt;Text&lt;/i&gt;, y colocamos todos los elementos dentro de un &lt;i&gt;DrawerLayout&lt;/i&gt; como elemento inmediatamente después del &lt;i&gt;layout&lt;/i&gt; raíz, envolviendo el &lt;i&gt;LinearLayout&lt;/i&gt;:&lt;br /&gt;
&lt;pre class=&quot;hl&quot;&gt;&lt;span class=&quot;hl com&quot;&gt;&amp;lt;!-- activity_main.xml --&amp;gt;&lt;/span&gt;
&lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;?xml&lt;/span&gt; &lt;span class=&quot;hl kwb&quot;&gt;version&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;1.0&quot;&lt;/span&gt; &lt;span class=&quot;hl kwb&quot;&gt;encoding&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;utf-8&quot;&lt;/span&gt;&lt;span class=&quot;hl kwa&quot;&gt;?&amp;gt;&lt;/span&gt;

&lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;layout&lt;/span&gt; xmlns:&lt;span class=&quot;hl kwb&quot;&gt;android&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;http://schemas.android.com/apk/res/android&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; xmlns:&lt;span class=&quot;hl kwb&quot;&gt;app&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;http://schemas.android.com/apk/res-auto&quot;&lt;/span&gt;&lt;span class=&quot;hl kwa&quot;&gt;&amp;gt;&lt;/span&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;androidx&lt;/span&gt;.drawerlayout.widget.DrawerLayout
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;id&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@+id/drawerLayout&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_width&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;match_parent&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_height&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;match_parent&quot;&lt;/span&gt;&lt;span class=&quot;hl kwa&quot;&gt;&amp;gt;&lt;/span&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;LinearLayout&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_width&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;match_parent&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_height&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;match_parent&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;orientation&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;vertical&quot;&lt;/span&gt;&lt;span class=&quot;hl kwa&quot;&gt;&amp;gt;&lt;/span&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;fragment&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;id&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@+id/myNavHostFragment&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;name&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;androidx.navigation.fragment.NavHostFragment&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_width&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;match_parent&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_height&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;match_parent&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; app:&lt;span class=&quot;hl kwb&quot;&gt;defaultNavHost&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;true&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; app:&lt;span class=&quot;hl kwb&quot;&gt;navGraph&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@navigation/navigation&quot;&lt;/span&gt; &lt;span class=&quot;hl kwa&quot;&gt;/&amp;gt;&lt;/span&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;/LinearLayout&amp;gt;&lt;/span&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;/androidx&lt;/span&gt;.drawerlayout.widget.DrawerLayout&lt;span class=&quot;hl kwa&quot;&gt;&amp;gt;&lt;/span&gt;

&lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;/layout&amp;gt;&lt;/span&gt;&lt;/pre&gt;
Ahora añadimos el cajón, que es un &lt;i&gt;NavigationView&lt;/i&gt; que usa el &lt;i&gt;navdrawer_menu&lt;/i&gt; que definimos antes, después del cierre de la etiqueta &lt;i&gt;LinearLayout&lt;/i&gt;:&lt;br /&gt;
&lt;pre class=&quot;hl&quot;&gt;&lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;com&lt;/span&gt;.google.android.material.navigation.NavigationView
&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;id&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@+id/navView&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_width&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;wrap_content&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_height&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;match_parent&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_gravity&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;start&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; app:&lt;span class=&quot;hl kwb&quot;&gt;headerLayout&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@layout/nav_header&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; app:&lt;span class=&quot;hl kwb&quot;&gt;menu&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@menu/navdrawer_menu&quot;&lt;/span&gt; &lt;span class=&quot;hl kwa&quot;&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;
Vemos que &lt;i&gt;Android Studio&lt;/i&gt; nos advierte de un error, ya que el recurso de diseño &lt;i&gt;layout/nav_header&lt;/i&gt; no existe. Se trata del diseño del encabezado del cajón, que queremos que sea una imagen de la aplicación. Pulsamos sobre el error y con Alt + Enter (o desde el icono de la bombilla) lo creamos con &lt;i&gt;androidx.constraintlayout.widget.ConstraintLayout&lt;/i&gt; como elemento raíz (y la advertencia del error desaparecerá):&lt;br /&gt;
&lt;br /&gt;
&lt;img border=&quot;0&quot; data-original-height=&quot;479&quot; data-original-width=&quot;797&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg1vPnyaxpx11gS8QI5OMFrBgu-9W_28Ro-7MIROrBwg4zaOIJDz6M5eLqXx0CniSPgbRUllVPgWzPIuxU4-9QFcv_wV6h4c1DeX4r6a6PJjAN66xemPiNg5OGRR2L0BY5bMeaJYy2iTQk/s1600/image5.png&quot; /&gt;&lt;br /&gt;
&lt;br /&gt;
Y le añadimos una &lt;i&gt;ImageView&lt;/i&gt; quedando de esta manera:&lt;br /&gt;
&lt;pre class=&quot;hl&quot;&gt;&lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;?xml&lt;/span&gt; &lt;span class=&quot;hl kwb&quot;&gt;version&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;1.0&quot;&lt;/span&gt; &lt;span class=&quot;hl kwb&quot;&gt;encoding&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;utf-8&quot;&lt;/span&gt;&lt;span class=&quot;hl kwa&quot;&gt;?&amp;gt;&lt;/span&gt;

&lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;androidx&lt;/span&gt;.constraintlayout.widget.ConstraintLayout xmlns:&lt;span class=&quot;hl kwb&quot;&gt;android&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;http://schemas.android.com/apk/res/android&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; xmlns:&lt;span class=&quot;hl kwb&quot;&gt;app&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;http://schemas.android.com/apk/res-auto&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;id&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@+id/navHeader&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_width&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;match_parent&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_height&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@dimen/image_header_height&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;background&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@color/fondoazul&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;padding&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@dimen/button_padding&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;theme&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@style/ThemeOverlay.AppCompat.Dark&quot;&lt;/span&gt;&lt;span class=&quot;hl kwa&quot;&gt;&amp;gt;&lt;/span&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;ImageView&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;id&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@+id/navHeaderImage&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_width&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;0dp&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_height&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;0dp&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_marginStart&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@dimen/horizontal_margin&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_marginTop&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@dimen/top_margin&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_marginEnd&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@dimen/horizontal_margin&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_marginBottom&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@dimen/bottom_margin&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;scaleType&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;fitCenter&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; app:&lt;span class=&quot;hl kwb&quot;&gt;layout_constraintBottom_toBottomOf&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;parent&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; app:&lt;span class=&quot;hl kwb&quot;&gt;layout_constraintEnd_toEndOf&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;parent&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; app:&lt;span class=&quot;hl kwb&quot;&gt;layout_constraintStart_toStartOf&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;parent&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; app:&lt;span class=&quot;hl kwb&quot;&gt;layout_constraintTop_toTopOf&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;parent&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; app:&lt;span class=&quot;hl kwb&quot;&gt;srcCompat&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@drawable/ic_problem_solving&quot;&lt;/span&gt; &lt;span class=&quot;hl kwa&quot;&gt;/&amp;gt;&lt;/span&gt;

&lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;/androidx&lt;/span&gt;.constraintlayout.widget.ConstraintLayout&lt;span class=&quot;hl kwa&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
Hasta ahora hemos creado los elementos del menú para el cajón de navegación y el diseño del propio cajón, pero necesitamos conectar el cajón al controlador de navegación para que cada elemento navegue a su correspondiente fragmento. Abrimos &lt;i&gt;MainActivity.kt&lt;/i&gt; y en &lt;i&gt;onCreate&lt;/i&gt; permitimos al usuario mostrar el cajón de navegación llamando al método &lt;i&gt;setupWithNavController&lt;/i&gt;:&lt;br /&gt;
&lt;pre class=&quot;hl&quot;&gt;NavigationUI&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;setupWithNavController&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;binding&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;navView&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; navController&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;&lt;/pre&gt;
Si en principio no reconoce la referencia a &lt;i&gt;navView&lt;/i&gt; que acabamos de crear en &lt;i&gt;activity_main.xml&lt;/i&gt;, podemos solucionarlo desde &lt;i&gt;Build&lt;/i&gt; -&amp;gt; &lt;i&gt;Clean Project&lt;/i&gt; y después &lt;i&gt;Build&lt;/i&gt; -&amp;gt; &lt;i&gt;Rebuild Project&lt;/i&gt;. Ejecutamos la aplicación y hacemos un movimiento de deslizamiento desde el borde izquierdo para mostrar el cajón de navegación, y comprobamos que cada item navega a su destino correcto:&lt;br /&gt;
&lt;br /&gt;
&lt;img border=&quot;0&quot; data-original-height=&quot;1600&quot; data-original-width=&quot;900&quot; height=&quot;640&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhkSX9PLwwJcsj9oR3zddjjlKs66MF0GveQgelCuu_O-EoGQKGhvWuDlDCxeFVp4yK8oLaOaGkRw7BPurWNPqG6_M7jjGtK4o6JZ4qaSXU4eZ5V1ez-cVyHv4IFChlWSRd4B6COlGM5WuM/s640/image6.png&quot; width=&quot;360&quot; /&gt;&lt;br /&gt;
&lt;br /&gt;
Funciona, pero deberiamos también mostrar el cajón de navegación desde el botón de tres líneas de la barra de la aplicación. Para hacerlo, en &lt;i&gt;MainActivity.kt&lt;/i&gt;, justo antes del método &lt;i&gt;onCreate&lt;/i&gt;, declaramos una variable con el modificador &lt;i&gt;lateinit&lt;/i&gt; (para permitir retrasar su inicialización) para representar el diseño del cajón (requiere &lt;i&gt;import androidx.drawerlayout.widget.DrawerLayout&lt;/i&gt;):&lt;br /&gt;
&lt;pre class=&quot;hl&quot;&gt;&lt;span class=&quot;hl kwa&quot;&gt;private&lt;/span&gt; lateinit &lt;span class=&quot;hl kwa&quot;&gt;var&lt;/span&gt; drawerLayout&lt;span class=&quot;hl opt&quot;&gt;:&lt;/span&gt; DrawerLayout&lt;/pre&gt;
Y dentro del método &lt;i&gt;onCreate&lt;/i&gt; la inicializamos después de que se haya inicializado la variable de enlace:&lt;br /&gt;
&lt;pre class=&quot;hl&quot;&gt;&lt;span class=&quot;hl kwa&quot;&gt;val&lt;/span&gt; binding &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; DataBindingUtil&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;setContentView&lt;span class=&quot;hl opt&quot;&gt;&amp;lt;&lt;/span&gt;ActivityMainBinding&lt;span class=&quot;hl opt&quot;&gt;&amp;gt;(&lt;/span&gt;&lt;span class=&quot;hl kwa&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; R&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;layout&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;activity_main&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;

drawerLayout &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; binding&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;drawerLayout&lt;/pre&gt;
Y la agregamos como tercer parámetro al método &lt;i&gt;setupActionBarWithNavController&lt;/i&gt;:&lt;br /&gt;
&lt;pre class=&quot;hl&quot;&gt;&lt;span class=&quot;hl slc&quot;&gt;// NavigationUI.setupActionBarWithNavController(this, navController)&lt;/span&gt;
NavigationUI&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;setupActionBarWithNavController&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl kwa&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; navController&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; drawerLayout&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;&lt;/pre&gt;
Ahora editamos el método &lt;i&gt;onSupportNavigateUp&lt;/i&gt; para devolver, en lugar de &lt;i&gt;navController&lt;/i&gt;, &lt;i&gt;NavigationUI&lt;/i&gt; con el método &lt;i&gt;navigateUp&lt;/i&gt; pasándole el controlador de navegación y el diseño del cajón:&lt;br /&gt;
&lt;pre class=&quot;hl&quot;&gt;&lt;span class=&quot;hl kwa&quot;&gt;override fun&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;onSupportNavigateUp&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;():&lt;/span&gt; &lt;span class=&quot;hl kwb&quot;&gt;Boolean&lt;/span&gt; &lt;span class=&quot;hl opt&quot;&gt;{&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;val&lt;/span&gt; navController &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;hl kwa&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;findNavController&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;R&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;id&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;myNavHostFragment&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl slc&quot;&gt;// return navController.navigateUp()&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;return&lt;/span&gt; NavigationUI&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;navigateUp&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;navController&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; drawerLayout&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt;&lt;/pre&gt;
Ejecutamos la aplicación en el emulador y comprobamos que en la pantalla de inicio, en la barra de la aplicación, a la izquierda tenemos el botón de tres líneas que abre el cajón de navegación (que también podemos abrir desde cualquier pantalla deslizando de izquierda a derecha).&lt;br /&gt;
&lt;br /&gt;
Finalmente hemos creado distintas opciones de navegación en la aplicación. En resumen, el usuario puede avanzar a través de la aplicación según el acierto o no de sus respuestas, puede volver en cualquier momento a la pantalla de inicio usando el botón &lt;i&gt;Arriba&lt;/i&gt;, y puede acceder a la pantalla &lt;i&gt;Acerca de&lt;/i&gt; desde el menú de opciones o bien desde el cajón de navegación que se puede abrir con un gesto de deslizamiento o con el botón de la barra de la aplicación en la pantalla de inicio; además, al pulsar en el botón &lt;i&gt;Atrás&lt;/i&gt; del dispositivo regresa a pantallas anteriores de una manera que tiene sentido para la aplicación (no necesariamente a la última pantalla visitada). ¡Objetivo conseguido: La aplicación incluye rutas de navegación robustas y lógicas que son intuitivas para el usuario!&lt;br /&gt;
&lt;br /&gt;
&lt;img border=&quot;0&quot; data-original-height=&quot;579&quot; data-original-width=&quot;347&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiPQnFUupr-ws0QRHdlwZJIs1Vd-oQl34qqMunm08OTwxAwbY4OeC2SO0ro4YR5CQR1Er7LgcMRZhTkxL1wcvqf5oeeYS1Onufb5TWYwKKWKKGauPcRtML2qP4rRW16rt6bmLk-Muyc6AY/s1600/app2.gif&quot; /&gt;</content><link rel='replies' type='application/atom+xml' href='https://kotlindoc.blogspot.com/feeds/4826302756043177716/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='https://kotlindoc.blogspot.com/2019/08/navegando-por-la-aplicacion-2-parte.html#comment-form' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='https://www.blogger.com/feeds/6895501055750567199/posts/default/4826302756043177716'/><link rel='self' type='application/atom+xml' href='https://www.blogger.com/feeds/6895501055750567199/posts/default/4826302756043177716'/><link rel='alternate' type='text/html' href='https://kotlindoc.blogspot.com/2019/08/navegando-por-la-aplicacion-2-parte.html' title='Navegando por la aplicación (2ª parte)'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjssoBObM_Rp8YcxaYNNAcDkkf4NV7S4DoHinFoifOE8kbbgWfrPub86coKOWbki5lwfxtm8V3Av5ws6KbDUSvZ39AICuPCQAnDXuFg5qdnumQ1j-elDozokpCeEz0WloS79ITzil8Ai3s/s72-c/rutas.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6895501055750567199.post-5025376899706004800</id><published>2019-08-22T18:06:00.004+02:00</published><updated>2019-08-22T18:06:38.840+02:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="clases"/><title type='text'>Clases restringidas o selladas (sealed classes) en Kotlin</title><content type='html'>&lt;img alt=&quot;Clases restringidas o selladas (sealed classes) en Kotlin&quot; border=&quot;0&quot; data-original-height=&quot;560&quot; data-original-width=&quot;792&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjsY0PIEtV1MqevKF8y51decK1OPfli7x7Ij-0hCZRAaV301qbXKi0ddOQQhr8Wthlh4TmGD1kr4j92-tJ3UOW0l1vt-ID6gYyeNc-DqBrT8MlXtUhfWMUoPmypb1AWo-i2o2ARKeaEavM/s1600/sealed.png&quot; title=&quot;Clases restringidas o selladas (sealed classes) en Kotlin&quot; /&gt;&lt;br /&gt;
&lt;br /&gt;
Antes de entrar en las &lt;b&gt;clases selladas&lt;/b&gt; vamos a recordar lo que vimos en su día sobre los &lt;a href=&quot;https://kotlindoc.blogspot.com/2019/05/clase-de-enumeracion-o-enum-class-en.html&quot;&gt;enumerados o &lt;i&gt;enum class&lt;/i&gt; en Kotlin&lt;/a&gt; con un ejemplo:&lt;br /&gt;&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;
&lt;pre class=&quot;hl&quot;&gt;&lt;span class=&quot;hl kwa&quot;&gt;enum class&lt;/span&gt; DiaSemana &lt;span class=&quot;hl opt&quot;&gt;{&lt;/span&gt;LUNES&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; MARTES&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; MIERCOLES&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; JUEVES&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; VIERNES&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; SABADO&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; DOMINGO&lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;hl kwa&quot;&gt;fun&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;main&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;() {&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;val&lt;/span&gt; diaSemana &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; DiaSemana&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;LUNES
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwd&quot;&gt;println&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;diaSemana&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;hl slc&quot;&gt;// LUNES&lt;/span&gt;
&lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt;&lt;/pre&gt;
También se pueden inicializar haciendo referencia a &lt;b&gt;una propiedad&lt;/b&gt; definida en el constructor (un valor):&lt;br /&gt;
&lt;pre class=&quot;hl&quot;&gt;&lt;span class=&quot;hl kwa&quot;&gt;enum class&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;DiaSemana&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl kwa&quot;&gt;val&lt;/span&gt; dia&lt;span class=&quot;hl opt&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;hl kwb&quot;&gt;Int&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;) {&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwd&quot;&gt;LUNES&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl num&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;),&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwd&quot;&gt;MARTES&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl num&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;),&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwd&quot;&gt;MIERCOLES&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl num&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;),&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwd&quot;&gt;JUEVES&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl num&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;),&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwd&quot;&gt;VIERNES&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl num&quot;&gt;5&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;),&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwd&quot;&gt;SABADO&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl num&quot;&gt;6&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;),&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwd&quot;&gt;DOMINGO&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl num&quot;&gt;7&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt;&lt;/pre&gt;
Pero además de valor pueden tener &lt;b&gt;comportamiento&lt;/b&gt;, de dos maneras:&lt;br /&gt;
&lt;ol&gt;
&lt;li&gt;Definiendo sus propios &lt;b&gt;métodos&lt;/b&gt;, abstractos o no:&lt;/li&gt;
&lt;pre class=&quot;hl&quot;&gt;&lt;span class=&quot;hl kwa&quot;&gt;enum class&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;DiaSemana&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl kwa&quot;&gt;val&lt;/span&gt; dia&lt;span class=&quot;hl opt&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;hl kwb&quot;&gt;Int&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;) {&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwd&quot;&gt;LUNES&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl num&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;) {&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;override fun&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;esFinDeSemana&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;() =&lt;/span&gt; &lt;span class=&quot;hl kwa&quot;&gt;false&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl opt&quot;&gt;},&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwd&quot;&gt;MARTES&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl num&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;) {&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;override fun&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;esFinDeSemana&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;() =&lt;/span&gt; &lt;span class=&quot;hl kwa&quot;&gt;false&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl opt&quot;&gt;},&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwd&quot;&gt;MIERCOLES&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl num&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;) {&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;override fun&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;esFinDeSemana&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;() =&lt;/span&gt; &lt;span class=&quot;hl kwa&quot;&gt;false&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl opt&quot;&gt;},&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwd&quot;&gt;JUEVES&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl num&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;) {&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;override fun&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;esFinDeSemana&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;() =&lt;/span&gt; &lt;span class=&quot;hl kwa&quot;&gt;false&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl opt&quot;&gt;},&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwd&quot;&gt;VIERNES&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl num&quot;&gt;5&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;) {&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;override fun&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;esFinDeSemana&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;() =&lt;/span&gt; &lt;span class=&quot;hl kwa&quot;&gt;false&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl opt&quot;&gt;},&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwd&quot;&gt;SABADO&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl num&quot;&gt;6&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;) {&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;override fun&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;esFinDeSemana&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;() =&lt;/span&gt; &lt;span class=&quot;hl kwa&quot;&gt;true&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl opt&quot;&gt;},&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwd&quot;&gt;DOMINGO&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl num&quot;&gt;7&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;) {&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;override fun&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;esFinDeSemana&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;() =&lt;/span&gt; &lt;span class=&quot;hl kwa&quot;&gt;true&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl opt&quot;&gt;};&lt;/span&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;abstract fun&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;esFinDeSemana&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;():&lt;/span&gt; &lt;span class=&quot;hl kwb&quot;&gt;Boolean&lt;/span&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;fun&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;anteriorA&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;diaSemana&lt;span class=&quot;hl opt&quot;&gt;:&lt;/span&gt; DiaSemana&lt;span class=&quot;hl opt&quot;&gt;):&lt;/span&gt; &lt;span class=&quot;hl kwb&quot;&gt;Boolean&lt;/span&gt; &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; dia &lt;span class=&quot;hl opt&quot;&gt;&amp;lt;&lt;/span&gt; diaSemana&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;dia
&lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;hl kwa&quot;&gt;fun&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;main&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;() {&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;val&lt;/span&gt; dia1 &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; DiaSemana&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;JUEVES
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;val&lt;/span&gt; dia2 &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; DiaSemana&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;DOMINGO
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwd&quot;&gt;println&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;dia1&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;esFinDeSemana&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;())&lt;/span&gt; &lt;span class=&quot;hl slc&quot;&gt;// false&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwd&quot;&gt;println&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;dia2&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;esFinDeSemana&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;())&lt;/span&gt; &lt;span class=&quot;hl slc&quot;&gt;// true&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwd&quot;&gt;println&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;dia1&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;anteriorA&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;dia2&lt;span class=&quot;hl opt&quot;&gt;))&lt;/span&gt; &lt;span class=&quot;hl slc&quot;&gt;// true&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwd&quot;&gt;println&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;dia2&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;anteriorA&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;dia1&lt;span class=&quot;hl opt&quot;&gt;))&lt;/span&gt; &lt;span class=&quot;hl slc&quot;&gt;// false&lt;/span&gt;
&lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt;&lt;/pre&gt;
&lt;li&gt;Implementando &lt;b&gt;interfaces&lt;/b&gt;, aunque no extendiendo otras clases:&lt;/li&gt;
&lt;pre class=&quot;hl&quot;&gt;&lt;span class=&quot;hl kwa&quot;&gt;interface&lt;/span&gt; Dia &lt;span class=&quot;hl opt&quot;&gt;{&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;fun&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;esFinDeSemana&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;():&lt;/span&gt; &lt;span class=&quot;hl kwb&quot;&gt;Boolean&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;fun&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;esDiaSemana&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;():&lt;/span&gt; &lt;span class=&quot;hl kwb&quot;&gt;Boolean&lt;/span&gt;
&lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;hl kwa&quot;&gt;enum class&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;DiaSemana&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl kwa&quot;&gt;val&lt;/span&gt; dia&lt;span class=&quot;hl opt&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;hl kwb&quot;&gt;Int&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;) :&lt;/span&gt; Dia &lt;span class=&quot;hl opt&quot;&gt;{&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwd&quot;&gt;LUNES&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl num&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;) {&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;override fun&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;esFinDeSemana&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;() =&lt;/span&gt; &lt;span class=&quot;hl kwa&quot;&gt;false&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl opt&quot;&gt;},&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwd&quot;&gt;MARTES&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl num&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;) {&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;override fun&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;esFinDeSemana&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;() =&lt;/span&gt; &lt;span class=&quot;hl kwa&quot;&gt;false&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl opt&quot;&gt;},&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwd&quot;&gt;MIERCOLES&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl num&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;) {&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;override fun&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;esFinDeSemana&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;() =&lt;/span&gt; &lt;span class=&quot;hl kwa&quot;&gt;false&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl opt&quot;&gt;},&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwd&quot;&gt;JUEVES&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl num&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;) {&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;override fun&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;esFinDeSemana&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;() =&lt;/span&gt; &lt;span class=&quot;hl kwa&quot;&gt;false&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl opt&quot;&gt;},&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwd&quot;&gt;VIERNES&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl num&quot;&gt;5&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;) {&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;override fun&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;esFinDeSemana&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;() =&lt;/span&gt; &lt;span class=&quot;hl kwa&quot;&gt;false&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl opt&quot;&gt;},&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwd&quot;&gt;SABADO&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl num&quot;&gt;6&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;) {&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;override fun&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;esFinDeSemana&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;() =&lt;/span&gt; &lt;span class=&quot;hl kwa&quot;&gt;true&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl opt&quot;&gt;},&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwd&quot;&gt;DOMINGO&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl num&quot;&gt;7&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;) {&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;override fun&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;esFinDeSemana&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;() =&lt;/span&gt; &lt;span class=&quot;hl kwa&quot;&gt;true&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl opt&quot;&gt;};&lt;/span&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;override fun&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;esDiaSemana&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;():&lt;/span&gt; &lt;span class=&quot;hl kwb&quot;&gt;Boolean&lt;/span&gt; &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;hl kwa&quot;&gt;true&lt;/span&gt;
&lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt;&lt;/pre&gt;
&lt;/ol&gt;
Hasta aquí los enumerados se ven fuertes y con muchas potencialidades, pero su principal limitación es que todos los subtipos tienen una misma estructura (en el ejemplo, todos comparten un valor y unos métodos, ya sean individuales o uno general para todos los tipos). La solución son las &lt;b&gt;clases selladas&lt;/b&gt; (&lt;i&gt;sealed classes&lt;/i&gt;), donde cada subtipo (subclase) es una clase que puede contener sus propios valores y métodos independientes.&lt;br /&gt;
&lt;br /&gt;
Imagina que queremos controlar los posibles errores de acceso en una pantalla de identificación con usuario y contraseña; tendremos un error si alguno de los campos está en blanco, otro si el usuario no está registrado, otro si la contraseña no corresponde al usuario registrado y otro desconocido por lo que pueda pasar. Esto lo podemos modelar de esta manera (para declarar una clase sellada colocamos el modificador &lt;i&gt;sealed&lt;/i&gt; antes del nombre de la clase):&lt;br /&gt;
&lt;pre class=&quot;hl&quot;&gt;sealed &lt;span class=&quot;hl kwa&quot;&gt;class&lt;/span&gt; LoginError &lt;span class=&quot;hl opt&quot;&gt;{&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; data &lt;span class=&quot;hl kwa&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;Incompleto&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl kwa&quot;&gt;val&lt;/span&gt; username&lt;span class=&quot;hl opt&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;hl kwb&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;hl kwa&quot;&gt;val&lt;/span&gt; password&lt;span class=&quot;hl opt&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;hl kwb&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;) :&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;LoginError&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;()&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;NoRegistrado&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl kwa&quot;&gt;val&lt;/span&gt; username&lt;span class=&quot;hl opt&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;hl kwb&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;) :&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;LoginError&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;()&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;PassError&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl kwa&quot;&gt;val&lt;/span&gt; password&lt;span class=&quot;hl opt&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;hl kwb&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;) :&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;LoginError&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;()&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;object&lt;/span&gt; Indefinido &lt;span class=&quot;hl opt&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;LoginError&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;()&lt;/span&gt;
&lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt;&lt;/pre&gt;
Las llaves son opcionales, por lo que podemos escribir los mismo de esta manera:&lt;br /&gt;
&lt;pre class=&quot;hl&quot;&gt;sealed &lt;span class=&quot;hl kwa&quot;&gt;class&lt;/span&gt; LoginError
data &lt;span class=&quot;hl kwa&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;Incompleto&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl kwa&quot;&gt;val&lt;/span&gt; username&lt;span class=&quot;hl opt&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;hl kwb&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;hl kwa&quot;&gt;val&lt;/span&gt; password&lt;span class=&quot;hl opt&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;hl kwb&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;) :&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;LoginError&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;()&lt;/span&gt;
&lt;span class=&quot;hl kwa&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;NoRegistrado&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl kwa&quot;&gt;val&lt;/span&gt; username&lt;span class=&quot;hl opt&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;hl kwb&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;) :&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;LoginError&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;()&lt;/span&gt;
&lt;span class=&quot;hl kwa&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;PassError&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl kwa&quot;&gt;val&lt;/span&gt; password&lt;span class=&quot;hl opt&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;hl kwb&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;) :&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;LoginError&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;()&lt;/span&gt;
&lt;span class=&quot;hl kwa&quot;&gt;object&lt;/span&gt; Indefinido &lt;span class=&quot;hl opt&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;LoginError&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;()&lt;/span&gt;&lt;/pre&gt;
Donde &lt;i&gt;LoginError&lt;/i&gt; es una clase abstracta que tiene únicamente cuatro hijos: &lt;i&gt;Incompleto&lt;/i&gt;, &lt;i&gt;NoRegistrado&lt;/i&gt;, &lt;i&gt;PassError&lt;/i&gt; e &lt;i&gt;Indefinido&lt;/i&gt;, y por tanto cuando manejamos un &lt;i&gt;LoginError&lt;/i&gt; éste solo puede ser de uno de estos tipos. A partir de aquí podemos utilizar la expresión &lt;i&gt;when&lt;/i&gt; de esta manera (con &lt;i&gt;is&lt;/i&gt; en el caso de las clases y sin &lt;i&gt;is&lt;/i&gt; en el caso de los objectos, y como una expresión no requiere &lt;i&gt;else&lt;/i&gt; al contemplar todas las opciones posibles):&lt;br /&gt;
&lt;pre class=&quot;hl&quot;&gt;sealed &lt;span class=&quot;hl kwa&quot;&gt;class&lt;/span&gt; LoginError &lt;span class=&quot;hl opt&quot;&gt;{&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; data &lt;span class=&quot;hl kwa&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;Incompleto&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl kwa&quot;&gt;val&lt;/span&gt; username&lt;span class=&quot;hl opt&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;hl kwb&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;hl kwa&quot;&gt;val&lt;/span&gt; password&lt;span class=&quot;hl opt&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;hl kwb&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;) :&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;LoginError&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;()&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;NoRegistrado&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl kwa&quot;&gt;val&lt;/span&gt; username&lt;span class=&quot;hl opt&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;hl kwb&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;) :&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;LoginError&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;()&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;PassError&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl kwa&quot;&gt;val&lt;/span&gt; password&lt;span class=&quot;hl opt&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;hl kwb&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;) :&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;LoginError&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;()&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;object&lt;/span&gt; Indefinido &lt;span class=&quot;hl opt&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;LoginError&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;()&lt;/span&gt;
&lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;hl kwa&quot;&gt;fun&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;main&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;() {&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;val&lt;/span&gt; error &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; LoginError&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;PassError&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl str&quot;&gt;&quot;1234&quot;&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwd&quot;&gt;println&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;getError&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;error&lt;span class=&quot;hl opt&quot;&gt;))&lt;/span&gt;
&lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;hl kwa&quot;&gt;fun&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;getError&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;error&lt;span class=&quot;hl opt&quot;&gt;:&lt;/span&gt; LoginError&lt;span class=&quot;hl opt&quot;&gt;):&lt;/span&gt; &lt;span class=&quot;hl kwb&quot;&gt;String&lt;/span&gt; &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;hl kwa&quot;&gt;when&lt;/span&gt; &lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;error&lt;span class=&quot;hl opt&quot;&gt;) {&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;is&lt;/span&gt; LoginError&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;Incompleto &lt;span class=&quot;hl opt&quot;&gt;-&amp;gt;&lt;/span&gt; &lt;span class=&quot;hl str&quot;&gt;&quot;Campos de usuario y contraseña requeridos.&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;is&lt;/span&gt; LoginError&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;NoRegistrado &lt;span class=&quot;hl opt&quot;&gt;-&amp;gt;&lt;/span&gt; &lt;span class=&quot;hl str&quot;&gt;&quot;El usuario&lt;/span&gt; &lt;span class=&quot;hl ipl&quot;&gt;${error.username}&lt;/span&gt; &lt;span class=&quot;hl str&quot;&gt;no está registrado.&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;is&lt;/span&gt; LoginError&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;PassError &lt;span class=&quot;hl opt&quot;&gt;-&amp;gt;&lt;/span&gt; &lt;span class=&quot;hl str&quot;&gt;&quot;Contraseña&lt;/span&gt; &lt;span class=&quot;hl ipl&quot;&gt;${error.password}&lt;/span&gt; &lt;span class=&quot;hl str&quot;&gt;no reconocida&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; LoginError&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;Indefinido &lt;span class=&quot;hl opt&quot;&gt;-&amp;gt;&lt;/span&gt; &lt;span class=&quot;hl str&quot;&gt;&quot;Error desconocido.&quot;&lt;/span&gt;
&lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt;&lt;/pre&gt;
Esto hace que si entramos, por ejemplo, en la opción &lt;i&gt;NoRegistrado&lt;/i&gt; nuestra variable &lt;i&gt;error&lt;/i&gt; sea inmediatamente (por conversión implícita o &lt;i&gt;smart cast&lt;/i&gt;) un &lt;i&gt;NoRegistrado&lt;/i&gt; en ese ámbito. Observa que, en el ejemplo, estamos accediendo al atributo &lt;i&gt;password&lt;/i&gt; que no es compartido por todos los elementos.&lt;br /&gt;
&lt;br /&gt;
Como vemos, frente a los enumerados, la principal ventaja de las clases selladas es el hecho de que los elementos son clases (&lt;i&gt;class&lt;/i&gt;, &lt;i&gt;data class&lt;/i&gt;, &lt;i&gt;object&lt;/i&gt; e incluso &lt;i&gt;sealed class&lt;/i&gt;), y que cada subclase puede tener sus propios valores y métodos (además, los enumerados solamente pueden tener una instancia, mientras que las subclases de clases selladas pueden tener varias instancias, cada una con su estado).&lt;br /&gt;
&lt;br /&gt;
Por tanto, las clases selladas, además de entenderse como una extensión de la clase &lt;i&gt;enum&lt;/i&gt; o superenumerados, son empleadas para construir una herencia cerrada en la que el compilador conoce cuáles son las únicas clases hijas, ya que no puede haber otras; representan jerarquías de &lt;b&gt;clases restringidas&lt;/b&gt; en las que un valor debe tener uno de los tipos de un conjunto limitado, pero no puede tener ningún otro tipo. Y aunque el conjunto de valores para un tipo &lt;i&gt;enum&lt;/i&gt; también está restringido, para cada constante &lt;i&gt;enum&lt;/i&gt; existe solo una única instancia (sólo tenemos un único objeto por tipo) mientras que una subclase de una clase sellada puede tener múltiples instancias que pueden contener estado.&lt;br /&gt;
&lt;br /&gt;
Vamos a ver unos ejemplos utilizando &lt;i&gt;sealed classes&lt;/i&gt;:&lt;br /&gt;
&lt;pre class=&quot;hl&quot;&gt;sealed &lt;span class=&quot;hl kwa&quot;&gt;class&lt;/span&gt; Expr
data &lt;span class=&quot;hl kwa&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;Const&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl kwa&quot;&gt;val&lt;/span&gt; number&lt;span class=&quot;hl opt&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;hl kwb&quot;&gt;Double&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;) :&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;Expr&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;()&lt;/span&gt;
data &lt;span class=&quot;hl kwa&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;Sum&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl kwa&quot;&gt;val&lt;/span&gt; e1&lt;span class=&quot;hl opt&quot;&gt;:&lt;/span&gt; Expr&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;hl kwa&quot;&gt;val&lt;/span&gt; e2&lt;span class=&quot;hl opt&quot;&gt;:&lt;/span&gt; Expr&lt;span class=&quot;hl opt&quot;&gt;) :&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;Expr&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;()&lt;/span&gt;
&lt;span class=&quot;hl kwa&quot;&gt;object&lt;/span&gt; NotANumber &lt;span class=&quot;hl opt&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;Expr&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;()&lt;/span&gt;

&lt;span class=&quot;hl kwa&quot;&gt;fun&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;main&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;() {&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;val&lt;/span&gt; pi &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;Const&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl num&quot;&gt;3.1415&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwd&quot;&gt;println&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;eval&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;pi&lt;span class=&quot;hl opt&quot;&gt;))&lt;/span&gt; &lt;span class=&quot;hl slc&quot;&gt;// 3.1415&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwd&quot;&gt;println&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;eval&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;Sum&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;pi&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; pi&lt;span class=&quot;hl opt&quot;&gt;)))&lt;/span&gt; &lt;span class=&quot;hl slc&quot;&gt;// 6.283&lt;/span&gt;
&lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;hl kwa&quot;&gt;fun&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;eval&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;expr&lt;span class=&quot;hl opt&quot;&gt;:&lt;/span&gt; Expr&lt;span class=&quot;hl opt&quot;&gt;):&lt;/span&gt; &lt;span class=&quot;hl kwb&quot;&gt;Double&lt;/span&gt; &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;hl kwa&quot;&gt;when&lt;/span&gt; &lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;expr&lt;span class=&quot;hl opt&quot;&gt;) {&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;is&lt;/span&gt; Const &lt;span class=&quot;hl opt&quot;&gt;-&amp;gt;&lt;/span&gt; expr&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;number
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;is&lt;/span&gt; Sum &lt;span class=&quot;hl opt&quot;&gt;-&amp;gt;&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;eval&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;expr&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;e1&lt;span class=&quot;hl opt&quot;&gt;) +&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;eval&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;expr&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;e2&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; NotANumber &lt;span class=&quot;hl opt&quot;&gt;-&amp;gt;&lt;/span&gt; &lt;span class=&quot;hl kwb&quot;&gt;Double&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;NaN
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl slc&quot;&gt;// else no es requerido porque cubrimos todos los casos&lt;/span&gt;
&lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt;&lt;/pre&gt;
Otro ejemplo:&lt;br /&gt;
&lt;pre class=&quot;hl&quot;&gt;&lt;span class=&quot;hl slc&quot;&gt;// enum class PuntoCardinal { NORTE, SUR, OESTE, ESTE }&lt;/span&gt;
sealed &lt;span class=&quot;hl kwa&quot;&gt;class&lt;/span&gt; PuntoCardinal &lt;span class=&quot;hl opt&quot;&gt;{&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;Norte&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl kwa&quot;&gt;val&lt;/span&gt; value&lt;span class=&quot;hl opt&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;hl kwb&quot;&gt;Int&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;) :&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;PuntoCardinal&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;()&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;Sur&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl kwa&quot;&gt;val&lt;/span&gt; value&lt;span class=&quot;hl opt&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;hl kwb&quot;&gt;Int&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;) :&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;PuntoCardinal&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;()&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;Oeste&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl kwa&quot;&gt;val&lt;/span&gt; value&lt;span class=&quot;hl opt&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;hl kwb&quot;&gt;Int&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;) :&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;PuntoCardinal&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;()&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;Este&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl kwa&quot;&gt;val&lt;/span&gt; value&lt;span class=&quot;hl opt&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;hl kwb&quot;&gt;Int&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;) :&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;PuntoCardinal&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;()&lt;/span&gt;
&lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;hl kwa&quot;&gt;fun&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;main&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;() {&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;var&lt;/span&gt; orientacion&lt;span class=&quot;hl opt&quot;&gt;:&lt;/span&gt; PuntoCardinal
&amp;nbsp;&amp;nbsp;&amp;nbsp; orientacion &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; PuntoCardinal&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;Sur&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl num&quot;&gt;30&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwd&quot;&gt;println&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;rumbo&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;orientacion&lt;span class=&quot;hl opt&quot;&gt;))&lt;/span&gt;&amp;nbsp; &lt;span class=&quot;hl slc&quot;&gt;// 210&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; orientacion &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; PuntoCardinal&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;Este&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl num&quot;&gt;10&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwd&quot;&gt;println&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;rumbo&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;orientacion&lt;span class=&quot;hl opt&quot;&gt;))&lt;/span&gt;&amp;nbsp; &lt;span class=&quot;hl slc&quot;&gt;// 100&lt;/span&gt;
&lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;hl kwa&quot;&gt;fun&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;rumbo&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;orientacion&lt;span class=&quot;hl opt&quot;&gt;:&lt;/span&gt; PuntoCardinal&lt;span class=&quot;hl opt&quot;&gt;) =&lt;/span&gt; &lt;span class=&quot;hl kwa&quot;&gt;when&lt;/span&gt; &lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;orientacion&lt;span class=&quot;hl opt&quot;&gt;) {&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;is&lt;/span&gt; PuntoCardinal&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;Norte &lt;span class=&quot;hl opt&quot;&gt;-&amp;gt;&lt;/span&gt; orientacion&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;value &lt;span class=&quot;hl opt&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;hl num&quot;&gt;0&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;is&lt;/span&gt; PuntoCardinal&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;Este &lt;span class=&quot;hl opt&quot;&gt;-&amp;gt;&lt;/span&gt; orientacion&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;value &lt;span class=&quot;hl opt&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;hl num&quot;&gt;90&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;is&lt;/span&gt; PuntoCardinal&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;Sur &lt;span class=&quot;hl opt&quot;&gt;-&amp;gt;&lt;/span&gt; orientacion&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;value &lt;span class=&quot;hl opt&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;hl num&quot;&gt;180&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;is&lt;/span&gt; PuntoCardinal&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;Oeste &lt;span class=&quot;hl opt&quot;&gt;-&amp;gt;&lt;/span&gt; orientacion&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;value &lt;span class=&quot;hl opt&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;hl num&quot;&gt;270&lt;/span&gt;
&lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt;&lt;/pre&gt;
Y otro más:&lt;br /&gt;
&lt;pre class=&quot;hl&quot;&gt;sealed &lt;span class=&quot;hl kwa&quot;&gt;class&lt;/span&gt; Operacion &lt;span class=&quot;hl opt&quot;&gt;{&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;Suma&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl kwa&quot;&gt;val&lt;/span&gt; valor&lt;span class=&quot;hl opt&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;hl kwb&quot;&gt;Int&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;) :&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;Operacion&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;()&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;Resta&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl kwa&quot;&gt;val&lt;/span&gt; valor&lt;span class=&quot;hl opt&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;hl kwb&quot;&gt;Int&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;) :&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;Operacion&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;()&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;Multiplicacion&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl kwa&quot;&gt;val&lt;/span&gt; valor&lt;span class=&quot;hl opt&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;hl kwb&quot;&gt;Int&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;) :&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;Operacion&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;()&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;Division&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl kwa&quot;&gt;val&lt;/span&gt; valor&lt;span class=&quot;hl opt&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;hl kwb&quot;&gt;Int&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;) :&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;Operacion&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;()&lt;/span&gt;
&lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;hl kwa&quot;&gt;fun&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;main&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;() {&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;val&lt;/span&gt; numero &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;hl num&quot;&gt;5&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;var&lt;/span&gt; operacion&lt;span class=&quot;hl opt&quot;&gt;:&lt;/span&gt; Operacion
&amp;nbsp;&amp;nbsp;&amp;nbsp; operacion &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; Operacion&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;Suma&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl num&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;val&lt;/span&gt; numero2 &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;calcular&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;numero&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; operacion&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwd&quot;&gt;println&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;numero2&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;&amp;nbsp; &lt;span class=&quot;hl slc&quot;&gt;// 8&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; operacion &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; Operacion&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;Multiplicacion&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl num&quot;&gt;6&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwd&quot;&gt;println&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;calcular&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;numero2&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; operacion&lt;span class=&quot;hl opt&quot;&gt;))&lt;/span&gt;&amp;nbsp; &lt;span class=&quot;hl slc&quot;&gt;// 48&lt;/span&gt;
&lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;hl kwa&quot;&gt;fun&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;calcular&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;x&lt;span class=&quot;hl opt&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;hl kwb&quot;&gt;Int&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; op&lt;span class=&quot;hl opt&quot;&gt;:&lt;/span&gt; Operacion&lt;span class=&quot;hl opt&quot;&gt;) =&lt;/span&gt; &lt;span class=&quot;hl kwa&quot;&gt;when&lt;/span&gt; &lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;op&lt;span class=&quot;hl opt&quot;&gt;) {&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;is&lt;/span&gt; Operacion&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;Suma &lt;span class=&quot;hl opt&quot;&gt;-&amp;gt;&lt;/span&gt; x &lt;span class=&quot;hl opt&quot;&gt;+&lt;/span&gt; op&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;valor
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;is&lt;/span&gt; Operacion&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;Resta &lt;span class=&quot;hl opt&quot;&gt;-&amp;gt;&lt;/span&gt; x &lt;span class=&quot;hl opt&quot;&gt;-&lt;/span&gt; op&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;valor
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;is&lt;/span&gt; Operacion&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;Multiplicacion &lt;span class=&quot;hl opt&quot;&gt;-&amp;gt;&lt;/span&gt; x &lt;span class=&quot;hl opt&quot;&gt;*&lt;/span&gt; op&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;valor
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;is&lt;/span&gt; Operacion&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;Division &lt;span class=&quot;hl opt&quot;&gt;-&amp;gt;&lt;/span&gt; x &lt;span class=&quot;hl opt&quot;&gt;/&lt;/span&gt; op&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;valor
&lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt;&lt;/pre&gt;
</content><link rel='replies' type='application/atom+xml' href='https://kotlindoc.blogspot.com/feeds/5025376899706004800/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='https://kotlindoc.blogspot.com/2019/08/clases-restringidas-o-selladas-sealed.html#comment-form' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='https://www.blogger.com/feeds/6895501055750567199/posts/default/5025376899706004800'/><link rel='self' type='application/atom+xml' href='https://www.blogger.com/feeds/6895501055750567199/posts/default/5025376899706004800'/><link rel='alternate' type='text/html' href='https://kotlindoc.blogspot.com/2019/08/clases-restringidas-o-selladas-sealed.html' title='Clases restringidas o selladas (sealed classes) en Kotlin'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjsY0PIEtV1MqevKF8y51decK1OPfli7x7Ij-0hCZRAaV301qbXKi0ddOQQhr8Wthlh4TmGD1kr4j92-tJ3UOW0l1vt-ID6gYyeNc-DqBrT8MlXtUhfWMUoPmypb1AWo-i2o2ARKeaEavM/s72-c/sealed.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6895501055750567199.post-4079903140133773654</id><published>2019-08-19T16:14:00.001+02:00</published><updated>2019-08-20T17:37:04.880+02:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="android básico"/><category scheme="http://www.blogger.com/atom/ns#" term="android studio"/><title type='text'>Navegando entre fragmentos</title><content type='html'>&lt;img alt=&quot;Navegando entre fragmentos&quot; border=&quot;0&quot; data-original-height=&quot;533&quot; data-original-width=&quot;913&quot; height=&quot;373&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhcpV2q-xSGXgm1xzXlcKnrynK5VMctw2R5NsC6zsCVEN0M99lOOr8PX2FwU2J5bcYhYLXVVHcQbgaKg_dIFvU_teFgk2iUgmssQjYEfontEjXOp7Gdw0QDQGU_6vNWX-X-2fVqFQxGkfA/s640/navegando.png&quot; title=&quot;Navegando entre fragmentos&quot; width=&quot;640&quot; /&gt;&lt;br /&gt;
&lt;br /&gt;
En esta entrada vamos desarrollar una aplicación para ilustrar el uso de &lt;b&gt;&lt;a href=&quot;https://kotlindoc.blogspot.com/2019/08/fundamentos-de-android-introduccion-los.html&quot;&gt;fragmentos&lt;/a&gt;&lt;/b&gt; (en la primera parte) y las &lt;b&gt;rutas de navegación&lt;/b&gt; (en una segunda parte) en Android con Kotlin. La aplicación representa un sencillo test de inteligencia cuyo diseño se distribuye en varios componentes principales (estos componentes nos servirán de referencia a la hora de crear los fragmentos):&lt;br /&gt;&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;
&lt;ol&gt;
&lt;li&gt;&lt;b&gt;Pantalla de inicio&lt;/b&gt;, que contiene el logo y nombre de la aplicación y un botón para iniciar el test.&lt;/li&gt;
&lt;li&gt;&lt;b&gt;Pantalla del test&lt;/b&gt;, abierta al pulsar el botón de inicio, en la que se van sucediendo preguntas con las posibles opciones de respuesta.&lt;/li&gt;
&lt;li&gt;&lt;b&gt;Pantallas de resultados&lt;/b&gt;.&lt;/li&gt;
&lt;li&gt;&lt;b&gt;Pantallas de información y acerca de&lt;/b&gt;.&lt;/li&gt;
&lt;li&gt;Un &lt;b&gt;cajón de navegación&lt;/b&gt; que se abre al pulsar sobre un botón de navegación situado en la barra de la aplicación y que contiene un menú con enlaces a las pantallas de información y acerca de.&lt;/li&gt;
&lt;/ol&gt;
En esta entrada veremos los tres primeros puntos, dejando el resto para próximas entregas.&lt;br /&gt;
&lt;br /&gt;
Empezamos creando un nuevo proyecto llamado &lt;i&gt;Test CI&lt;/i&gt; desde una actividad vacía. Lo configuramos para trabajar con &lt;i&gt;Data Binding&lt;/i&gt; (para más detalles, revisar &lt;a href=&quot;https://kotlindoc.blogspot.com/2019/08/fundamentos-de-android-data-binding.html&quot;&gt;Fundamentos de Android: Data Binding&lt;/a&gt;), esto es:&lt;br /&gt;
&lt;ol&gt;
&lt;li&gt;En app/build.gradle (Module: app) &lt;b&gt;habilitamos dataBinding&lt;/b&gt; (y ya que estamos habilitamos la &lt;a href=&quot;https://kotlindoc.blogspot.com/2019/08/android-studio-con-java-8.html&quot;&gt;compatibilidad con Java 8&lt;/a&gt;).&lt;/li&gt;
&lt;li&gt;Ajustamos el archivo de diseño con una &lt;b&gt;etiqueta layout como clase raíz&lt;/b&gt; (también eliminamos el &lt;i&gt;TextView&lt;/i&gt; y cambiamos el &lt;i&gt;ConstraintLayout&lt;/i&gt; por un &lt;i&gt;LinearLayout&lt;/i&gt; de orientación vertical).&lt;/li&gt;
&lt;li&gt;Y en el archivo de la actividad &lt;b&gt;creamos el objeto de enlace&lt;/b&gt;.&lt;/li&gt;
&lt;/ol&gt;
&lt;br /&gt;
Hasta ahora los archivos de la actividad y del diseño han quedado así:&lt;br /&gt;
&lt;pre class=&quot;hl&quot;&gt;&lt;span class=&quot;hl slc&quot;&gt;// MainActivity.kt&lt;/span&gt;
&lt;span class=&quot;hl kwa&quot;&gt;package&lt;/span&gt; com&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;android&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;testci

&lt;span class=&quot;hl kwa&quot;&gt;import&lt;/span&gt; android&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;os&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;Bundle
&lt;span class=&quot;hl kwa&quot;&gt;import&lt;/span&gt; androidx&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;appcompat&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;app&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;AppCompatActivity
&lt;span class=&quot;hl kwa&quot;&gt;import&lt;/span&gt; androidx&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;databinding&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;DataBindingUtil
&lt;span class=&quot;hl kwa&quot;&gt;import&lt;/span&gt; com&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;android&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;testci&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;databinding&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;ActivityMainBinding

&lt;span class=&quot;hl kwa&quot;&gt;class&lt;/span&gt; MainActivity &lt;span class=&quot;hl opt&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;AppCompatActivity&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;() {&lt;/span&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;override fun&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;onCreate&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;savedInstanceState&lt;span class=&quot;hl opt&quot;&gt;:&lt;/span&gt; Bundle?&lt;span class=&quot;hl opt&quot;&gt;) {&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;super&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;onCreate&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;savedInstanceState&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;val&lt;/span&gt; binding &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; DataBindingUtil&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;setContentView&lt;span class=&quot;hl opt&quot;&gt;&amp;lt;&lt;/span&gt;ActivityMainBinding&lt;span class=&quot;hl opt&quot;&gt;&amp;gt;(&lt;/span&gt;&lt;span class=&quot;hl kwa&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; R&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;layout&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;activity_main&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt;&lt;/pre&gt;
&lt;pre class=&quot;hl&quot;&gt;&lt;span class=&quot;hl com&quot;&gt;&amp;lt;!-- layout/activity_main.xml --&amp;gt;&lt;/span&gt;
&lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;?xml&lt;/span&gt; &lt;span class=&quot;hl kwb&quot;&gt;version&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;1.0&quot;&lt;/span&gt; &lt;span class=&quot;hl kwb&quot;&gt;encoding&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;utf-8&quot;&lt;/span&gt;&lt;span class=&quot;hl kwa&quot;&gt;?&amp;gt;&lt;/span&gt;

&lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;layout&lt;/span&gt; xmlns:&lt;span class=&quot;hl kwb&quot;&gt;android&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;http://schemas.android.com/apk/res/android&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; xmlns:&lt;span class=&quot;hl kwb&quot;&gt;app&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;http://schemas.android.com/apk/res-auto&quot;&lt;/span&gt;&lt;span class=&quot;hl kwa&quot;&gt;&amp;gt;&lt;/span&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;LinearLayout&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_width&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;match_parent&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_height&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;match_parent&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;orientation&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;vertical&quot;&lt;/span&gt;&lt;span class=&quot;hl kwa&quot;&gt;&amp;gt;&lt;/span&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;/LinearLayout&amp;gt;&lt;/span&gt;

&lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;/layout&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;br /&gt;
&lt;h2&gt;
Parte 1: Estructura de fragmentos&lt;/h2&gt;
Creamos un fragmento llamado &lt;i&gt;TitleFragment&lt;/i&gt; y en la ventana &lt;i&gt;New Android Component&lt;/i&gt; desactivamos todas las opciones excepto &lt;i&gt;Create Layout XML?&lt;/i&gt;. Abrimos &lt;i&gt;layout/fragment_title.xml&lt;/i&gt; y lo configuramos para que una etiqueta &lt;i&gt;layout&lt;/i&gt; sea el elemento superior que contenga un &lt;i&gt;ConstraintLayout&lt;/i&gt;, en cuyo interior creamos una imagen, un par de &lt;i&gt;TextView&lt;/i&gt; encadenados y un botón:&lt;br /&gt;
&lt;pre class=&quot;hl&quot;&gt;&lt;span class=&quot;hl com&quot;&gt;&amp;lt;!-- layout/fragment_title.xml --&amp;gt;&lt;/span&gt;
?xml &lt;span class=&quot;hl kwb&quot;&gt;version&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;1.0&quot;&lt;/span&gt; &lt;span class=&quot;hl kwb&quot;&gt;encoding&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;utf-8&quot;&lt;/span&gt;&lt;span class=&quot;hl kwa&quot;&gt;?&amp;gt;&lt;/span&gt;

&lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;layout&lt;/span&gt; xmlns:&lt;span class=&quot;hl kwb&quot;&gt;android&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;http://schemas.android.com/apk/res/android&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; xmlns:&lt;span class=&quot;hl kwb&quot;&gt;app&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;http://schemas.android.com/apk/res-auto&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; xmlns:&lt;span class=&quot;hl kwb&quot;&gt;tools&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;http://schemas.android.com/tools&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; tools:&lt;span class=&quot;hl kwb&quot;&gt;context&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;com.android.testci.TitleFragment&quot;&lt;/span&gt;&lt;span class=&quot;hl kwa&quot;&gt;&amp;gt;&lt;/span&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;androidx&lt;/span&gt;.constraintlayout.widget.ConstraintLayout
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;id&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@+id/titleConstraint&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_width&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;match_parent&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_height&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;match_parent&quot;&lt;/span&gt;&lt;span class=&quot;hl kwa&quot;&gt;&amp;gt;&lt;/span&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;ImageView&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;id&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@+id/titleImage&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_width&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;0dp&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_height&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;0dp&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_marginStart&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@dimen/horizontal_margin&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_marginEnd&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@dimen/horizontal_margin&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;contentDescription&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@string/logo&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;scaleType&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;fitCenter&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; app:&lt;span class=&quot;hl kwb&quot;&gt;layout_constraintBottom_toTopOf&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@+id/textView&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; app:&lt;span class=&quot;hl kwb&quot;&gt;layout_constraintEnd_toEndOf&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;parent&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; app:&lt;span class=&quot;hl kwb&quot;&gt;layout_constraintHorizontal_bias&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;1.0&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; app:&lt;span class=&quot;hl kwb&quot;&gt;layout_constraintStart_toStartOf&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;parent&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; app:&lt;span class=&quot;hl kwb&quot;&gt;layout_constraintTop_toTopOf&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;parent&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; app:&lt;span class=&quot;hl kwb&quot;&gt;srcCompat&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@drawable/ic_mid_mapping&quot;&lt;/span&gt; &lt;span class=&quot;hl kwa&quot;&gt;/&amp;gt;&lt;/span&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;TextView&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;id&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@+id/textView&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_width&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;wrap_content&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_height&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;wrap_content&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;paddingLeft&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@dimen/horizontal_margin&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;paddingRight&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@dimen/horizontal_margin&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;text&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@string/test&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;textAllCaps&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;false&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;textColor&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@color/azul&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;textSize&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@dimen/titulo&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;textStyle&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;bold&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; app:&lt;span class=&quot;hl kwb&quot;&gt;layout_constraintBaseline_toBaselineOf&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@+id/textView2&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; app:&lt;span class=&quot;hl kwb&quot;&gt;layout_constraintEnd_toStartOf&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@+id/textView2&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; app:&lt;span class=&quot;hl kwb&quot;&gt;layout_constraintHorizontal_chainStyle&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;packed&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; app:&lt;span class=&quot;hl kwb&quot;&gt;layout_constraintStart_toStartOf&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;parent&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; app:&lt;span class=&quot;hl kwb&quot;&gt;layout_constraintTop_toBottomOf&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@+id/titleImage&quot;&lt;/span&gt; &lt;span class=&quot;hl kwa&quot;&gt;/&amp;gt;&lt;/span&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;TextView&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;id&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@+id/textView2&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_width&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;wrap_content&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_height&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;wrap_content&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_marginBottom&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;32dp&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;paddingLeft&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@dimen/horizontal_margin&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;paddingRight&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@dimen/horizontal_margin&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;text&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@string/ci&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;textColor&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@color/rosa&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;textSize&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@dimen/titulo&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;textStyle&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;bold&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; app:&lt;span class=&quot;hl kwb&quot;&gt;layout_constraintBottom_toTopOf&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@+id/playButton&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; app:&lt;span class=&quot;hl kwb&quot;&gt;layout_constraintEnd_toEndOf&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;parent&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; app:&lt;span class=&quot;hl kwb&quot;&gt;layout_constraintStart_toEndOf&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@+id/textView&quot;&lt;/span&gt; &lt;span class=&quot;hl kwa&quot;&gt;/&amp;gt;&lt;/span&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;Button&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;id&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@+id/playButton&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_width&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;wrap_content&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_height&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;wrap_content&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_marginStart&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@dimen/horizontal_margin&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_marginTop&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;32dp&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_marginEnd&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@dimen/horizontal_margin&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_marginBottom&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;32dp&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;paddingStart&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@dimen/button_padding&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;paddingEnd&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@dimen/button_padding&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;text&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@string/start&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;textColor&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@color/colorAccent&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;textSize&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@dimen/button_text_size&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;textStyle&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;bold&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; app:&lt;span class=&quot;hl kwb&quot;&gt;layout_constraintBottom_toBottomOf&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;parent&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; app:&lt;span class=&quot;hl kwb&quot;&gt;layout_constraintEnd_toEndOf&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;parent&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; app:&lt;span class=&quot;hl kwb&quot;&gt;layout_constraintStart_toStartOf&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;parent&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; app:&lt;span class=&quot;hl kwb&quot;&gt;layout_constraintTop_toBottomOf&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@+id/textView&quot;&lt;/span&gt; &lt;span class=&quot;hl kwa&quot;&gt;/&amp;gt;&lt;/span&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;/androidx&lt;/span&gt;.constraintlayout.widget.ConstraintLayout&lt;span class=&quot;hl kwa&quot;&gt;&amp;gt;&lt;/span&gt;
&lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;/layout&amp;gt;&lt;/span&gt;&lt;/pre&gt;
Que en la vista &lt;i&gt;Design&lt;/i&gt; del editor de diseño se ve así:&lt;br /&gt;
&lt;br /&gt;
&lt;img border=&quot;0&quot; data-original-height=&quot;794&quot; data-original-width=&quot;791&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg4BKtIuS-U_ZzShtUxyox-N47rGj1tmqaKsalMeyVGKI5lr7TKQJcPvaIcbaww4hnFzSbRHywSXU0oo4iTCic-oZXufzFc5FPv3cNcdAcuHlFwSjTU8wgIZvu4a5ojDpMpyWiyC7ViOZg/s1600/app1.png&quot; /&gt;&lt;br /&gt;
&lt;br /&gt;
Abrimos el archivo del nuevo fragmento y en la función &lt;i&gt;onCreateView&lt;/i&gt; (es uno de los métodos que se llama durante el ciclo de vida de un fragmento) quitamos la instrucción &lt;i&gt;return&lt;/i&gt; dejándola así:&lt;br /&gt;
&lt;pre class=&quot;hl&quot;&gt;&lt;span class=&quot;hl kwa&quot;&gt;override fun&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;onCreateView&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; inflater&lt;span class=&quot;hl opt&quot;&gt;:&lt;/span&gt; LayoutInflater&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; container&lt;span class=&quot;hl opt&quot;&gt;:&lt;/span&gt; ViewGroup?&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; savedInstanceState&lt;span class=&quot;hl opt&quot;&gt;:&lt;/span&gt; Bundle?
&lt;span class=&quot;hl opt&quot;&gt;):&lt;/span&gt; View? &lt;span class=&quot;hl opt&quot;&gt;{&lt;/span&gt;

&lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt;&lt;/pre&gt;
Y en su lugar creamos un &lt;i&gt;objeto binding&lt;/i&gt; y activamos (inflamos) la vista del fragmento (lo que es equivalente a usar &lt;i&gt;setContentView&lt;/i&gt; en una actividad). Para esta activación utilizamos el método &lt;i&gt;DataBindingUtil.inflate&lt;/i&gt; sobre el objeto binding del fragmento con cuatro parámetros:&lt;br /&gt;
&lt;ol&gt;
&lt;li&gt;&lt;i&gt;inflater&lt;/i&gt;, que es el LayoutInflater utilizado para activar el diseño del binding.&lt;/li&gt;
&lt;li&gt;&lt;i&gt;R.layout.fragment_title&lt;/i&gt;: el recurso de diseño para activar.&lt;/li&gt;
&lt;li&gt;&lt;i&gt;container&lt;/i&gt; (parámetro opcional) para el &lt;i&gt;ViewGroup&lt;/i&gt; padre.&lt;/li&gt;
&lt;li&gt;&lt;i&gt;false&lt;/i&gt;, valor que se asigna a &lt;i&gt;attachToParent&lt;/i&gt; (adjuntar al padre).&lt;/li&gt;
&lt;/ol&gt;
&lt;br /&gt;
Asignamos al &lt;i&gt;objeto binding&lt;/i&gt; el resultado del método &lt;i&gt;DataBindingUtil.inflate&lt;/i&gt; y hacemos que la función &lt;i&gt;onCreateView&lt;/i&gt; devuelva &lt;i&gt;binding.root&lt;/i&gt;, que contiene la vista activada:&lt;br /&gt;
&lt;pre class=&quot;hl&quot;&gt;&lt;span class=&quot;hl kwa&quot;&gt;class&lt;/span&gt; TitleFragment &lt;span class=&quot;hl opt&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;Fragment&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;() {&lt;/span&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;override fun&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;onCreateView&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; inflater&lt;span class=&quot;hl opt&quot;&gt;:&lt;/span&gt; LayoutInflater&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; container&lt;span class=&quot;hl opt&quot;&gt;:&lt;/span&gt; ViewGroup?&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; savedInstanceState&lt;span class=&quot;hl opt&quot;&gt;:&lt;/span&gt; Bundle?
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl opt&quot;&gt;):&lt;/span&gt; View? &lt;span class=&quot;hl opt&quot;&gt;{&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl slc&quot;&gt;// Inflate the layout for this fragment&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl slc&quot;&gt;// return inflater.inflate(R.layout.fragment_title, container, false)&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;val&lt;/span&gt; binding &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; DataBindingUtil&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;inflate&lt;span class=&quot;hl opt&quot;&gt;&amp;lt;&lt;/span&gt;FragmentTitleBinding&lt;span class=&quot;hl opt&quot;&gt;&amp;gt;(&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; inflater&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; R&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;layout&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;fragment_title&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; container&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;hl kwa&quot;&gt;false&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;return&lt;/span&gt; binding&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;root
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt;&lt;/pre&gt;
Ahora añadimos el nuevo fragmento al diseño de la actividad, dentro del &lt;i&gt;LinearLayout&lt;/i&gt;:&lt;br /&gt;
&lt;pre class=&quot;hl&quot;&gt;&lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;?xml&lt;/span&gt; &lt;span class=&quot;hl kwb&quot;&gt;version&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;1.0&quot;&lt;/span&gt; &lt;span class=&quot;hl kwb&quot;&gt;encoding&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;utf-8&quot;&lt;/span&gt;&lt;span class=&quot;hl kwa&quot;&gt;?&amp;gt;&lt;/span&gt;

&lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;layout&lt;/span&gt; xmlns:&lt;span class=&quot;hl kwb&quot;&gt;android&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;http://schemas.android.com/apk/res/android&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; xmlns:&lt;span class=&quot;hl kwb&quot;&gt;app&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;http://schemas.android.com/apk/res-auto&quot;&lt;/span&gt;&lt;span class=&quot;hl kwa&quot;&gt;&amp;gt;&lt;/span&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;LinearLayout&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_width&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;match_parent&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_height&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;match_parent&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;orientation&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;vertical&quot;&lt;/span&gt;&lt;span class=&quot;hl kwa&quot;&gt;&amp;gt;&lt;/span&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;fragment&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;id&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@+id/titleFragment&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;name&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;com.android.testci.TitleFragment&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_width&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;match_parent&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_height&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;match_parent&quot;&lt;/span&gt; &lt;span class=&quot;hl kwa&quot;&gt;/&amp;gt;&lt;/span&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;/LinearLayout&amp;gt;&lt;/span&gt;

&lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;/layout&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;br /&gt;
Repitiendo los pasos anteriores, vamos a crear otros fragmentos correspondientes a los distintos componentes que necesitamos en nuestra aplicación: 1) pantalla de inicio, 2) las preguntas del test, dos posibles resultados de 3) acierto y 4) error, y los dos componentes para las 5) instrucciones y la información 6) Acerca de. Aunque de momento no están conectados entre sí, los diseños de estos fragmentos se presentan así:&lt;br /&gt;
&lt;br /&gt;
&lt;img border=&quot;0&quot; data-original-height=&quot;631&quot; data-original-width=&quot;355&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgvdPB65MZV1CNTrWmj7d-PSyB75jbyurFOFbHngpettnFjTXz5HTDFm_zRqvIsv9E8K3FhUi1GeiM-tHfoSODoj9P17Q3rYpf1OEMo_YKpQUpywHYhstAiLY62qH5g1T5zX52rwZznMD8/s1600/fragment.gif&quot; /&gt;&lt;br /&gt;
&lt;br /&gt;
Además en el fragmento dedicado a presentar las preguntas del test (&lt;i&gt;TestFragment.kt&lt;/i&gt;) utilizamos una &lt;a href=&quot;https://kotlindoc.blogspot.com/2019/05/clase-de-datos-o-data-class-en-kotlin.html&quot;&gt;data class&lt;/a&gt; con un parámetro tipo &lt;i&gt;String&lt;/i&gt; para contener las preguntas y otro parámetro tipo &lt;i&gt;Lista de String&lt;/i&gt; para contener las respuesta posibles.&lt;br /&gt;
&lt;pre class=&quot;hl&quot;&gt;data &lt;span class=&quot;hl kwa&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;Question&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;val&lt;/span&gt; text&lt;span class=&quot;hl opt&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;hl kwb&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;val&lt;/span&gt; answers&lt;span class=&quot;hl opt&quot;&gt;:&lt;/span&gt; List&lt;span class=&quot;hl opt&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl kwb&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;&amp;gt;&lt;/span&gt;
&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;&lt;/pre&gt;
Después creamos una lista de objetos de este tipo (&lt;i&gt;Question&lt;/i&gt;) que asignan a cada parámetro los valores de cada pregunta y sus respectivas respuestas alternativas:&lt;br /&gt;
&lt;pre class=&quot;hl&quot;&gt;&lt;span class=&quot;hl kwa&quot;&gt;private val&lt;/span&gt; questions&lt;span class=&quot;hl opt&quot;&gt;:&lt;/span&gt; MutableList&lt;span class=&quot;hl opt&quot;&gt;&amp;lt;&lt;/span&gt;Question&lt;span class=&quot;hl opt&quot;&gt;&amp;gt; =&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;mutableListOf&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwd&quot;&gt;Question&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; text &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;hl str&quot;&gt;&quot;¿Cuál de las siguientes palabras no encaja con el resto?&quot;&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; answers &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;listOf&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl str&quot;&gt;&quot;Ordenanza&quot;&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;hl str&quot;&gt;&quot;Escriba&quot;&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;hl str&quot;&gt;&quot;Secretario&quot;&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;hl str&quot;&gt;&quot;Amanuense&quot;&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;hl str&quot;&gt;&quot;Copista&quot;&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl opt&quot;&gt;),&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwd&quot;&gt;Question&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; text &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;hl str&quot;&gt;&quot;Complete la analogía: ENOJO es a CALMA como ENFURECER a&quot;&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; answers &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;listOf&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl str&quot;&gt;&quot;Apaciguar&quot;&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;hl str&quot;&gt;&quot;Descansar&quot;&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;hl str&quot;&gt;&quot;Despertar&quot;&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;hl str&quot;&gt;&quot;Marear&quot;&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;hl str&quot;&gt;&quot;Alterar&quot;&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl opt&quot;&gt;),&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl opt&quot;&gt;...&lt;/span&gt;
&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;&lt;/pre&gt;
Y dentro de la función &lt;i&gt;onCreateView&lt;/i&gt;:&lt;br /&gt;
&lt;ol&gt;
&lt;li&gt;Llamamos a la función &lt;i&gt;randomizeQuestions&lt;/i&gt; que aleatoriza el orden de las preguntas y establece la primera pregunta (al final de la entrada se puede ver el código de los principales archivos).&lt;/li&gt;
&lt;li&gt;Con &lt;i&gt;setOnClickListener&lt;/i&gt; capturamos la acción del botón de respuesta del diseño (&lt;i&gt;binding.submitButton.setOnClickListener&lt;/i&gt;), que a su vez captura la opción activada en el &lt;i&gt;RadioGroup&lt;/i&gt; (&lt;i&gt;binding.questionRadioGroup.checkedRadioButtonId&lt;/i&gt;) para comprobar si la respuesta es correcta y en ese caso avanza a la siguiente pregunta después de comprobar si han realizado todas las preguntas (entoncés se activará el fragmento de victoria), o si la respuesta no es correcta se activará el fragmento de fin del test.&lt;/li&gt;
&lt;/ol&gt;
&lt;br /&gt;
&lt;h2&gt;
Parte 2: Definir las rutas de navegación&lt;/h2&gt;
Una vez que hemos construido la estructura de la aplicación, ahora crearemos la posibilidad de navegar (las rutas) entre estos componentes conectando las pantallas con acciones y ofreciendo al usuario una forma de navegar entre las pantallas.&lt;br /&gt;
&lt;br /&gt;
Para ello debemos agregar las dependencias de navegación a los archivos de &lt;i&gt;Gradle&lt;/i&gt;. Abrimos el archivo &lt;i&gt;build.gradle&lt;/i&gt; a nivel de proyecto, y en la parte superior, junto con las otras variables &lt;i&gt;ext&lt;/i&gt;, agregamos una variable para &lt;i&gt;navigationVersion&lt;/i&gt;. Si solo tenemos una variable ext, como por ejemplo &lt;i&gt;ext.kotlin_version&lt;/i&gt;, la reescribimos en el bloque ext de esta forma:&lt;br /&gt;
&lt;pre class=&quot;hl&quot;&gt;&lt;span class=&quot;hl slc&quot;&gt;// ext.kotlin_version = &#39;1.3.21&#39;&lt;/span&gt;
ext &lt;span class=&quot;hl opt&quot;&gt;{&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; kotlin_version &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;hl str&quot;&gt;&#39;1.3.21&#39;&lt;/span&gt;
&lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt;&lt;/pre&gt;
Y añadimos la dependencia de navegación (para encontrar la última versión estable consulta &lt;a href=&quot;https://developer.android.com/jetpack/androidx/releases/navigation#declaring&quot;&gt;&lt;i&gt;Declaring dependencies&lt;/i&gt;&lt;/a&gt;):&lt;br /&gt;
&lt;pre class=&quot;hl&quot;&gt;ext &lt;span class=&quot;hl opt&quot;&gt;{&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; kotlin_version &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;hl str&quot;&gt;&#39;1.3.21&#39;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; navigationVersion &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;hl str&quot;&gt;&#39;1.0.0-rc02&#39;&lt;/span&gt;
&lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt;&lt;/pre&gt;
Ahora abrimos &lt;i&gt;build.gradle&lt;/i&gt; a nivel de módulo para agregar las dependencias &lt;i&gt;navigation-fragment-ktx&lt;/i&gt; y &lt;i&gt;navigation-ui-ktx&lt;/i&gt;:&lt;br /&gt;
&lt;pre class=&quot;hl&quot;&gt;dependencies &lt;span class=&quot;hl opt&quot;&gt;{&lt;/span&gt;
&amp;nbsp; &lt;span class=&quot;hl opt&quot;&gt;...&lt;/span&gt;
&amp;nbsp; implementation &lt;span class=&quot;hl str&quot;&gt;&quot;android.arch.navigation:navigation-fragment-ktx:$navigationVersion&quot;&lt;/span&gt;
&amp;nbsp; implementation &lt;span class=&quot;hl str&quot;&gt;&quot;android.arch.navigation:navigation-ui-ktx:$navigationVersion&quot;&lt;/span&gt;
&amp;nbsp; &lt;span class=&quot;hl opt&quot;&gt;...&lt;/span&gt;
&lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt;&lt;/pre&gt;
En caso de utilizar &lt;i&gt;navigationVersion&lt;/i&gt; = &#39;2.1.0-rc01&#39; posiblemente necesites estas dependencias:&lt;br /&gt;
&lt;pre class=&quot;hl&quot;&gt;dependencies &lt;span class=&quot;hl opt&quot;&gt;{&lt;/span&gt;
&amp;nbsp; &lt;span class=&quot;hl opt&quot;&gt;...&lt;/span&gt;
&amp;nbsp; implementation &lt;span class=&quot;hl str&quot;&gt;&quot;androidx.navigation:navigation-fragment-ktx:$$navigationVersion&quot;&lt;/span&gt;
&amp;nbsp; implementation &lt;span class=&quot;hl str&quot;&gt;&quot;androidx.navigation:navigation-ui-ktx:$$navigationVersion&quot;&lt;/span&gt;
&amp;nbsp; &lt;span class=&quot;hl opt&quot;&gt;...&lt;/span&gt;
&lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt;&lt;/pre&gt;
&lt;i&gt;Build&lt;/i&gt; -&amp;gt; &lt;i&gt;Rebuild Project&lt;/i&gt; y sincronizamos los cambios.&lt;br /&gt;
&lt;br /&gt;
Ahora vamos a agregar un &lt;b&gt;gráfico de navegación&lt;/b&gt; desde la carpeta &lt;i&gt;res&lt;/i&gt; -&amp;gt; &lt;i&gt;New&lt;/i&gt; -&amp;gt; &lt;i&gt;Android Resource File&lt;/i&gt;, seleccionamos &lt;i&gt;Navigation&lt;/i&gt; como tipo de recurso y le asignamos un nombre:&lt;br /&gt;
&lt;br /&gt;
&lt;img border=&quot;0&quot; data-original-height=&quot;479&quot; data-original-width=&quot;826&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjcn9Xxp3LdkmVThOFYHNeE5zSx9Qziu9wDv97WTOpoMvUwYB4CuBIXhmbz3waCo0aYqCvJTrTmXSmMmfyCtasqFNGIqzDnPLqk5BERTs3kilGJq7grLU_Zbf62AeYmWFf140H7N_0QlEo/s1600/newNavigation.png&quot; /&gt;&lt;br /&gt;
&lt;br /&gt;
Esto crea, en la carpera &lt;i&gt;res&lt;/i&gt;, la carpeta &lt;i&gt;navigation&lt;/i&gt; con el archivo &lt;i&gt;navigation.xml&lt;/i&gt;, que en la vista &lt;i&gt;Design&lt;/i&gt; solo muestra el mensaje &#39;Click to add a destination&#39;:&lt;br /&gt;
&lt;br /&gt;
&lt;img border=&quot;0&quot; data-original-height=&quot;682&quot; data-original-width=&quot;957&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgStj8eewQCPuJAWLzKEf6hKGLNzY0cSGVCFJ2C8HbyI4DKKC-M2YKUhTCl-r6QELtVJdKIT1Yb0auz4zPMiwRDckjRHrsvQAnAi1JadGER0dh4Beea5c4VM4w-1dhixO_CjFdWEHOaimQ/s1600/navigationXML.png&quot; /&gt;&lt;br /&gt;
&lt;br /&gt;
También vemos que en el panel &lt;i&gt;Destinations&lt;/i&gt; aparece el mensaje &#39;&lt;i&gt;No NavHostFragments found&lt;/i&gt;&#39;. Un fragmento &lt;i&gt;host&lt;/i&gt; de navegación (&lt;i&gt;NavHostFragment&lt;/i&gt;, de &lt;i&gt;navigation host fragment&lt;/i&gt;) actúa como cabeza u organizador de fragmentos en un gráfico de navegación. A medida que el usuario se mueve entre los destinos definidos en el gráfico de navegación, el &lt;i&gt;NavHostFragment&lt;/i&gt; intercambia fragmentos según sea necesario.&lt;br /&gt;
&lt;br /&gt;
Para crear el &lt;i&gt;NavHostFragment&lt;/i&gt; abrimos el archivo de diseño de la actividad principal (&lt;i&gt;activity_main.xml&lt;/i&gt;) y cambiamos el nombre (atributo &lt;i&gt;name&lt;/i&gt;) del fragmento (com.android.testci.TitleFragment) por androidx.navigation.fragment.NavHostFragment y también cambiamos la identificación (atributo id) a &lt;i&gt;myNavHostFragment&lt;/i&gt;. Le añadimos el atributo app:navGraph con el valor del recurso del gráfico de navegación que hemos creado (@navigation/navigation) y el atributo app:defaultNavHost con el valor &lt;i&gt;true&lt;/i&gt;:&lt;br /&gt;
&lt;pre class=&quot;hl&quot;&gt;&lt;span class=&quot;hl com&quot;&gt;&amp;lt;!--&lt;/span&gt;
&lt;span class=&quot;hl com&quot;&gt;&amp;lt;fragment&lt;/span&gt;
&lt;span class=&quot;hl com&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:id=&quot;@+id/titleFragment&quot;&lt;/span&gt;
&lt;span class=&quot;hl com&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:name=&quot;com.android.testci.TitleFragment&quot;&lt;/span&gt;
&lt;span class=&quot;hl com&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:layout_width=&quot;match_parent&quot;&lt;/span&gt;
&lt;span class=&quot;hl com&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:layout_height=&quot;match_parent&quot; /&amp;gt;&lt;/span&gt;
&lt;span class=&quot;hl com&quot;&gt;--&amp;gt;&lt;/span&gt;

&lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;fragment&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;id&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@+id/myNavHostFragment&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;name&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;androidx.navigation.fragment.NavHostFragment&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_width&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;match_parent&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_height&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;match_parent&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; app:&lt;span class=&quot;hl kwb&quot;&gt;defaultNavHost&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;true&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; app:&lt;span class=&quot;hl kwb&quot;&gt;navGraph&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@navigation/navigation&quot;&lt;/span&gt; &lt;span class=&quot;hl kwa&quot;&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;
Ahora este punto de navegación es el &lt;i&gt;NavHostFragments&lt;/i&gt; predeterminado y como tal interceptará el botón Atrás del sistema.&lt;br /&gt;
&lt;br /&gt;
Ahora queda añadir los fragmentos que hemos creado al gráfico de navegación, empezando por los fragmentos de portada (fragment_title.xml) y de test (fragment_test.xml). En el archivo navigation/navigation.xml al pulsar sobre el botón &lt;i&gt;New Destination&lt;/i&gt; aparece una lista de fragmentos y actividades, y seleccionamos fragment_title para que sea el inicio de la aplicación.&lt;br /&gt;
&lt;br /&gt;
&lt;img border=&quot;0&quot; data-original-height=&quot;566&quot; data-original-width=&quot;565&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhumVJOBi_YObFyMKOR2ayeLwXvLIW8n1gcFvy2baP1_hkOiB0M1f4cWSLf7xjzZ3Nt-6bvt-yfBYZCmN5cSLr9B9orwlG9yuo5tjf79dRq9aZxyaRFMLIoPZzFLvb_N52uPKPHzfT7soc/s1600/addFragmento1.png&quot; /&gt;&lt;br /&gt;
&lt;br /&gt;
Repetimos para añadir como nuevo destino el fragmento fragment_test (si la vista previa no está disponible, vamos a la vista &lt;i&gt;Text&lt;/i&gt; para asegurarnos que el elemento correspondiente a testFragment incluye el atributo tools:layout=&quot;@layout/fragment_test&quot;.&lt;br /&gt;
&lt;br /&gt;
&lt;img border=&quot;0&quot; data-original-height=&quot;576&quot; data-original-width=&quot;866&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhk93l2ppn-nSrcxYdPQUu_2N2mEY2Oo7HgePvhiJqJerxupBNqPBZ68MVtVfNb0rYb5tW3VRFiUHZks51HijLkzit7jeXYhnpp0HC8MuDlMs7g1_DVMV3QvHAZd_vKrgt_bmvYHqdTZn8/s1600/nav1.png&quot; /&gt;&lt;br /&gt;
&lt;br /&gt;
Seleccionamos el fragmento del título y pulsamos sobre el punto de conexión del lado derecho, arrastrándolo al fragmento del test, lo que crea una acción que conecta ambos fragmentos. Para ver los atributos de esta acción, seleccionamos la línea o flecha de conexión y comprobamos el valor de su ID (action_titleFragment_to_testFragment) y el atributo Destination (testFragment).&lt;br /&gt;
&lt;br /&gt;
Ahora debemos añadir un controlador de clic al botón EMPEZAR del fragmento de inicio para que al pulsarlo se pueda navegar desde el primero al segundo fragmento (y se ejecute la conexión que acabamos de crear, conduciendo al usuario a la pantalla del test). Abrimos TitleFragment.kt y dentro de &lt;i&gt;onCreateView&lt;/i&gt; agregamos el controlador antes de la declaración de devolución (&lt;i&gt;return&lt;/i&gt;):&lt;br /&gt;
&lt;pre class=&quot;hl&quot;&gt;binding&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;playButton&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;setOnClickListener &lt;span class=&quot;hl opt&quot;&gt;{ }&lt;/span&gt;&lt;/pre&gt;
Y en su interior escribimos el código para navegar al fragmento del test (requiere import androidx.navigation.findNavController):&lt;br /&gt;
&lt;pre class=&quot;hl&quot;&gt;binding&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;playButton&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;setOnClickListener &lt;span class=&quot;hl opt&quot;&gt;{&lt;/span&gt; view&lt;span class=&quot;hl opt&quot;&gt;:&lt;/span&gt; View &lt;span class=&quot;hl opt&quot;&gt;-&amp;gt;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; view&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;findNavController&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;().&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;navigate&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;R&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;id&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;action_titleFragment_to_testFragment&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt;&lt;/pre&gt;
Ejecutamos la aplicación para comprobar que el botón cumple su cometido de llevarnos a la pantalla del test. Además con el botón Atrás del dispositivo volvemos a la primera pantalla.&lt;br /&gt;
&lt;br /&gt;
Ahora vamos a crear &lt;b&gt;rutas de navegación condicionales&lt;/b&gt; en función de las respuestas del usuario, lo que activará el fragmento fragment_test_won.xml o el fragmento fragment_test_over.xml en función de si responde correctamente o no a las preguntas.&lt;br /&gt;
&lt;br /&gt;
Para ello, con el botón &lt;i&gt;New Destination&lt;/i&gt; agregamos estos dos fragmentos al gráfico de navegación del archivo navigation.xml:&lt;br /&gt;
&lt;br /&gt;
&lt;img border=&quot;0&quot; data-original-height=&quot;767&quot; data-original-width=&quot;1032&quot; height=&quot;475&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhViaO8MnriwZa635HWv4qQxi8NYzfrSbF2iXt34WLOdy8C_HlifzwsyD8bNdI8Wh82-pKbpuAUcUyxGMmo_Jv2Q6Cl_Oku2llCKXSoO_7OBu_77qdFAEuXuhdfYSK6uHXg-20K59EAIgg/s640/nav2.png&quot; width=&quot;640&quot; /&gt;&lt;br /&gt;
&lt;br /&gt;
Ahora conectamos el fragmento del test a estos dos fragmentos:&lt;br /&gt;
&lt;br /&gt;
&lt;img border=&quot;0&quot; data-original-height=&quot;669&quot; data-original-width=&quot;1250&quot; height=&quot;342&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEidVwBLFWnRvGM9oXbFMrrkiCpdR6FMMOLW86VHkbyx47uRypZs9jzKXOIg70RdrcJj0XRGii-Ye-f_kFcxd8msHzCVXTvruYkyLuqZq82cTiGVRn8QE08VD49bDG8YoN0VB9stolPTccU/s640/nav3.png&quot; width=&quot;640&quot; /&gt;&lt;br /&gt;
&lt;br /&gt;
El archivo TestFragment.kt contiene la clase &lt;i&gt;TestFragment&lt;/i&gt; que es un fragmento que contiene las preguntas y respuestas del test y también incluye la lógica que determina si el usuario responde correctamente o no, y en cada caso tendrá una acción distinta (distintas rutas de navegación) por parte de la aplicación.&lt;br /&gt;
&lt;pre class=&quot;hl&quot;&gt;&lt;span class=&quot;hl kwa&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;answers&lt;span class=&quot;hl opt&quot;&gt;[&lt;/span&gt;answerIndex&lt;span class=&quot;hl opt&quot;&gt;] ==&lt;/span&gt; currentQuestion&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;answers&lt;span class=&quot;hl opt&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;hl num&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;]) { }&lt;/span&gt;&amp;nbsp; &lt;span class=&quot;hl slc&quot;&gt;// si esto es true, la respuesta es correcta&lt;/span&gt;&lt;/pre&gt;
Si la condición anterior devuelve &lt;i&gt;false&lt;/i&gt; (la respuesta es incorrecta), se termina el test y la aplicación navega a TestOverFragment.&lt;br /&gt;
&lt;pre class=&quot;hl&quot;&gt;&lt;span class=&quot;hl kwa&quot;&gt;else&lt;/span&gt; &lt;span class=&quot;hl opt&quot;&gt;{&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; view&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;findNavController&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;().&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;navigate&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;R&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;id&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;action_testFragment_to_testOverFragment&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt;&lt;/pre&gt;
Pero si la respuesta es correcta, debemos comprobar (dentro del bloque &lt;i&gt;if&lt;/i&gt; anterior) si se ha completado el test (3 aciertos seguidos) o no:&lt;br /&gt;
&lt;pre class=&quot;hl&quot;&gt;&lt;span class=&quot;hl kwa&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;questionIndex &lt;span class=&quot;hl opt&quot;&gt;&amp;lt;&lt;/span&gt; numQuestions&lt;span class=&quot;hl opt&quot;&gt;) {&lt;/span&gt; &lt;span class=&quot;hl slc&quot;&gt;// si true, continuar con la siguiente pregunta&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl opt&quot;&gt;...&lt;/span&gt;
&lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;hl kwa&quot;&gt;else&lt;/span&gt; &lt;span class=&quot;hl opt&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;hl slc&quot;&gt;// si false, test completado -&amp;gt; navegar a TestWonFragment&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; view&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;findNavController&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;().&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;navigate&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;R&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;id&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;action_testFragment_to_testWonFragment&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt;&lt;/pre&gt;
El sistema Android realiza un seguimiento de los destinos visitados por los usuarios en un dispositivo (cada vez que el usuario va a un nuevo destino, Android lo agrega a una pila posterior de destinos o &lt;i&gt;back stack&lt;/i&gt;). Y cuando se presiona sobre el botón Atrás del dispositivo, la aplicación accede al destino situado en la parte superior de esa pila, que por defecto es el último destino visitado. Pero podemos cambiar este funcionamiento para ajustar otro destino. Por ejemplo, en nuestra aplicación estaría bien que desde el fragmento TestOverFragment (fin del test), el botón Atrás sirviera para acceder a la pantalla de inicio de la aplicación (TitleFragment) en lugar de a las preguntas del test (TestFragment) como hace ahora.&lt;br /&gt;
&lt;br /&gt;
Vamos a tomar el control de la pila de destinos visitados. En concreto vamos a eliminar TestFragment de la pila para que cuando el usuario gane o pierda (TestWonFragment o TestOverFragment) y pulse el botón Atrás la aplicación no encuentre esos fragmentos y vuelva al fragmento de portada de la aplicación (TitleFragment).&lt;br /&gt;
&lt;br /&gt;
Para administrar esta pila debemos configurar el comportamiento de &quot;&lt;i&gt;pop&lt;/i&gt;&quot; para las acciones que conectan los fragmentos, lo cual admite diversos ajustes en sus atributos:&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;El atributo &lt;i&gt;popUpTo&lt;/i&gt; de una acción abre la pila a un destino determinado (los destinos se eliminan de la pila).&lt;/li&gt;
&lt;li&gt;Si el atributo &lt;i&gt;popUpToInclusive&lt;/i&gt; es &lt;i&gt;false&lt;/i&gt; o no está configurado, &lt;i&gt;popUpTo&lt;/i&gt; elimina los destinos hasta el destino especificado y lo deja en la pila posterior.&lt;/li&gt;
&lt;li&gt;Si &lt;i&gt;popUpToInclusive&lt;/i&gt; se establece como &lt;i&gt;true&lt;/i&gt;, el atributo &lt;i&gt;popUpTo&lt;/i&gt; elimina todos los destinos hasta el destino dado de la pila posterior.&lt;/li&gt;
&lt;li&gt;Si &lt;i&gt;popUpToInclusive&lt;/i&gt; es &lt;i&gt;true&lt;/i&gt; y &lt;i&gt;popUpTo&lt;/i&gt; está configurado en la ubicación de inicio de la aplicación, la acción elimina todos los destinos de la aplicación de la pila posterior, por lo que el botón Atrás saca al usuario de la aplicación.&lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;
Entonces, desde el gráfico de navegación, seleccionamos la acción (flecha) para navegar desde TestFragment a TestOverFragment, y en el panel de atributos ajustamos el atributo &lt;i&gt;Pop To&lt;/i&gt; a testFragment y activamos la casilla &lt;i&gt;Inclusive&lt;/i&gt; (&lt;i&gt;true&lt;/i&gt;). Podemos combrobar en el archivo xml (vista &lt;i&gt;Text&lt;/i&gt;) que se han agregado estos atributos:&lt;br /&gt;
&lt;pre class=&quot;hl&quot;&gt;app:&lt;span class=&quot;hl kwb&quot;&gt;popUpTo&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@+id/testFragment&quot;&lt;/span&gt;
app:&lt;span class=&quot;hl kwb&quot;&gt;popUpToInclusive&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;true&quot;&lt;/span&gt;&lt;/pre&gt;
Esto hace que el componente de navegación elimine los fragmentos de la pila posterior hasta TestFragment (inclusive). Lo mismo lo podríamos heber hecho ajustando el atributo &lt;i&gt;Pop To&lt;/i&gt; en titleFragment y desactivando &lt;i&gt;Inclusive&lt;/i&gt; (&lt;i&gt;false&lt;/i&gt;). Hacemos lo mismo para la acción de navegación desde TestFragment a TestWonFragment.&lt;br /&gt;
&lt;br /&gt;
Ejecutamos la aplicación en el emulador para comprobar que ahora el botón Atrás del dispositivo salta la pantalla de preguntas y llega hasta la pantalla de inicio desde cualquiera de las dos pantallas de resultados.&lt;br /&gt;
&lt;br /&gt;
Ahora vamos a darle funcionalidades a los botones &#39;Siguiente Test&#39; (TestWonFragment) e &#39;¿Interntarlo otra vez?&#39; (TestOverFragment) para que ambos accedan a las preguntas (TestFragment) y después, si el usuario presiona el botón Atrás no vuelva a TestWonFragment ni a TestOverFragment, sino a TitleFragment.&lt;br /&gt;
&lt;br /&gt;
En el gráfico de navegación añadimos una acción de navegación que conecte TestOverFragment con TestFragment (esta conexión la usará el botón). Y en el atributo &lt;i&gt;Pop To&lt;/i&gt; de esta acción ajustamos a titleFragment con Inclusive &lt;i&gt;false&lt;/i&gt; (una vez en TestFragment, el botón Atrás irá a TitleFragment).&lt;br /&gt;
&lt;br /&gt;
Repetimos para crear una nueva acción de navegación desde TestWonFragment a TestFragment y la configuramos igual:&lt;br /&gt;
&lt;br /&gt;
&lt;img border=&quot;0&quot; data-original-height=&quot;641&quot; data-original-width=&quot;738&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi1lNWizQ1ZGgnOjqsFn7cJ93envf8_HrEQVWX8eHku1V60Yd6HhpQPc4vc31JhE3tLDM_iXz77tHW7HGDjkyaJSxXryS9G5KN6y04hz09x4X-bi3TdaLi7PZAmUo3cC0YpJ9UE1gbAAV0/s1600/nav4.png&quot; /&gt;&lt;br /&gt;
&lt;br /&gt;
En el archivo TestOverFragment.kt, al final del método &lt;i&gt;onCreateView&lt;/i&gt;, antes del &lt;i&gt;return&lt;/i&gt;, escribimos un controlador de clics al botón:&lt;br /&gt;
&lt;pre class=&quot;hl&quot;&gt;binding&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;tryAgainButton&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;setOnClickListener &lt;span class=&quot;hl opt&quot;&gt;{&lt;/span&gt; view&lt;span class=&quot;hl opt&quot;&gt;:&lt;/span&gt; View &lt;span class=&quot;hl opt&quot;&gt;-&amp;gt;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; view&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;findNavController&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;().&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;navigate&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;R&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;id&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;action_testOverFragment_to_testFragment&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt;&lt;/pre&gt;
Repetimos en el archivo TestWonFragment para su botón:&lt;br /&gt;
&lt;pre class=&quot;hl&quot;&gt;binding&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;nextTestButton&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;setOnClickListener &lt;span class=&quot;hl opt&quot;&gt;{&lt;/span&gt; view&lt;span class=&quot;hl opt&quot;&gt;:&lt;/span&gt; View &lt;span class=&quot;hl opt&quot;&gt;-&amp;gt;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; view&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;findNavController&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;().&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;navigate&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;R&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;id&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;action_testWonFragment_to_testFragment&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt;&lt;/pre&gt;
Ejecutamos para comprobar que funciona. Hasta aquí esta entrada donde hemos repasado la creación de fragmentos y hemos aprendido a navegar entre ellos. En una próxima entrega seguiremos trabajando con esta aplicación para añadir un botón en la barra de la aplicación que nos ayudará a navegar por la aplicación, y un menú de opciones y un cajón de navegación para ir a los fragmentos Info y About.&lt;br /&gt;
&lt;br /&gt;
A continuación se muestran los archivos más importantes relativos a las actividades, fragmentos y el recurso de navegación de la aplicación:&lt;br /&gt;
&lt;pre class=&quot;hl&quot;&gt;&lt;span class=&quot;hl slc&quot;&gt;// MainActivity.kt&lt;/span&gt;
&lt;span class=&quot;hl kwa&quot;&gt;package&lt;/span&gt; com&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;android&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;testci

&lt;span class=&quot;hl kwa&quot;&gt;import&lt;/span&gt; android&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;os&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;Bundle
&lt;span class=&quot;hl kwa&quot;&gt;import&lt;/span&gt; androidx&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;appcompat&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;app&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;AppCompatActivity
&lt;span class=&quot;hl kwa&quot;&gt;import&lt;/span&gt; androidx&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;databinding&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;DataBindingUtil
&lt;span class=&quot;hl kwa&quot;&gt;import&lt;/span&gt; com&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;android&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;testci&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;databinding&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;ActivityMainBinding

&lt;span class=&quot;hl kwa&quot;&gt;class&lt;/span&gt; MainActivity &lt;span class=&quot;hl opt&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;AppCompatActivity&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;() {&lt;/span&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;override fun&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;onCreate&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;savedInstanceState&lt;span class=&quot;hl opt&quot;&gt;:&lt;/span&gt; Bundle?&lt;span class=&quot;hl opt&quot;&gt;) {&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;super&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;onCreate&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;savedInstanceState&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;val&lt;/span&gt; binding &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; DataBindingUtil&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;setContentView&lt;span class=&quot;hl opt&quot;&gt;&amp;lt;&lt;/span&gt;ActivityMainBinding&lt;span class=&quot;hl opt&quot;&gt;&amp;gt;(&lt;/span&gt;&lt;span class=&quot;hl kwa&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; R&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;layout&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;activity_main&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt;&lt;/pre&gt;
&lt;pre class=&quot;hl&quot;&gt;&lt;span class=&quot;hl com&quot;&gt;&amp;lt;!-- layout/activity_main.xml --&amp;gt;&lt;/span&gt;
&lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;?xml&lt;/span&gt; &lt;span class=&quot;hl kwb&quot;&gt;version&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;1.0&quot;&lt;/span&gt; &lt;span class=&quot;hl kwb&quot;&gt;encoding&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;utf-8&quot;&lt;/span&gt;&lt;span class=&quot;hl kwa&quot;&gt;?&amp;gt;&lt;/span&gt;

&lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;layout&lt;/span&gt; xmlns:&lt;span class=&quot;hl kwb&quot;&gt;android&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;http://schemas.android.com/apk/res/android&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; xmlns:&lt;span class=&quot;hl kwb&quot;&gt;app&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;http://schemas.android.com/apk/res-auto&quot;&lt;/span&gt;&lt;span class=&quot;hl kwa&quot;&gt;&amp;gt;&lt;/span&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;LinearLayout&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_width&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;match_parent&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_height&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;match_parent&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;orientation&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;vertical&quot;&lt;/span&gt;&lt;span class=&quot;hl kwa&quot;&gt;&amp;gt;&lt;/span&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;fragment&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;id&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@+id/myNavHostFragment&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;name&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;androidx.navigation.fragment.NavHostFragment&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_width&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;match_parent&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_height&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;match_parent&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; app:&lt;span class=&quot;hl kwb&quot;&gt;defaultNavHost&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;true&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; app:&lt;span class=&quot;hl kwb&quot;&gt;navGraph&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@navigation/navigation&quot;&lt;/span&gt; &lt;span class=&quot;hl kwa&quot;&gt;/&amp;gt;&lt;/span&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;/LinearLayout&amp;gt;&lt;/span&gt;

&lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;/layout&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;pre class=&quot;hl&quot;&gt;&lt;span class=&quot;hl slc&quot;&gt;// TitleFragment.kt&lt;/span&gt;
&lt;span class=&quot;hl kwa&quot;&gt;package&lt;/span&gt; com&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;android&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;testci

&lt;span class=&quot;hl kwa&quot;&gt;import&lt;/span&gt; android&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;os&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;Bundle
&lt;span class=&quot;hl kwa&quot;&gt;import&lt;/span&gt; android&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;view&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;LayoutInflater
&lt;span class=&quot;hl kwa&quot;&gt;import&lt;/span&gt; android&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;view&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;View
&lt;span class=&quot;hl kwa&quot;&gt;import&lt;/span&gt; android&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;view&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;ViewGroup
&lt;span class=&quot;hl kwa&quot;&gt;import&lt;/span&gt; androidx&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;databinding&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;DataBindingUtil
&lt;span class=&quot;hl kwa&quot;&gt;import&lt;/span&gt; androidx&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;fragment&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;app&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;Fragment
&lt;span class=&quot;hl kwa&quot;&gt;import&lt;/span&gt; androidx&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;navigation&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;findNavController
&lt;span class=&quot;hl kwa&quot;&gt;import&lt;/span&gt; com&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;android&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;testci&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;databinding&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;FragmentTitleBinding

&lt;span class=&quot;hl kwa&quot;&gt;class&lt;/span&gt; TitleFragment &lt;span class=&quot;hl opt&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;Fragment&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;() {&lt;/span&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;override fun&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;onCreateView&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; inflater&lt;span class=&quot;hl opt&quot;&gt;:&lt;/span&gt; LayoutInflater&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; container&lt;span class=&quot;hl opt&quot;&gt;:&lt;/span&gt; ViewGroup?&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; savedInstanceState&lt;span class=&quot;hl opt&quot;&gt;:&lt;/span&gt; Bundle?
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl opt&quot;&gt;):&lt;/span&gt; View? &lt;span class=&quot;hl opt&quot;&gt;{&lt;/span&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;val&lt;/span&gt; binding &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; DataBindingUtil&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;inflate&lt;span class=&quot;hl opt&quot;&gt;&amp;lt;&lt;/span&gt;FragmentTitleBinding&lt;span class=&quot;hl opt&quot;&gt;&amp;gt;(&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; inflater&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; R&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;layout&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;fragment_title&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; container&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;hl kwa&quot;&gt;false&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; binding&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;playButton&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;setOnClickListener &lt;span class=&quot;hl opt&quot;&gt;{&lt;/span&gt; view&lt;span class=&quot;hl opt&quot;&gt;:&lt;/span&gt; View &lt;span class=&quot;hl opt&quot;&gt;-&amp;gt;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; view&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;findNavController&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;().&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;navigate&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;R&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;id&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;action_titleFragment_to_testFragment&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;return&lt;/span&gt; binding&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;root
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt;&lt;/pre&gt;
&lt;pre class=&quot;hl&quot;&gt;&lt;span class=&quot;hl com&quot;&gt;&amp;lt;!-- layout/fragment_title.xml --&amp;gt;&lt;/span&gt;
&lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;?xml&lt;/span&gt; &lt;span class=&quot;hl kwb&quot;&gt;version&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;1.0&quot;&lt;/span&gt; &lt;span class=&quot;hl kwb&quot;&gt;encoding&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;utf-8&quot;&lt;/span&gt;&lt;span class=&quot;hl kwa&quot;&gt;?&amp;gt;&lt;/span&gt;

&lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;layout&lt;/span&gt; xmlns:&lt;span class=&quot;hl kwb&quot;&gt;android&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;http://schemas.android.com/apk/res/android&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; xmlns:&lt;span class=&quot;hl kwb&quot;&gt;app&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;http://schemas.android.com/apk/res-auto&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; xmlns:&lt;span class=&quot;hl kwb&quot;&gt;tools&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;http://schemas.android.com/tools&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; tools:&lt;span class=&quot;hl kwb&quot;&gt;context&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;com.android.testci.TitleFragment&quot;&lt;/span&gt;&lt;span class=&quot;hl kwa&quot;&gt;&amp;gt;&lt;/span&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;androidx&lt;/span&gt;.constraintlayout.widget.ConstraintLayout
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;id&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@+id/titleConstraint&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_width&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;match_parent&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_height&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;match_parent&quot;&lt;/span&gt;&lt;span class=&quot;hl kwa&quot;&gt;&amp;gt;&lt;/span&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;ImageView&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;id&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@+id/titleImage&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_width&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;0dp&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_height&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;0dp&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_marginStart&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@dimen/horizontal_margin&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_marginEnd&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@dimen/horizontal_margin&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;scaleType&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;fitCenter&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; app:&lt;span class=&quot;hl kwb&quot;&gt;layout_constraintBottom_toTopOf&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@+id/textView&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; app:&lt;span class=&quot;hl kwb&quot;&gt;layout_constraintEnd_toEndOf&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;parent&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; app:&lt;span class=&quot;hl kwb&quot;&gt;layout_constraintHorizontal_bias&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;1.0&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; app:&lt;span class=&quot;hl kwb&quot;&gt;layout_constraintStart_toStartOf&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;parent&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; app:&lt;span class=&quot;hl kwb&quot;&gt;layout_constraintTop_toTopOf&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;parent&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; app:&lt;span class=&quot;hl kwb&quot;&gt;srcCompat&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@drawable/ic_mid_mapping&quot;&lt;/span&gt; &lt;span class=&quot;hl kwa&quot;&gt;/&amp;gt;&lt;/span&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;TextView&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;id&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@+id/textView&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_width&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;wrap_content&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_height&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;wrap_content&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;paddingLeft&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@dimen/horizontal_margin&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;paddingRight&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@dimen/horizontal_margin&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;text&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@string/test&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;textAllCaps&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;false&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;textColor&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@color/azul&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;textSize&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@dimen/titulo&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;textStyle&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;bold&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; app:&lt;span class=&quot;hl kwb&quot;&gt;layout_constraintBaseline_toBaselineOf&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@+id/textView2&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; app:&lt;span class=&quot;hl kwb&quot;&gt;layout_constraintEnd_toStartOf&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@+id/textView2&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; app:&lt;span class=&quot;hl kwb&quot;&gt;layout_constraintHorizontal_chainStyle&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;packed&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; app:&lt;span class=&quot;hl kwb&quot;&gt;layout_constraintStart_toStartOf&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;parent&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; app:&lt;span class=&quot;hl kwb&quot;&gt;layout_constraintTop_toBottomOf&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@+id/titleImage&quot;&lt;/span&gt; &lt;span class=&quot;hl kwa&quot;&gt;/&amp;gt;&lt;/span&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;TextView&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;id&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@+id/textView2&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_width&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;wrap_content&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_height&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;wrap_content&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_marginBottom&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;32dp&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;paddingLeft&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@dimen/horizontal_margin&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;paddingRight&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@dimen/horizontal_margin&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;text&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@string/ci&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;textColor&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@color/rosa&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;textSize&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@dimen/titulo&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;textStyle&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;bold&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; app:&lt;span class=&quot;hl kwb&quot;&gt;layout_constraintBottom_toTopOf&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@+id/playButton&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; app:&lt;span class=&quot;hl kwb&quot;&gt;layout_constraintEnd_toEndOf&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;parent&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; app:&lt;span class=&quot;hl kwb&quot;&gt;layout_constraintStart_toEndOf&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@+id/textView&quot;&lt;/span&gt; &lt;span class=&quot;hl kwa&quot;&gt;/&amp;gt;&lt;/span&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;Button&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;id&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@+id/playButton&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_width&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;wrap_content&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_height&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;wrap_content&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_marginStart&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@dimen/horizontal_margin&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_marginTop&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;32dp&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_marginEnd&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@dimen/horizontal_margin&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_marginBottom&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;32dp&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;paddingStart&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@dimen/button_padding&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;paddingEnd&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@dimen/button_padding&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;text&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@string/start&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;textColor&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@color/colorAccent&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;textSize&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@dimen/button_text_size&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;textStyle&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;bold&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; app:&lt;span class=&quot;hl kwb&quot;&gt;layout_constraintBottom_toBottomOf&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;parent&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; app:&lt;span class=&quot;hl kwb&quot;&gt;layout_constraintEnd_toEndOf&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;parent&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; app:&lt;span class=&quot;hl kwb&quot;&gt;layout_constraintStart_toStartOf&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;parent&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; app:&lt;span class=&quot;hl kwb&quot;&gt;layout_constraintTop_toBottomOf&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@+id/textView&quot;&lt;/span&gt; &lt;span class=&quot;hl kwa&quot;&gt;/&amp;gt;&lt;/span&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;/androidx&lt;/span&gt;.constraintlayout.widget.ConstraintLayout&lt;span class=&quot;hl kwa&quot;&gt;&amp;gt;&lt;/span&gt;
&lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;/layout&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;pre class=&quot;hl&quot;&gt;&lt;span class=&quot;hl slc&quot;&gt;// TestFragment.kt&lt;/span&gt;
&lt;span class=&quot;hl kwa&quot;&gt;package&lt;/span&gt; com&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;android&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;testci

&lt;span class=&quot;hl kwa&quot;&gt;import&lt;/span&gt; android&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;os&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;Bundle
&lt;span class=&quot;hl kwa&quot;&gt;import&lt;/span&gt; android&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;view&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;LayoutInflater
&lt;span class=&quot;hl kwa&quot;&gt;import&lt;/span&gt; android&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;view&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;View
&lt;span class=&quot;hl kwa&quot;&gt;import&lt;/span&gt; android&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;view&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;ViewGroup
&lt;span class=&quot;hl kwa&quot;&gt;import&lt;/span&gt; androidx&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;appcompat&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;app&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;AppCompatActivity
&lt;span class=&quot;hl kwa&quot;&gt;import&lt;/span&gt; androidx&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;databinding&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;DataBindingUtil
&lt;span class=&quot;hl kwa&quot;&gt;import&lt;/span&gt; androidx&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;fragment&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;app&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;Fragment
&lt;span class=&quot;hl kwa&quot;&gt;import&lt;/span&gt; androidx&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;navigation&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;findNavController
&lt;span class=&quot;hl kwa&quot;&gt;import&lt;/span&gt; com&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;android&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;testci&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;databinding&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;FragmentTestBinding

&lt;span class=&quot;hl kwa&quot;&gt;class&lt;/span&gt; TestFragment &lt;span class=&quot;hl opt&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;Fragment&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;() {&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; data &lt;span class=&quot;hl kwa&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;Question&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;val&lt;/span&gt; text&lt;span class=&quot;hl opt&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;hl kwb&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;val&lt;/span&gt; answers&lt;span class=&quot;hl opt&quot;&gt;:&lt;/span&gt; List&lt;span class=&quot;hl opt&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl kwb&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;&amp;gt;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl slc&quot;&gt;// Lista de Question (pregunta y lista de respuestas)&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl slc&quot;&gt;// La primera respuesta es la correcta y después se presentan de manera aleatoria&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;private val&lt;/span&gt; questions&lt;span class=&quot;hl opt&quot;&gt;:&lt;/span&gt; MutableList&lt;span class=&quot;hl opt&quot;&gt;&amp;lt;&lt;/span&gt;Question&lt;span class=&quot;hl opt&quot;&gt;&amp;gt; =&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;mutableListOf&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwd&quot;&gt;Question&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; text &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;hl str&quot;&gt;&quot;¿Cuál de las siguientes palabras no encaja con el resto?&quot;&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; answers &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;listOf&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl str&quot;&gt;&quot;Ordenanza&quot;&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;hl str&quot;&gt;&quot;Escriba&quot;&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;hl str&quot;&gt;&quot;Secretario&quot;&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;hl str&quot;&gt;&quot;Amanuense&quot;&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;hl str&quot;&gt;&quot;Copista&quot;&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl opt&quot;&gt;),&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwd&quot;&gt;Question&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; text &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;hl str&quot;&gt;&quot;Complete la analogía: ENOJO es a CALMA como ENFURECER a&quot;&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; answers &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;listOf&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl str&quot;&gt;&quot;Apaciguar&quot;&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;hl str&quot;&gt;&quot;Descansar&quot;&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;hl str&quot;&gt;&quot;Despertar&quot;&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;hl str&quot;&gt;&quot;Marear&quot;&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;hl str&quot;&gt;&quot;Alterar&quot;&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl opt&quot;&gt;),&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwd&quot;&gt;Question&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; text &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;hl str&quot;&gt;&quot;Al lanzar dos dados ¿cuál es la probabilidad de que las caras orientadas hacia arriba sumen un total de 6 en dos ocasiones consecutivas?&lt;/span&gt;&lt;span class=&quot;hl esc&quot;&gt;\n&lt;/span&gt;&lt;span class=&quot;hl str&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; answers &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;listOf&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl str&quot;&gt;&quot;25/1296&quot;&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;hl str&quot;&gt;&quot;8/1296&quot;&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;hl str&quot;&gt;&quot;10/1296&quot;&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;hl str&quot;&gt;&quot;16/1296&quot;&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;hl str&quot;&gt;&quot;36/1296&quot;&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl opt&quot;&gt;),&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwd&quot;&gt;Question&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; text &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;hl str&quot;&gt;&quot;El nieto de mis padres es uno de mis sobrinos y tengo tres sobrinos más que no son hermanos entre sí. Como mínimo ¿cuántos hijos e hijas tienen mis padres? (asumiendo que nadie ha muerto)&quot;&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; answers &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;listOf&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl str&quot;&gt;&quot;Cuatro&quot;&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;hl str&quot;&gt;&quot;Dos&quot;&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;hl str&quot;&gt;&quot;Tres&quot;&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;hl str&quot;&gt;&quot;Cinco&quot;&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;hl str&quot;&gt;&quot;No hay datos suficientes para saberlo&quot;&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl opt&quot;&gt;),&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwd&quot;&gt;Question&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; text &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;hl str&quot;&gt;&quot;¿Cuántos múltiplos de 4 hay entre 1000 y 2000 inclusives?&quot;&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; answers &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;listOf&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl str&quot;&gt;&quot;251&quot;&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;hl str&quot;&gt;&quot;300&quot;&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;hl str&quot;&gt;&quot;500&quot;&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;hl str&quot;&gt;&quot;204&quot;&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;hl str&quot;&gt;&quot;164&quot;&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl opt&quot;&gt;),&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwd&quot;&gt;Question&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; text &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;hl str&quot;&gt;&quot;Dibujando sobre un papel un cuadrado y dos triángulos ¿cuántas áreas pueden delimitarse?. Dicho de otro modo, ¿cuál es el número máximo de parcelas que pueden delimitarse en un prado con una cerca de alambre cuadrada y dos triangulares?&quot;&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; answers &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;listOf&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl str&quot;&gt;&quot;19&quot;&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;hl str&quot;&gt;&quot;7&quot;&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;hl str&quot;&gt;&quot;11&quot;&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;hl str&quot;&gt;&quot;15&quot;&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;hl str&quot;&gt;&quot;24&quot;&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl opt&quot;&gt;),&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwd&quot;&gt;Question&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; text &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;hl str&quot;&gt;&quot;Encuentre el número que completa esta serie lógica: 3, 5, 10, 24, 65, ?&quot;&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; answers &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;listOf&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl str&quot;&gt;&quot;187&quot;&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;hl str&quot;&gt;&quot;174&quot;&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;hl str&quot;&gt;&quot;201&quot;&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;hl str&quot;&gt;&quot;123&quot;&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;hl str&quot;&gt;&quot;130&quot;&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl opt&quot;&gt;),&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwd&quot;&gt;Question&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; text &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;hl str&quot;&gt;&quot;Complete la analogía: DESDEÑOSO es a DESPECTIVO como ALTIVO es a&quot;&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; answers &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;listOf&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl str&quot;&gt;&quot;Soberbio&quot;&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;hl str&quot;&gt;&quot;Estrafalario&quot;&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;hl str&quot;&gt;&quot;Arreglado&quot;&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;hl str&quot;&gt;&quot;Negativo&quot;&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;hl str&quot;&gt;&quot;Positivo&quot;&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl opt&quot;&gt;),&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwd&quot;&gt;Question&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; text &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;hl str&quot;&gt;&quot;¿Si el hijo de Marmaduke es el padre de mi hijo, ¿qué parentesco tengo yo con Marmaduke?&quot;&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; answers &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;listOf&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl str&quot;&gt;&quot;Su hijo&quot;&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;hl str&quot;&gt;&quot;Soy su abuelo&quot;&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;hl str&quot;&gt;&quot;Su padre&quot;&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;hl str&quot;&gt;&quot;Su nieto&quot;&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;hl str&quot;&gt;&quot;Yo soy Marmaduke&quot;&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl opt&quot;&gt;),&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwd&quot;&gt;Question&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; text &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;hl str&quot;&gt;&quot;En una hilera de cuatro casas, los Brown viven al lado de los Smith pero no al lado de los Bruce. Si los Bruce no viven al lado de los Jones, ¿quiénes son los vecinos inmediatos de los Jones?&quot;&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; answers &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;listOf&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl str&quot;&gt;&quot;Los Brown&quot;&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;hl str&quot;&gt;&quot;Los Smith&quot;&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;hl str&quot;&gt;&quot;Los Brown y los Smith&quot;&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;hl str&quot;&gt;&quot;Es imposible averiguarlo&quot;&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;hl str&quot;&gt;&quot;Ninguno de los anteriores&quot;&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;private&lt;/span&gt; lateinit &lt;span class=&quot;hl kwa&quot;&gt;var&lt;/span&gt; binding&lt;span class=&quot;hl opt&quot;&gt;:&lt;/span&gt; FragmentTestBinding
&amp;nbsp;&amp;nbsp;&amp;nbsp; lateinit &lt;span class=&quot;hl kwa&quot;&gt;var&lt;/span&gt; currentQuestion&lt;span class=&quot;hl opt&quot;&gt;:&lt;/span&gt; Question
&amp;nbsp;&amp;nbsp;&amp;nbsp; lateinit &lt;span class=&quot;hl kwa&quot;&gt;var&lt;/span&gt; answers&lt;span class=&quot;hl opt&quot;&gt;:&lt;/span&gt; MutableList&lt;span class=&quot;hl opt&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;hl kwb&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;&amp;gt;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;private var&lt;/span&gt; questionIndex &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;hl num&quot;&gt;0&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;private val&lt;/span&gt; numQuestions &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; Math&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;min&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;((&lt;/span&gt;questions&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;size &lt;span class=&quot;hl opt&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;hl num&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;) /&lt;/span&gt; &lt;span class=&quot;hl num&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;hl num&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;override fun&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;onCreateView&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; inflater&lt;span class=&quot;hl opt&quot;&gt;:&lt;/span&gt; LayoutInflater&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; container&lt;span class=&quot;hl opt&quot;&gt;:&lt;/span&gt; ViewGroup?&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; savedInstanceState&lt;span class=&quot;hl opt&quot;&gt;:&lt;/span&gt; Bundle?
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl opt&quot;&gt;):&lt;/span&gt; View? &lt;span class=&quot;hl opt&quot;&gt;{&lt;/span&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; binding &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; DataBindingUtil&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;inflate&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; inflater&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; R&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;layout&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;fragment_test&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; container&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;hl kwa&quot;&gt;false&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl slc&quot;&gt;// Mezcla las preguntas y determina el índice de la primera pregunta en la lista de preguntas&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwd&quot;&gt;randomizeQuestions&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;()&lt;/span&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; binding&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;test &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;hl kwa&quot;&gt;this&lt;/span&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; binding&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;submitButton&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;setOnClickListener &lt;span class=&quot;hl kwc&quot;&gt;@Suppress&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl str&quot;&gt;&quot;UNUSED_ANONYMOUS_PARAMETER&quot;&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl opt&quot;&gt;{&lt;/span&gt; view&lt;span class=&quot;hl opt&quot;&gt;:&lt;/span&gt; View &lt;span class=&quot;hl opt&quot;&gt;-&amp;gt;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;val&lt;/span&gt; checkedId &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; binding&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;questionRadioGroup&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;checkedRadioButtonId
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;hl opt&quot;&gt;(-&lt;/span&gt;&lt;span class=&quot;hl num&quot;&gt;1&lt;/span&gt; &lt;span class=&quot;hl opt&quot;&gt;!=&lt;/span&gt; checkedId&lt;span class=&quot;hl opt&quot;&gt;) {&lt;/span&gt;&amp;nbsp; &lt;span class=&quot;hl slc&quot;&gt;// no hace nada si ninguna opción está activada&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;var&lt;/span&gt; answerIndex &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;hl num&quot;&gt;0&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;when&lt;/span&gt; &lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;checkedId&lt;span class=&quot;hl opt&quot;&gt;) {&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; R&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;id&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;secondAnswerRadioButton &lt;span class=&quot;hl opt&quot;&gt;-&amp;gt;&lt;/span&gt; answerIndex &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;hl num&quot;&gt;1&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; R&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;id&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;thirdAnswerRadioButton &lt;span class=&quot;hl opt&quot;&gt;-&amp;gt;&lt;/span&gt; answerIndex &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;hl num&quot;&gt;2&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; R&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;id&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;fourthAnswerRadioButton &lt;span class=&quot;hl opt&quot;&gt;-&amp;gt;&lt;/span&gt; answerIndex &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;hl num&quot;&gt;3&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; R&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;id&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;fiveAnswerRadioButton &lt;span class=&quot;hl opt&quot;&gt;-&amp;gt;&lt;/span&gt; answerIndex &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;hl num&quot;&gt;4&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;answers&lt;span class=&quot;hl opt&quot;&gt;[&lt;/span&gt;answerIndex&lt;span class=&quot;hl opt&quot;&gt;] ==&lt;/span&gt; currentQuestion&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;answers&lt;span class=&quot;hl opt&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;hl num&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;]) {&lt;/span&gt;&amp;nbsp; &lt;span class=&quot;hl slc&quot;&gt;// si true: respuesta correcta&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; questionIndex&lt;span class=&quot;hl opt&quot;&gt;++&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;questionIndex &lt;span class=&quot;hl opt&quot;&gt;&amp;lt;&lt;/span&gt; numQuestions&lt;span class=&quot;hl opt&quot;&gt;) {&lt;/span&gt;&amp;nbsp; &lt;span class=&quot;hl slc&quot;&gt;// si true: siguiente pregunta&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; currentQuestion &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; questions&lt;span class=&quot;hl opt&quot;&gt;[&lt;/span&gt;questionIndex&lt;span class=&quot;hl opt&quot;&gt;]&lt;/span&gt;&amp;nbsp; &lt;span class=&quot;hl slc&quot;&gt;// siguiente pregunta&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwd&quot;&gt;setQuestion&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;()&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; binding&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;invalidateAll&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;()&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;hl kwa&quot;&gt;else&lt;/span&gt; &lt;span class=&quot;hl opt&quot;&gt;{&lt;/span&gt;&amp;nbsp; &lt;span class=&quot;hl slc&quot;&gt;// tres respuestas correctas: navegar a testWonFragment&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; view&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;findNavController&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;().&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;navigate&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;R&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;id&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;action_testFragment_to_testWonFragment&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;hl kwa&quot;&gt;else&lt;/span&gt; &lt;span class=&quot;hl opt&quot;&gt;{&lt;/span&gt;&amp;nbsp; &lt;span class=&quot;hl slc&quot;&gt;// error de respuesta: navegar a testOverFragment&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; view&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;findNavController&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;().&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;navigate&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;R&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;id&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;action_testFragment_to_testOverFragment&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;return&lt;/span&gt; binding&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;root
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;private fun&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;randomizeQuestions&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;() {&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; questions&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;shuffle&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;()&lt;/span&gt;&amp;nbsp; &lt;span class=&quot;hl slc&quot;&gt;// mezcla la lista&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; questionIndex &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;hl num&quot;&gt;0&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwd&quot;&gt;setQuestion&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;()&lt;/span&gt;&amp;nbsp; &lt;span class=&quot;hl slc&quot;&gt;// obtiene una pregunta y mezcla sus respuestas&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;private fun&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;setQuestion&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;() {&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; binding&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;questionRadioGroup&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;clearCheck&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;()&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; currentQuestion &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; questions&lt;span class=&quot;hl opt&quot;&gt;[&lt;/span&gt;questionIndex&lt;span class=&quot;hl opt&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;hl slc&quot;&gt;// selecciona la Question&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; answers &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; currentQuestion&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;answers&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;toMutableList&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;()&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; answers&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;shuffle&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;()&lt;/span&gt;&amp;nbsp; &lt;span class=&quot;hl slc&quot;&gt;// y mezcla sus respuestas&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;activity &lt;span class=&quot;hl kwa&quot;&gt;as&lt;/span&gt; AppCompatActivity&lt;span class=&quot;hl opt&quot;&gt;).&lt;/span&gt;supportActionBar?&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;title &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwd&quot;&gt;getString&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;R&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;string&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;title_android_testci_question&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; questionIndex &lt;span class=&quot;hl opt&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;hl num&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; numQuestions&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt;&lt;/pre&gt;
&lt;pre class=&quot;hl&quot;&gt;&lt;span class=&quot;hl com&quot;&gt;&amp;lt;!-- layout/fragment_test.xml --&amp;gt;&lt;/span&gt;
&lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;?xml&lt;/span&gt; &lt;span class=&quot;hl kwb&quot;&gt;version&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;1.0&quot;&lt;/span&gt; &lt;span class=&quot;hl kwb&quot;&gt;encoding&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;utf-8&quot;&lt;/span&gt;&lt;span class=&quot;hl kwa&quot;&gt;?&amp;gt;&lt;/span&gt;

&lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;layout&lt;/span&gt; xmlns:&lt;span class=&quot;hl kwb&quot;&gt;android&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;http://schemas.android.com/apk/res/android&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; xmlns:&lt;span class=&quot;hl kwb&quot;&gt;app&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;http://schemas.android.com/apk/res-auto&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; xmlns:&lt;span class=&quot;hl kwb&quot;&gt;tools&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;http://schemas.android.com/tools&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; tools:&lt;span class=&quot;hl kwb&quot;&gt;context&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;com.example.android.navigation.InGame&quot;&lt;/span&gt;&lt;span class=&quot;hl kwa&quot;&gt;&amp;gt;&lt;/span&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;data&amp;gt;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;variable&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwb&quot;&gt;name&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;test&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwb&quot;&gt;type&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;com.android.testci.TestFragment&quot;&lt;/span&gt; &lt;span class=&quot;hl kwa&quot;&gt;/&amp;gt;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;/data&amp;gt;&lt;/span&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;ScrollView&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_width&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;match_parent&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_height&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;match_parent&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;fillViewport&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;true&quot;&lt;/span&gt;&lt;span class=&quot;hl kwa&quot;&gt;&amp;gt;&lt;/span&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;androidx&lt;/span&gt;.constraintlayout.widget.ConstraintLayout
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;id&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@+id/frameLayout&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_width&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;match_parent&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_height&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;wrap_content&quot;&lt;/span&gt;&lt;span class=&quot;hl kwa&quot;&gt;&amp;gt;&lt;/span&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;ImageView&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;id&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@+id/questionImage&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_width&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;0dp&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_height&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@dimen/image_header_height_min&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_marginStart&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@dimen/horizontal_margin&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_marginTop&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@dimen/vertical_margin&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_marginEnd&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@dimen/horizontal_margin&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_marginBottom&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@dimen/vertical_margin&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;scaleType&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;fitCenter&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; app:&lt;span class=&quot;hl kwb&quot;&gt;layout_constraintBottom_toTopOf&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@+id/questionText&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; app:&lt;span class=&quot;hl kwb&quot;&gt;layout_constraintEnd_toEndOf&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;parent&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; app:&lt;span class=&quot;hl kwb&quot;&gt;layout_constraintStart_toStartOf&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;parent&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; app:&lt;span class=&quot;hl kwb&quot;&gt;layout_constraintTop_toTopOf&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;parent&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; app:&lt;span class=&quot;hl kwb&quot;&gt;layout_constraintVertical_chainStyle&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;packed&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; app:&lt;span class=&quot;hl kwb&quot;&gt;srcCompat&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@drawable/ic_preguntas&quot;&lt;/span&gt; &lt;span class=&quot;hl kwa&quot;&gt;/&amp;gt;&lt;/span&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;TextView&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;id&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@+id/questionText&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_width&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;0dp&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_height&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;wrap_content&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_marginStart&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@dimen/question_horizontal_margin&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_marginTop&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@dimen/vertical_margin&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_marginEnd&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@dimen/question_horizontal_margin&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;fontFamily&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;sans-serif&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;text&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@{test.currentQuestion.text}&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;textSize&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@dimen/question_size&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;textStyle&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;bold&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;typeface&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;normal&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; app:&lt;span class=&quot;hl kwb&quot;&gt;layout_constraintEnd_toEndOf&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;parent&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; app:&lt;span class=&quot;hl kwb&quot;&gt;layout_constraintStart_toStartOf&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;parent&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; app:&lt;span class=&quot;hl kwb&quot;&gt;layout_constraintTop_toBottomOf&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@+id/questionImage&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; tools:&lt;span class=&quot;hl kwb&quot;&gt;text&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;¿Qué número sigue en la siguiente serie?\n9, 16, 25, 36 ...&amp;nbsp; &quot;&lt;/span&gt; &lt;span class=&quot;hl kwa&quot;&gt;/&amp;gt;&lt;/span&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;RadioGroup&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;id&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@+id/questionRadioGroup&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_width&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;0dp&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_height&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;wrap_content&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_marginStart&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@dimen/question_horizontal_margin&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_marginTop&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@dimen/vertical_margin&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_marginEnd&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@dimen/question_horizontal_margin&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;animateLayoutChanges&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;true&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;orientation&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;vertical&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; app:&lt;span class=&quot;hl kwb&quot;&gt;layout_constraintEnd_toEndOf&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;parent&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; app:&lt;span class=&quot;hl kwb&quot;&gt;layout_constraintStart_toStartOf&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;parent&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; app:&lt;span class=&quot;hl kwb&quot;&gt;layout_constraintTop_toBottomOf&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@+id/questionText&quot;&lt;/span&gt;&lt;span class=&quot;hl kwa&quot;&gt;&amp;gt;&lt;/span&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;RadioButton&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;id&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@+id/firstAnswerRadioButton&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_width&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;match_parent&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_height&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;wrap_content&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_marginBottom&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@dimen/question_vertical_margin&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;checked&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;true&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;text&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@{test.answers[0]}&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;textSize&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@dimen/answer_text_size&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; tools:&lt;span class=&quot;hl kwb&quot;&gt;text&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;42&quot;&lt;/span&gt; &lt;span class=&quot;hl kwa&quot;&gt;/&amp;gt;&lt;/span&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;RadioButton&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;id&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@+id/secondAnswerRadioButton&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_width&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;match_parent&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_height&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;wrap_content&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_marginBottom&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@dimen/question_vertical_margin&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;text&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@{test.answers[1]}&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;textSize&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@dimen/answer_text_size&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; tools:&lt;span class=&quot;hl kwb&quot;&gt;text&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;49&quot;&lt;/span&gt; &lt;span class=&quot;hl kwa&quot;&gt;/&amp;gt;&lt;/span&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;RadioButton&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;id&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@+id/thirdAnswerRadioButton&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_width&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;match_parent&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_height&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;wrap_content&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_marginBottom&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@dimen/question_vertical_margin&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;text&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@{test.answers[2]}&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;textSize&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@dimen/answer_text_size&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; tools:&lt;span class=&quot;hl kwb&quot;&gt;text&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;51&quot;&lt;/span&gt; &lt;span class=&quot;hl kwa&quot;&gt;/&amp;gt;&lt;/span&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;RadioButton&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;id&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@+id/fourthAnswerRadioButton&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_width&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;match_parent&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_height&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;wrap_content&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_marginBottom&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@dimen/question_vertical_margin&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;text&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@{test.answers[3]}&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;textSize&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@dimen/answer_text_size&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; tools:&lt;span class=&quot;hl kwb&quot;&gt;text&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;54&quot;&lt;/span&gt; &lt;span class=&quot;hl kwa&quot;&gt;/&amp;gt;&lt;/span&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;RadioButton&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;id&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@+id/fiveAnswerRadioButton&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_width&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;match_parent&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_height&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;wrap_content&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_marginBottom&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@dimen/question_vertical_margin&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;text&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@{test.answers[4]}&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;textSize&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@dimen/answer_text_size&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; tools:&lt;span class=&quot;hl kwb&quot;&gt;text&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;Ninguna de las anteriores&quot;&lt;/span&gt; &lt;span class=&quot;hl kwa&quot;&gt;/&amp;gt;&lt;/span&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;/RadioGroup&amp;gt;&lt;/span&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;Button&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;id&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@+id/submitButton&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_width&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;wrap_content&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_height&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;wrap_content&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_marginStart&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@dimen/question_horizontal_margin&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_marginTop&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@dimen/vertical_margin&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_marginEnd&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@dimen/question_horizontal_margin&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;text&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@string/respoder&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;textSize&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@dimen/button_text_size&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; app:&lt;span class=&quot;hl kwb&quot;&gt;layout_constraintEnd_toEndOf&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;parent&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; app:&lt;span class=&quot;hl kwb&quot;&gt;layout_constraintStart_toStartOf&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;parent&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; app:&lt;span class=&quot;hl kwb&quot;&gt;layout_constraintTop_toBottomOf&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@+id/questionRadioGroup&quot;&lt;/span&gt; &lt;span class=&quot;hl kwa&quot;&gt;/&amp;gt;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;/androidx&lt;/span&gt;.constraintlayout.widget.ConstraintLayout&lt;span class=&quot;hl kwa&quot;&gt;&amp;gt;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;/ScrollView&amp;gt;&lt;/span&gt;
&lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;/layout&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;pre class=&quot;hl&quot;&gt;&lt;span class=&quot;hl slc&quot;&gt;// TestWonFragment.kt&lt;/span&gt;
&lt;span class=&quot;hl kwa&quot;&gt;package&lt;/span&gt; com&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;android&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;testci

&lt;span class=&quot;hl kwa&quot;&gt;import&lt;/span&gt; android&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;os&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;Bundle
&lt;span class=&quot;hl kwa&quot;&gt;import&lt;/span&gt; android&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;view&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;LayoutInflater
&lt;span class=&quot;hl kwa&quot;&gt;import&lt;/span&gt; android&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;view&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;View
&lt;span class=&quot;hl kwa&quot;&gt;import&lt;/span&gt; android&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;view&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;ViewGroup
&lt;span class=&quot;hl kwa&quot;&gt;import&lt;/span&gt; androidx&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;databinding&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;DataBindingUtil
&lt;span class=&quot;hl kwa&quot;&gt;import&lt;/span&gt; androidx&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;fragment&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;app&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;Fragment
&lt;span class=&quot;hl kwa&quot;&gt;import&lt;/span&gt; androidx&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;navigation&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;findNavController
&lt;span class=&quot;hl kwa&quot;&gt;import&lt;/span&gt; com&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;android&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;testci&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;databinding&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;FragmentTestWonBinding

&lt;span class=&quot;hl kwa&quot;&gt;class&lt;/span&gt; TestWonFragment &lt;span class=&quot;hl opt&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;Fragment&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;() {&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;override fun&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;onCreateView&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; inflater&lt;span class=&quot;hl opt&quot;&gt;:&lt;/span&gt; LayoutInflater&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; container&lt;span class=&quot;hl opt&quot;&gt;:&lt;/span&gt; ViewGroup?&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; savedInstanceState&lt;span class=&quot;hl opt&quot;&gt;:&lt;/span&gt; Bundle?
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl opt&quot;&gt;):&lt;/span&gt; View? &lt;span class=&quot;hl opt&quot;&gt;{&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;val&lt;/span&gt; binding&lt;span class=&quot;hl opt&quot;&gt;:&lt;/span&gt; FragmentTestWonBinding &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; DataBindingUtil&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;inflate&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; inflater&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; R&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;layout&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;fragment_test_won&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; container&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;hl kwa&quot;&gt;false&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; binding&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;nextTestButton&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;setOnClickListener &lt;span class=&quot;hl opt&quot;&gt;{&lt;/span&gt; view&lt;span class=&quot;hl opt&quot;&gt;:&lt;/span&gt; View &lt;span class=&quot;hl opt&quot;&gt;-&amp;gt;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; view&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;findNavController&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;().&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;navigate&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;R&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;id&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;action_testWonFragment_to_testFragment&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;return&lt;/span&gt; binding&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;root
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt;&lt;/pre&gt;
&lt;pre class=&quot;hl&quot;&gt;&lt;span class=&quot;hl com&quot;&gt;&amp;lt;!-- layout/fragment_test_won.xml --&amp;gt;&lt;/span&gt;
&lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;?xml&lt;/span&gt; &lt;span class=&quot;hl kwb&quot;&gt;version&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;1.0&quot;&lt;/span&gt; &lt;span class=&quot;hl kwb&quot;&gt;encoding&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;utf-8&quot;&lt;/span&gt;&lt;span class=&quot;hl kwa&quot;&gt;?&amp;gt;&lt;/span&gt;

&lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;layout&lt;/span&gt; xmlns:&lt;span class=&quot;hl kwb&quot;&gt;android&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;http://schemas.android.com/apk/res/android&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; xmlns:&lt;span class=&quot;hl kwb&quot;&gt;app&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;http://schemas.android.com/apk/res-auto&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; xmlns:&lt;span class=&quot;hl kwb&quot;&gt;tools&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;http://schemas.android.com/tools&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; tools:&lt;span class=&quot;hl kwb&quot;&gt;context&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;com.android.testci.TestWonFragment&quot;&lt;/span&gt;&lt;span class=&quot;hl kwa&quot;&gt;&amp;gt;&lt;/span&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;androidx&lt;/span&gt;.constraintlayout.widget.ConstraintLayout
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;id&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@+id/testWonConstraintLayout&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_width&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;match_parent&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_height&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;match_parent&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;background&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@color/fondoazul&quot;&lt;/span&gt;&lt;span class=&quot;hl kwa&quot;&gt;&amp;gt;&lt;/span&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;Button&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;id&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@+id/nextTestButton&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_width&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;wrap_content&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_height&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;wrap_content&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;paddingStart&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@dimen/button_padding&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;paddingEnd&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@dimen/button_padding&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;text&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@string/next&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;textColor&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@color/youWinDark&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;textSize&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@dimen/button_text_size&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;textStyle&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;bold&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; app:&lt;span class=&quot;hl kwb&quot;&gt;layout_constraintBottom_toBottomOf&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;parent&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; app:&lt;span class=&quot;hl kwb&quot;&gt;layout_constraintEnd_toEndOf&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;parent&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; app:&lt;span class=&quot;hl kwb&quot;&gt;layout_constraintStart_toStartOf&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;parent&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; app:&lt;span class=&quot;hl kwb&quot;&gt;layout_constraintTop_toBottomOf&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@+id/youWinImage&quot;&lt;/span&gt; &lt;span class=&quot;hl kwa&quot;&gt;/&amp;gt;&lt;/span&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;ImageView&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;id&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@+id/youWinImage&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_width&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;0dp&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_height&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@dimen/game_over_height&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_marginStart&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@dimen/horizontal_margin&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_marginTop&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;8dp&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_marginEnd&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@dimen/horizontal_margin&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_marginBottom&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@dimen/vertical_margin&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;scaleType&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;fitCenter&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; app:&lt;span class=&quot;hl kwb&quot;&gt;layout_constraintBottom_toTopOf&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@+id/nextTestButton&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; app:&lt;span class=&quot;hl kwb&quot;&gt;layout_constraintEnd_toEndOf&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;parent&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; app:&lt;span class=&quot;hl kwb&quot;&gt;layout_constraintStart_toStartOf&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;parent&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; app:&lt;span class=&quot;hl kwb&quot;&gt;layout_constraintTop_toTopOf&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;parent&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; app:&lt;span class=&quot;hl kwb&quot;&gt;srcCompat&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@drawable/ic_award&quot;&lt;/span&gt; &lt;span class=&quot;hl kwa&quot;&gt;/&amp;gt;&lt;/span&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;/androidx&lt;/span&gt;.constraintlayout.widget.ConstraintLayout&lt;span class=&quot;hl kwa&quot;&gt;&amp;gt;&lt;/span&gt;
&lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;/layout&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;pre class=&quot;hl&quot;&gt;&lt;span class=&quot;hl slc&quot;&gt;// TestOverFragment.kt&lt;/span&gt;
&lt;span class=&quot;hl kwa&quot;&gt;package&lt;/span&gt; com&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;android&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;testci

&lt;span class=&quot;hl kwa&quot;&gt;import&lt;/span&gt; android&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;os&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;Bundle
&lt;span class=&quot;hl kwa&quot;&gt;import&lt;/span&gt; android&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;view&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;LayoutInflater
&lt;span class=&quot;hl kwa&quot;&gt;import&lt;/span&gt; android&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;view&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;View
&lt;span class=&quot;hl kwa&quot;&gt;import&lt;/span&gt; android&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;view&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;ViewGroup
&lt;span class=&quot;hl kwa&quot;&gt;import&lt;/span&gt; androidx&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;databinding&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;DataBindingUtil
&lt;span class=&quot;hl kwa&quot;&gt;import&lt;/span&gt; androidx&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;fragment&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;app&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;Fragment
&lt;span class=&quot;hl kwa&quot;&gt;import&lt;/span&gt; androidx&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;navigation&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;findNavController
&lt;span class=&quot;hl kwa&quot;&gt;import&lt;/span&gt; com&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;android&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;testci&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;databinding&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;FragmentTestOverBinding

&lt;span class=&quot;hl kwa&quot;&gt;class&lt;/span&gt; TestOverFragment &lt;span class=&quot;hl opt&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;Fragment&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;() {&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;override fun&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;onCreateView&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; inflater&lt;span class=&quot;hl opt&quot;&gt;:&lt;/span&gt; LayoutInflater&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; container&lt;span class=&quot;hl opt&quot;&gt;:&lt;/span&gt; ViewGroup?&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; savedInstanceState&lt;span class=&quot;hl opt&quot;&gt;:&lt;/span&gt; Bundle?
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl opt&quot;&gt;):&lt;/span&gt; View? &lt;span class=&quot;hl opt&quot;&gt;{&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl slc&quot;&gt;// Inflate the layout for this fragment&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;val&lt;/span&gt; binding&lt;span class=&quot;hl opt&quot;&gt;:&lt;/span&gt; FragmentTestOverBinding &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; DataBindingUtil&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;inflate&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; inflater&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; R&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;layout&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;fragment_test_over&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; container&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;hl kwa&quot;&gt;false&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; binding&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;tryAgainButton&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;setOnClickListener &lt;span class=&quot;hl opt&quot;&gt;{&lt;/span&gt; view&lt;span class=&quot;hl opt&quot;&gt;:&lt;/span&gt; View &lt;span class=&quot;hl opt&quot;&gt;-&amp;gt;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; view&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;findNavController&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;().&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;navigate&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;R&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;id&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;action_testOverFragment_to_testFragment&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;return&lt;/span&gt; binding&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;root
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt;&lt;/pre&gt;
&lt;pre class=&quot;hl&quot;&gt;&lt;span class=&quot;hl com&quot;&gt;&amp;lt;!-- layout/fragment_test_over.xml --&amp;gt;&lt;/span&gt;
&lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;?xml&lt;/span&gt; &lt;span class=&quot;hl kwb&quot;&gt;version&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;1.0&quot;&lt;/span&gt; &lt;span class=&quot;hl kwb&quot;&gt;encoding&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;utf-8&quot;&lt;/span&gt;&lt;span class=&quot;hl kwa&quot;&gt;?&amp;gt;&lt;/span&gt;

&lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;layout&lt;/span&gt; xmlns:&lt;span class=&quot;hl kwb&quot;&gt;android&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;http://schemas.android.com/apk/res/android&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; xmlns:&lt;span class=&quot;hl kwb&quot;&gt;app&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;http://schemas.android.com/apk/res-auto&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; xmlns:&lt;span class=&quot;hl kwb&quot;&gt;tools&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;http://schemas.android.com/tools&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; tools:&lt;span class=&quot;hl kwb&quot;&gt;context&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;com.android.testci.TestOverFragment&quot;&lt;/span&gt;&lt;span class=&quot;hl kwa&quot;&gt;&amp;gt;&lt;/span&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;androidx&lt;/span&gt;.constraintlayout.widget.ConstraintLayout
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;id&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@+id/gameOverConstraintLayout&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_width&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;match_parent&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_height&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;match_parent&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;background&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@color/fondorosa&quot;&lt;/span&gt;&lt;span class=&quot;hl kwa&quot;&gt;&amp;gt;&lt;/span&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;ImageView&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;id&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@+id/testOverFragment&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_width&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;wrap_content&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_height&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;362dp&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_marginStart&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@dimen/horizontal_margin&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_marginEnd&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@dimen/horizontal_margin&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_marginBottom&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;8dp&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;scaleType&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;fitCenter&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; app:&lt;span class=&quot;hl kwb&quot;&gt;layout_constraintBottom_toTopOf&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@+id/tryAgainButton&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; app:&lt;span class=&quot;hl kwb&quot;&gt;layout_constraintEnd_toEndOf&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;parent&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; app:&lt;span class=&quot;hl kwb&quot;&gt;layout_constraintStart_toStartOf&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;parent&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; app:&lt;span class=&quot;hl kwb&quot;&gt;layout_constraintTop_toTopOf&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;parent&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; app:&lt;span class=&quot;hl kwb&quot;&gt;layout_constraintVertical_chainStyle&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;packed&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; app:&lt;span class=&quot;hl kwb&quot;&gt;srcCompat&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@drawable/ic_assignment&quot;&lt;/span&gt; &lt;span class=&quot;hl kwa&quot;&gt;/&amp;gt;&lt;/span&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;Button&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;id&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@+id/tryAgainButton&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_width&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;wrap_content&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_height&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;wrap_content&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_marginStart&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@dimen/vertical_margin&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_marginTop&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@dimen/vertical_margin&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_marginEnd&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@dimen/vertical_margin&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_marginBottom&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;8dp&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;paddingStart&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@dimen/button_padding&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;paddingEnd&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@dimen/button_padding&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;text&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@string/try_again&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;textColor&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;?colorAccent&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;textSize&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@dimen/button_text_size&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;textStyle&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;bold&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; app:&lt;span class=&quot;hl kwb&quot;&gt;layout_constraintBottom_toBottomOf&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;parent&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; app:&lt;span class=&quot;hl kwb&quot;&gt;layout_constraintEnd_toEndOf&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;parent&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; app:&lt;span class=&quot;hl kwb&quot;&gt;layout_constraintStart_toStartOf&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;parent&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; app:&lt;span class=&quot;hl kwb&quot;&gt;layout_constraintTop_toBottomOf&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@+id/testOverFragment&quot;&lt;/span&gt; &lt;span class=&quot;hl kwa&quot;&gt;/&amp;gt;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;/androidx&lt;/span&gt;.constraintlayout.widget.ConstraintLayout&lt;span class=&quot;hl kwa&quot;&gt;&amp;gt;&lt;/span&gt;
&lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;/layout&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;pre class=&quot;hl&quot;&gt;&lt;span class=&quot;hl com&quot;&gt;&amp;lt;!-- navigation/navigation.xml --&amp;gt;&lt;/span&gt;
&lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;?xml&lt;/span&gt; &lt;span class=&quot;hl kwb&quot;&gt;version&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;1.0&quot;&lt;/span&gt; &lt;span class=&quot;hl kwb&quot;&gt;encoding&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;utf-8&quot;&lt;/span&gt;&lt;span class=&quot;hl kwa&quot;&gt;?&amp;gt;&lt;/span&gt;
&lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;navigation&lt;/span&gt; xmlns:&lt;span class=&quot;hl kwb&quot;&gt;android&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;http://schemas.android.com/apk/res/android&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; xmlns:&lt;span class=&quot;hl kwb&quot;&gt;app&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;http://schemas.android.com/apk/res-auto&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; xmlns:&lt;span class=&quot;hl kwb&quot;&gt;tools&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;http://schemas.android.com/tools&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;id&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@+id/navigation&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; app:&lt;span class=&quot;hl kwb&quot;&gt;startDestination&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@id/titleFragment&quot;&lt;/span&gt;&lt;span class=&quot;hl kwa&quot;&gt;&amp;gt;&lt;/span&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;fragment&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;id&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@+id/titleFragment&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;name&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;com.android.testci.TitleFragment&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;label&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;fragment_title&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; tools:&lt;span class=&quot;hl kwb&quot;&gt;layout&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@layout/fragment_title&quot;&lt;/span&gt;&lt;span class=&quot;hl kwa&quot;&gt;&amp;gt;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;action&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;id&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@+id/action_titleFragment_to_testFragment&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; app:&lt;span class=&quot;hl kwb&quot;&gt;destination&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@+id/testFragment&quot;&lt;/span&gt; &lt;span class=&quot;hl kwa&quot;&gt;/&amp;gt;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;/fragment&amp;gt;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;fragment&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;id&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@+id/testFragment&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;name&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;com.android.testci.TestFragment&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;label&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;TestFragment&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; tools:&lt;span class=&quot;hl kwb&quot;&gt;layout&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@layout/fragment_test&quot;&lt;/span&gt;&lt;span class=&quot;hl kwa&quot;&gt;&amp;gt;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;action&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;id&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@+id/action_testFragment_to_testOverFragment&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; app:&lt;span class=&quot;hl kwb&quot;&gt;destination&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@id/testOverFragment&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; app:&lt;span class=&quot;hl kwb&quot;&gt;popUpTo&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@+id/testFragment&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; app:&lt;span class=&quot;hl kwb&quot;&gt;popUpToInclusive&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;true&quot;&lt;/span&gt; &lt;span class=&quot;hl kwa&quot;&gt;/&amp;gt;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;action&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;id&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@+id/action_testFragment_to_testWonFragment&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; app:&lt;span class=&quot;hl kwb&quot;&gt;destination&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@id/testWonFragment&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; app:&lt;span class=&quot;hl kwb&quot;&gt;popUpTo&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@+id/testFragment&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; app:&lt;span class=&quot;hl kwb&quot;&gt;popUpToInclusive&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;true&quot;&lt;/span&gt; &lt;span class=&quot;hl kwa&quot;&gt;/&amp;gt;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;/fragment&amp;gt;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;fragment&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;id&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@+id/testOverFragment&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;name&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;com.android.testci.TestOverFragment&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;label&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;fragment_test_over&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; tools:&lt;span class=&quot;hl kwb&quot;&gt;layout&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@layout/fragment_test_over&quot;&lt;/span&gt;&lt;span class=&quot;hl kwa&quot;&gt;&amp;gt;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;action&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;id&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@+id/action_testOverFragment_to_testFragment&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; app:&lt;span class=&quot;hl kwb&quot;&gt;destination&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@id/testFragment&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; app:&lt;span class=&quot;hl kwb&quot;&gt;popUpTo&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@+id/titleFragment&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; app:&lt;span class=&quot;hl kwb&quot;&gt;popUpToInclusive&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;false&quot;&lt;/span&gt; &lt;span class=&quot;hl kwa&quot;&gt;/&amp;gt;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;/fragment&amp;gt;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;fragment&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;id&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@+id/testWonFragment&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;name&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;com.android.testci.TestWonFragment&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;label&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;fragment_test_won&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; tools:&lt;span class=&quot;hl kwb&quot;&gt;layout&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@layout/fragment_test_won&quot;&lt;/span&gt;&lt;span class=&quot;hl kwa&quot;&gt;&amp;gt;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;action&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;id&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@+id/action_testWonFragment_to_testFragment&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; app:&lt;span class=&quot;hl kwb&quot;&gt;destination&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@id/testFragment&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; app:&lt;span class=&quot;hl kwb&quot;&gt;popUpTo&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@+id/titleFragment&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; app:&lt;span class=&quot;hl kwb&quot;&gt;popUpToInclusive&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;false&quot;&lt;/span&gt; &lt;span class=&quot;hl kwa&quot;&gt;/&amp;gt;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;/fragment&amp;gt;&lt;/span&gt;
&lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;/navigation&amp;gt;&lt;/span&gt;&lt;/pre&gt;
</content><link rel='replies' type='application/atom+xml' href='https://kotlindoc.blogspot.com/feeds/4079903140133773654/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='https://kotlindoc.blogspot.com/2019/08/navegando-entre-fragmentos.html#comment-form' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='https://www.blogger.com/feeds/6895501055750567199/posts/default/4079903140133773654'/><link rel='self' type='application/atom+xml' href='https://www.blogger.com/feeds/6895501055750567199/posts/default/4079903140133773654'/><link rel='alternate' type='text/html' href='https://kotlindoc.blogspot.com/2019/08/navegando-entre-fragmentos.html' title='Navegando entre fragmentos'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhcpV2q-xSGXgm1xzXlcKnrynK5VMctw2R5NsC6zsCVEN0M99lOOr8PX2FwU2J5bcYhYLXVVHcQbgaKg_dIFvU_teFgk2iUgmssQjYEfontEjXOp7Gdw0QDQGU_6vNWX-X-2fVqFQxGkfA/s72-c/navegando.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6895501055750567199.post-5192995220367874743</id><published>2019-08-15T16:21:00.001+02:00</published><updated>2019-08-15T16:24:07.004+02:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="android studio"/><title type='text'>Android Studio con Java 8</title><content type='html'>&lt;img alt=&quot;Android Studio con Java 8&quot; border=&quot;0&quot; data-original-height=&quot;393&quot; data-original-width=&quot;700&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg3V0WKAYIK_oWSdht-wmhbqz2KbJDYW9R6PNsv8x33sob9ijz4IN0-ifMxBcgwwWc3ryqRf8HuPFyt9WD4_Yu77vjMJd22U2eUqh7JCs-7_SKDDGGOphKo8BGMvhf-5ZbBagfBrKtMVgQ/s1600/java.jpeg&quot; title=&quot;Android Studio con Java 8&quot; /&gt;&lt;br /&gt;
&lt;br /&gt;
Desde la versión 3.0 (y posteriores) &lt;i&gt;Android Studio&lt;/i&gt; admite todas las funciones del lenguaje Java 7 además de un subconjunto de funciones de &lt;b&gt;Java 8&lt;/b&gt; que varía según la versión de la plataforma (hay que tener en cuenta que, aunque el uso de Java 8 es opcional, para la compilación de aplicaciones con Java 7 se debe usar JDK 8).&lt;br /&gt;&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;
&lt;br /&gt;
&lt;i&gt;Android Studio&lt;/i&gt; proporciona compatibilidad integrada para el uso de ciertas funcionalidades de Java 8 y de bibliotecas de terceros que las necesitan, pero para poder usar Java 8 debemos configurar correctamente nuestro proyecto en &lt;i&gt;Android Studio&lt;/i&gt;. Además, como ya hemos visto en entradas anteriores, si intentamos usar algunas características de Java 8 sin esta configuración podemos encontrarnos con un error parecido a &#39;&lt;i&gt;Error Default interface methods are only supported starting with Android N...&lt;/i&gt;&#39;&lt;br /&gt;
&lt;br /&gt;
Para poder lograr la &lt;b&gt;compatibilidad con Java 8&lt;/b&gt; con el conjunto de herramientas predeterminadas de &lt;i&gt;Android Studio&lt;/i&gt; debemos seguir estos &lt;b&gt;tres pasos&lt;/b&gt;:&lt;br /&gt;
&lt;br /&gt;
&lt;h2&gt;
PRIMERO&lt;/h2&gt;
Lo primero es, si fuera el caso, &lt;b&gt;inhabilitar Jack&lt;/b&gt;, que es un conjunto de herramientas que ha quedado obsoleto. Esta advertencia es solo para aquellos proyectos más antiguos que dependen de &lt;i&gt;Jack&lt;/i&gt; y que deben realizar esta migración para usar la compatibilidad con Java 8. Para inhabilitar &lt;i&gt;Jack&lt;/i&gt; simplemente hay que quitar, en caso de existir, el bloque &lt;i&gt;jackOptions{}&lt;/i&gt; en el archivo &lt;i&gt;build.gradle&lt;/i&gt; del módulo.&lt;br /&gt;
&lt;br /&gt;
&lt;h2&gt;
SEGUNDO &lt;/h2&gt;
&lt;b&gt;Actualizar el complemento Gradle de Android&lt;/b&gt; (&lt;i&gt;Android Gradle plugin&lt;/i&gt;) al menos a la versión 3.0.0 (o versiones posteriores). Podemos especificar la versión de este complemento para todos los módulos integrados en un proyecto de &lt;i&gt;Android Studio&lt;/i&gt; desde &lt;i&gt;File&lt;/i&gt; &amp;gt; &lt;i&gt;Project Structure&lt;/i&gt; &amp;gt; &lt;i&gt;Project&lt;/i&gt;:&lt;br /&gt;
&lt;br /&gt;
&lt;img border=&quot;0&quot; data-original-height=&quot;431&quot; data-original-width=&quot;728&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjFBf9DQYXChUxy0W-IS8mnu8X5c_nu_eSM7jyze8CPlQvgikWJVH5kBrybY4RbWxYXXFRpEw3Hbfnbp66kmLOfSIzjr_zCUAXyuvX0kga7v_gtdaRT24synanxAxf01CPupF5OZ5zyTto/s1600/pluginversion.png&quot; /&gt;&lt;br /&gt;
&lt;br /&gt;
Y también en el archivo &lt;i&gt;build.gradle&lt;/i&gt; del proyecto:&lt;br /&gt;
&lt;pre class=&quot;hl&quot;&gt;buildscript &lt;span class=&quot;hl opt&quot;&gt;{&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; ext&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;kotlin_version &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;hl str&quot;&gt;&#39;1.3.21&#39;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; repositories &lt;span class=&quot;hl opt&quot;&gt;{&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwd&quot;&gt;google&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;()&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwd&quot;&gt;jcenter&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;()&lt;/span&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; dependencies &lt;span class=&quot;hl opt&quot;&gt;{&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; classpath &lt;span class=&quot;hl str&quot;&gt;&#39;com.android.tools.build:gradle:3.3.0&#39;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; classpath &lt;span class=&quot;hl str&quot;&gt;&quot;org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl slc&quot;&gt;// NOTE: Do not place your application dependencies here; they belong&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl slc&quot;&gt;// in the individual module build.gradle files&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt;&lt;/pre&gt;
Hay que tener en cuenta dos cosas: 1) que cada versión del complemento &lt;i&gt;Android Gradle&lt;/i&gt; requiere una versión de &lt;i&gt;Gradle&lt;/i&gt;, por lo que si actualizas el complemento posiblemente debas actualizar también &lt;i&gt;Gradle&lt;/i&gt; (en ese caso &lt;i&gt;Android Studio&lt;/i&gt; lanzará un mensaje de actualización), y 2) que para obtener el mejor rendimiento se debe usar la última versión posible de ambos.&lt;br /&gt;
&lt;br /&gt;
&lt;img border=&quot;0&quot; data-original-height=&quot;660&quot; data-original-width=&quot;720&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh8bfJQsmOw9outANhyrsb7o9If3-zqnGAMyaIc4lC4JJPEwL6Hrv7-faWe8Q7_2PE1Rxvc3ZqhRwf2zWH7y5kUCiEcDwH6alGg-hZ9HthZR8ipzh781q8brwxLiR7gBMPhw09GdY8awDw/s1600/versionGradle.png&quot; /&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;h2&gt;
TERCERO &lt;/h2&gt;
Y por último, para cada módulo que use Java 8 (ya sea en su código fuente o a través de dependencias), debemos &lt;b&gt;especificar la compatibilidad de origen y destino&lt;/b&gt; agregando lo siguiente a su archivo &lt;i&gt;build.gradle&lt;/i&gt;, dentro del bloque &lt;i&gt;android&lt;/i&gt;:&lt;br /&gt;
&lt;pre class=&quot;hl&quot;&gt;android &lt;span class=&quot;hl opt&quot;&gt;{&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl opt&quot;&gt;...&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; compileOptions &lt;span class=&quot;hl opt&quot;&gt;{&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; sourceCompatibility JavaVersion&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;VERSION_1_8
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; targetCompatibility JavaVersion&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;VERSION_1_8
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt;&lt;/pre&gt;
</content><link rel='replies' type='application/atom+xml' href='https://kotlindoc.blogspot.com/feeds/5192995220367874743/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='https://kotlindoc.blogspot.com/2019/08/android-studio-con-java-8.html#comment-form' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='https://www.blogger.com/feeds/6895501055750567199/posts/default/5192995220367874743'/><link rel='self' type='application/atom+xml' href='https://www.blogger.com/feeds/6895501055750567199/posts/default/5192995220367874743'/><link rel='alternate' type='text/html' href='https://kotlindoc.blogspot.com/2019/08/android-studio-con-java-8.html' title='Android Studio con Java 8'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg3V0WKAYIK_oWSdht-wmhbqz2KbJDYW9R6PNsv8x33sob9ijz4IN0-ifMxBcgwwWc3ryqRf8HuPFyt9WD4_Yu77vjMJd22U2eUqh7JCs-7_SKDDGGOphKo8BGMvhf-5ZbBagfBrKtMVgQ/s72-c/java.jpeg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6895501055750567199.post-6496459561687882443</id><published>2019-08-14T18:04:00.001+02:00</published><updated>2019-08-14T18:05:52.082+02:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="android básico"/><category scheme="http://www.blogger.com/atom/ns#" term="android studio"/><title type='text'>Fundamentos de Android: Introducción a los Fragmentos</title><content type='html'>&lt;img alt=&quot;Fundamentos de Android: Introducción a los Fragmentos&quot; border=&quot;0&quot; data-original-height=&quot;900&quot; data-original-width=&quot;900&quot; height=&quot;640&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjjhyFZF2gRMmYXWIqOh2p6FWupJsJbFDI9x_knfysUnPshPv5Ddw5MfXDZqsSjT-EyS8-i2tKz1BKvNjLiq4oB138Gcx7MICkPtB0Mc9p39Vh89MkMdjyoCZfkZHnD9GuwmzYoSepsLtM/s640/Kotlin+Android+Fragments.png&quot; title=&quot;Fundamentos de Android: Introducción a los Fragmentos&quot; width=&quot;640&quot; /&gt;&lt;br /&gt;
&lt;br /&gt;
Android introduce los &lt;b&gt;fragmentos&lt;/b&gt; en Android 3.0 (nivel de API 11) principalmente para admitir diseños de la interfaz de usuario (IU o UI, de &lt;i&gt;user interface&lt;/i&gt;) más dinámicos y flexibles en pantallas grandes, como las de las tablets, dividiendo el diseño de una actividad en fragmentos, lo que permite modificar el aspecto de la actividad en tiempo de ejecución.&lt;br /&gt;
&lt;br /&gt;
Un fragmento (&lt;i&gt;fragment&lt;/i&gt;) representa una parte de la IU en una actividad. Podemos combinar múltiples fragmentos en una sola actividad para construir una IU compleja, &lt;br /&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;y reutilizar un fragmento en distintas actividades. Podemos pensar en un fragmento como una &lt;b&gt;sección modular de una actividad&lt;/b&gt;, que tiene su propio ciclo de vida, que recibe sus propios eventos de entrada y que se puede agregar o quitar mientras la actividad se está ejecutando, algo así como una &quot;subactividad&quot; que se volver a usar en diferentes actividades. En definitiva, un fragmento es un componente de Android que puede contener parte del comportamiento y de la IU de una actividad, a la que está vinculado.&lt;br /&gt;
&lt;br /&gt;
Y es que un fragmento siempre debe estar integrado en una actividad (no son entidades independientes) y el ciclo de vida del fragmento se ve directamente afectado por el ciclo de vida de la actividad anfitriona (en próximas entradas hablaremos del ciclo de vida de la actividad). Por ejemplo, cuando la actividad está pausada, también lo están todos sus fragmentos, y cuando la actividad se destruye, lo mismo ocurre con todos los fragmentos. Sin embargo, mientras una actividad se está ejecutando se puede manipular cada fragmento de forma independiente, por ejemplo, para agregarlos o quitarlos.&lt;br /&gt;
&lt;br /&gt;
Debemos diseñar cada fragmento como un &lt;b&gt;componente modular y reutilizable de la actividad&lt;/b&gt;, pudiendo cambiar las combinaciones de fragmentos para diferentes tamaños de pantalla y reutilizando los fragmentos en diferentes configuraciones de diseño para optimizar la experiencia del usuario en función del espacio de pantalla disponible. La siguiente imagen representa la manera en que dos módulos de la IU definidos por fragmentos se pueden combinar en una actividad para un diseño de tablet y se presentan por separado para un diseño de teléfono en, por ejemplo, una aplicación de noticias que usa un fragmento para mostrar una lista de artículos a la izquierda y otro fragmento para mostrar el artículo seleccionado a la derecha:&lt;br /&gt;
&lt;br /&gt;
&lt;img border=&quot;0&quot; data-original-height=&quot;484&quot; data-original-width=&quot;840&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEguOM6VhIE_tjvZCeQ8FBgOR6MQ4H-pLWNGBl5BdyHng9cwhENyVeuk_ukLI2YJUKTUsUrfyFHTuSX0Gqv-SVkV7sHUNpGekwPE6fPBrgEbS2aIHPcNaM5495CBgZpHcI_p61M6d4jChjo/s1600/Fragmentos+Android+Developers.png&quot; /&gt;&lt;br /&gt;
&lt;br /&gt;
En resumen, los fragmentos en Android aportan:&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;&lt;b&gt;Modularidad&lt;/b&gt;: División del código de una actividad compleja en fragmentos para una mejor organización y mantenimiento.&lt;/li&gt;
&lt;li&gt;&lt;b&gt;Reusabilidad&lt;/b&gt;: Al ubicar un comportamiento o parte de la IU en fragmentos, éstos pueden ser compartidos por múltiples actividades.&lt;/li&gt;
&lt;li&gt;&lt;b&gt;Adaptabilidad&lt;/b&gt;: La representación de secciones de la IU como fragmentos permite utilizar diferentes diseños según la orientación y el tamaño de la pantalla.&lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;
En esta entrada vamos a aprender a crear un fragmento a través de un ejemplo básico, y en próximas entradas veremos cómo los fragmentos pueden enviar información a una actividad y cómo añadir y remplazar fragmentos.&lt;br /&gt;
&lt;br /&gt;
Empezamos creando un nuevo proyecto desde una actividad vacía. Una manera rápida de crear un fragmento es enfocar el panel de archivos del proyecto seleccionando, por ejemplo, la carpeta com.android.miapp y desde el menú superior accedemos a &lt;i&gt;File&lt;/i&gt; -&amp;gt; &lt;i&gt;New&lt;/i&gt; -&amp;gt; &lt;i&gt;Fragment&lt;/i&gt; -&amp;gt; &lt;i&gt;Fragment (Blank)&lt;/i&gt; o bien con el botón secundario del ratón &lt;i&gt;com.android.miapp&lt;/i&gt; -&amp;gt; &lt;i&gt;New&lt;/i&gt; -&amp;gt; &lt;i&gt;Fragment&lt;/i&gt; -&amp;gt; &lt;i&gt;Fragment (Blank)&lt;/i&gt;:&lt;br /&gt;
&lt;br /&gt;
&lt;img border=&quot;0&quot; data-original-height=&quot;925&quot; data-original-width=&quot;1266&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEibWScR_VU6eyOh1SgwGtMAZliJLFEiy0pEcSBcYsDatE-jXZEiJRFqc7_kt51gTtBuRSsBtywAfUrPQ_81vD9cU-3RhYeqSUFdCkWyCXrSQRKJqC-fR6v-qr8WIKL4tWgSJYuU2Cu15Pg/s1600/newFragment.png&quot; /&gt;&lt;br /&gt;
&lt;br /&gt;
Esto abre la ventana &lt;i&gt;New Android Component&lt;/i&gt;, donde asignamos un nombre al fragmento y desactivamos las casillas de verificación relativas a &lt;i&gt;factory methods&lt;/i&gt; e &lt;i&gt;interface callbacks&lt;/i&gt; como se ve en la imagen:&lt;br /&gt;
&lt;br /&gt;
&lt;img border=&quot;0&quot; data-original-height=&quot;680&quot; data-original-width=&quot;879&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjMjpOpxOtv53KiVnpW6qSi73OkrQQQtlhwpVjN9rwhd09eI2ncMDqbpf95NmKQ__ppKslgpj_xO_oO2ZTjTaSuU4Uq1Ba54lX0NNX7Fkgj1ypwWmInSYb-3wVQ0RW4k6szCExSAxABEHU/s1600/newComponent.png&quot; /&gt;&lt;br /&gt;
&lt;br /&gt;
Comprobamos que al crear el fragmento tenemos un nuevo archivo de Kotlin y su correspondiente archivo de diseño XML con un &lt;i&gt;TextView&lt;/i&gt;. Repetimos para crear un segundo fragmento. Configuramos los archivos de diseño de ambos fragmentos con algunos atributos distintos (color de fondo y texto) para distinguirlos más fácilmente en el diseño de la actividad, quedando de esta manera:&lt;br /&gt;
&lt;pre class=&quot;hl&quot;&gt;&lt;span class=&quot;hl com&quot;&gt;&amp;lt;!-- layout/fragment_primer_fragmento.xml --&amp;gt;&lt;/span&gt;
&lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;?xml&lt;/span&gt; &lt;span class=&quot;hl kwb&quot;&gt;version&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;1.0&quot;&lt;/span&gt; &lt;span class=&quot;hl kwb&quot;&gt;encoding&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;utf-8&quot;&lt;/span&gt;&lt;span class=&quot;hl kwa&quot;&gt;?&amp;gt;&lt;/span&gt;
&lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;FrameLayout&lt;/span&gt; xmlns:&lt;span class=&quot;hl kwb&quot;&gt;android&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;http://schemas.android.com/apk/res/android&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; xmlns:&lt;span class=&quot;hl kwb&quot;&gt;tools&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;http://schemas.android.com/tools&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_width&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;match_parent&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_height&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;match_parent&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;background&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@color/colorAccent&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; tools:&lt;span class=&quot;hl kwb&quot;&gt;context&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;.PrimerFragmento&quot;&lt;/span&gt;&lt;span class=&quot;hl kwa&quot;&gt;&amp;gt;&lt;/span&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl com&quot;&gt;&amp;lt;!-- TODO: Update blank fragment layout --&amp;gt;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;TextView&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_width&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;wrap_content&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_height&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;wrap_content&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_gravity&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;center&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;padding&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@dimen/padding_4&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;text&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@string/primer_fragment&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;textSize&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;18sp&quot;&lt;/span&gt; &lt;span class=&quot;hl kwa&quot;&gt;/&amp;gt;&lt;/span&gt;

&lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;/FrameLayout&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;pre class=&quot;hl&quot;&gt;&lt;span class=&quot;hl com&quot;&gt;&amp;lt;!--layout/fragment_segundo_fragmento.xml--&amp;gt;&lt;/span&gt;
&lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;?xml&lt;/span&gt; &lt;span class=&quot;hl kwb&quot;&gt;version&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;1.0&quot;&lt;/span&gt; &lt;span class=&quot;hl kwb&quot;&gt;encoding&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;utf-8&quot;&lt;/span&gt;&lt;span class=&quot;hl kwa&quot;&gt;?&amp;gt;&lt;/span&gt;
&lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;FrameLayout&lt;/span&gt; xmlns:&lt;span class=&quot;hl kwb&quot;&gt;android&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;http://schemas.android.com/apk/res/android&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; xmlns:&lt;span class=&quot;hl kwb&quot;&gt;tools&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;http://schemas.android.com/tools&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_width&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;match_parent&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_height&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;match_parent&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;background&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@color/colorPrimary&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; tools:&lt;span class=&quot;hl kwb&quot;&gt;context&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;.SegundoFragmento&quot;&lt;/span&gt;&lt;span class=&quot;hl kwa&quot;&gt;&amp;gt;&lt;/span&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl com&quot;&gt;&amp;lt;!-- TODO: Update blank fragment layout --&amp;gt;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;TextView&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_width&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;wrap_content&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_height&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;wrap_content&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_gravity&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;center&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;padding&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@dimen/padding_4&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;text&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@string/segundo_fragment&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;textSize&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;18sp&quot;&lt;/span&gt; &lt;span class=&quot;hl kwa&quot;&gt;/&amp;gt;&lt;/span&gt;

&lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;/FrameLayout&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;br /&gt;
Ahora abrimos el archivo &lt;i&gt;activity_main.xml&lt;/i&gt; para añadir ambos fragmentos como parte del diseño de la actividad principal, lo que podemos hacer con la etiqueta &amp;lt;fragment&amp;gt; en vista &lt;i&gt;Text&lt;/i&gt; o más fácilmente en vista &lt;i&gt;Design&lt;/i&gt;, arrastrando desde la paleta de elementos el elemento &amp;lt;fragment&amp;gt; hasta el árbol de componentes (al hacerlo, &lt;i&gt;Android Studio&lt;/i&gt; preguntará cuál de los fragmentos creados queremos añadir):&lt;br /&gt;
&lt;br /&gt;
&lt;img border=&quot;0&quot; data-original-height=&quot;597&quot; data-original-width=&quot;824&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi6y0-GV0LUrLyciuGv59eoA86_rDEztlX31iTcu4nKHrg7Jgsm8Y7gWCESz63ltpe-h6KEfMf5rLhieNYLtImdtLxvS51YZqjM9cYY1h6gys9LHPIwfV6JElUaxpbFASZ5yL2JExoU6zI/s1600/addFragmento.png&quot; /&gt;&lt;br /&gt;
&lt;br /&gt;
Eliminamos el &lt;i&gt;TextView&lt;/i&gt; que viene por defecto y distribuimos los fragmentos en la pantalla dentro del &lt;i&gt;ConstraintLayout&lt;/i&gt;:&lt;br /&gt;
&lt;pre class=&quot;hl&quot;&gt;&lt;span class=&quot;hl com&quot;&gt;&amp;lt;!--layout/activity_main.xml--&amp;gt;&lt;/span&gt;
&lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;?xml&lt;/span&gt; &lt;span class=&quot;hl kwb&quot;&gt;version&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;1.0&quot;&lt;/span&gt; &lt;span class=&quot;hl kwb&quot;&gt;encoding&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;utf-8&quot;&lt;/span&gt;&lt;span class=&quot;hl kwa&quot;&gt;?&amp;gt;&lt;/span&gt;
&lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;androidx&lt;/span&gt;.constraintlayout.widget.ConstraintLayout xmlns:&lt;span class=&quot;hl kwb&quot;&gt;android&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;http://schemas.android.com/apk/res/android&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; xmlns:&lt;span class=&quot;hl kwb&quot;&gt;app&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;http://schemas.android.com/apk/res-auto&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; xmlns:&lt;span class=&quot;hl kwb&quot;&gt;tools&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;http://schemas.android.com/tools&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_width&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;match_parent&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_height&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;match_parent&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; tools:&lt;span class=&quot;hl kwb&quot;&gt;context&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;.MainActivity&quot;&lt;/span&gt;&lt;span class=&quot;hl kwa&quot;&gt;&amp;gt;&lt;/span&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;fragment&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;id&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@+id/fragment&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;name&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;com.android.miapp.PrimerFragmento&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_width&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;wrap_content&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_height&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;0dp&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; app:&lt;span class=&quot;hl kwb&quot;&gt;layout_constraintBottom_toBottomOf&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;parent&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; app:&lt;span class=&quot;hl kwb&quot;&gt;layout_constraintEnd_toStartOf&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@+id/fragment2&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; app:&lt;span class=&quot;hl kwb&quot;&gt;layout_constraintHorizontal_bias&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;0.5&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; app:&lt;span class=&quot;hl kwb&quot;&gt;layout_constraintStart_toStartOf&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;parent&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; app:&lt;span class=&quot;hl kwb&quot;&gt;layout_constraintTop_toTopOf&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;parent&quot;&lt;/span&gt; &lt;span class=&quot;hl kwa&quot;&gt;/&amp;gt;&lt;/span&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;fragment&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;id&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@+id/fragment2&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;name&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;com.android.miapp.SegundoFragmento&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_width&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;0dp&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_height&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;0dp&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; app:&lt;span class=&quot;hl kwb&quot;&gt;layout_constraintBottom_toBottomOf&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;parent&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; app:&lt;span class=&quot;hl kwb&quot;&gt;layout_constraintEnd_toEndOf&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;parent&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; app:&lt;span class=&quot;hl kwb&quot;&gt;layout_constraintHorizontal_bias&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;0.5&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; app:&lt;span class=&quot;hl kwb&quot;&gt;layout_constraintStart_toEndOf&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@+id/fragment&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; app:&lt;span class=&quot;hl kwb&quot;&gt;layout_constraintTop_toTopOf&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;parent&quot;&lt;/span&gt; &lt;span class=&quot;hl kwa&quot;&gt;/&amp;gt;&lt;/span&gt;

&lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;/androidx&lt;/span&gt;.constraintlayout.widget.ConstraintLayout&lt;span class=&quot;hl kwa&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;br /&gt;
Al ejecutar la aplicación en el emulador podemos ver un resultando semejante a éste:&lt;br /&gt;
&lt;br /&gt;
&lt;img border=&quot;0&quot; data-original-height=&quot;1600&quot; data-original-width=&quot;900&quot; height=&quot;640&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjCXggWGyeaYI37QCy8yh2lHdZ0Z-kB3QgJ5Wm6LiCzyFbZmUjZbhPY-sRhJOgmSZIirct3qjX_QshMlmvTVYxebeHSlK2IC-eORTzRJI3kS7Oh7IVE593UcKkHQZdVGEtnYi-RhzzZMJg/s640/Screenshot_1565794845.png&quot; width=&quot;360&quot; /&gt;&lt;br /&gt;
&lt;br /&gt;
En esta entrada introductoria hemos visto cómo crear y añadir un fragmento a una actividad, pero lo hemos hecho de un modo estático, cuando los fragmentos permiten variaciones en el diseño en tiempo de ejecución. Próximamente veremos cómo crear y usar fragmentos dinámicamente desde la actividad con &lt;i&gt;FragmentManager&lt;/i&gt; y cómo realizar transacciones de fragmentos.</content><link rel='replies' type='application/atom+xml' href='https://kotlindoc.blogspot.com/feeds/6496459561687882443/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='https://kotlindoc.blogspot.com/2019/08/fundamentos-de-android-introduccion-los.html#comment-form' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='https://www.blogger.com/feeds/6895501055750567199/posts/default/6496459561687882443'/><link rel='self' type='application/atom+xml' href='https://www.blogger.com/feeds/6895501055750567199/posts/default/6496459561687882443'/><link rel='alternate' type='text/html' href='https://kotlindoc.blogspot.com/2019/08/fundamentos-de-android-introduccion-los.html' title='Fundamentos de Android: Introducción a los Fragmentos'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjjhyFZF2gRMmYXWIqOh2p6FWupJsJbFDI9x_knfysUnPshPv5Ddw5MfXDZqsSjT-EyS8-i2tKz1BKvNjLiq4oB138Gcx7MICkPtB0Mc9p39Vh89MkMdjyoCZfkZHnD9GuwmzYoSepsLtM/s72-c/Kotlin+Android+Fragments.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6895501055750567199.post-701179465979850480</id><published>2019-08-11T13:03:00.000+02:00</published><updated>2019-08-11T13:03:08.059+02:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="colecciones"/><title type='text'>Operaciones con colecciones IX: Operaciones de escritura</title><content type='html'>&lt;img alt=&quot;Operaciones con colecciones IX: Operaciones de escritura&quot; border=&quot;0&quot; data-original-height=&quot;582&quot; data-original-width=&quot;872&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgAUuvM_4jPmYncl7JJ77FCoG8frPFHxra6d6Veyj8CUPhJOrKGmallo5SpA1cSyltL5XeKdH2XHWgXFA2qmDs-8qH2b4IF89gQeKI5F1iCneCbAcTJdrA0GRegFaS6-mKb8jvebcnA-gM/s1600/colecEscritura.png&quot; title=&quot;Operaciones con colecciones IX: Operaciones de escritura&quot; /&gt;&lt;br /&gt;
&lt;br /&gt;
Aunque más adelante veremos otras características y funcionalidades de las colecciones, y concretamente operaciones específicas para listas, conjuntos y diccionarios, con esta entrada terminamos la serie dedicada a las &lt;a href=&quot;https://kotlindoc.blogspot.com/2019/06/operaciones-con-colecciones-i.html&quot;&gt;operaciones con colecciones&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;
Las &lt;b&gt;colecciones mutables&lt;/b&gt; admiten ciertas operaciones que permiten cambiar su contenido, por ejemplo agregando o eliminando elementos&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;
&lt;h2&gt;Agregar elementos&lt;/h2&gt;
Así, para agregar un solo elemento a una lista o a un conjunto usamos la función &lt;i&gt;add()&lt;/i&gt;, que agrega el nuevo elemento al final de la colección:&lt;br /&gt;
&lt;pre class=&quot;hl&quot;&gt;&lt;span class=&quot;hl kwa&quot;&gt;val&lt;/span&gt; numeros &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;mutableListOf&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl num&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;hl num&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;hl num&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;hl num&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;
numeros&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;add&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl num&quot;&gt;5&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;hl kwd&quot;&gt;println&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;numeros&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;hl slc&quot;&gt;// [1, 2, 3, 4, 5]&lt;/span&gt;&lt;/pre&gt;
&lt;br /&gt;
También tenemos la función &lt;i&gt;addAll()&lt;/i&gt; que utiliza como argumento un iterable, una secuencia o una &lt;i&gt;array&lt;/i&gt; para agregar cada elemento de dicho objeto, sin necesidad de que los tipos del argumento y de la colección receptora sean similares, esto es, se pueden agregar todos los elementos de un conjunto (&lt;i&gt;Set&lt;/i&gt;) a una lista (&lt;i&gt;List&lt;/i&gt;).&lt;br /&gt;
&lt;br /&gt;
Cuando &lt;i&gt;addAll()&lt;/i&gt; se invoca sobre listas, los nuevos elementos se agregan en el mismo orden en que aparecen en el argumento. También se puede llamar a &lt;i&gt;addAll()&lt;/i&gt; especificando una posición determinada como primer argumento, y entonces el primer elemento del argumento se inserta en esa posición seguido por el resto de elementos del argumento, desplazando a los elementos de la colección receptora hasta el final.&lt;br /&gt;
&lt;pre class=&quot;hl&quot;&gt;&lt;span class=&quot;hl kwa&quot;&gt;val&lt;/span&gt; numeros &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;mutableListOf&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl num&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;hl num&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;hl num&quot;&gt;5&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;hl num&quot;&gt;6&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;
numeros&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;addAll&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;arrayOf&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl num&quot;&gt;7&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;hl num&quot;&gt;8&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;))&lt;/span&gt;
&lt;span class=&quot;hl kwd&quot;&gt;println&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;numeros&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;hl slc&quot;&gt;// [1, 2, 5, 6, 7, 8]&lt;/span&gt;
numeros&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;addAll&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl num&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;setOf&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl num&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;hl num&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;))&lt;/span&gt; &lt;span class=&quot;hl slc&quot;&gt;// el primer argumento es el índice de inserción&lt;/span&gt;
&lt;span class=&quot;hl kwd&quot;&gt;println&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;numeros&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;hl slc&quot;&gt;// [1, 2, 3, 4, 5, 6, 7, 8]&lt;/span&gt;&lt;/pre&gt;
&lt;br /&gt;
Otra manera de agregar elementos es utilizando el &lt;i&gt;operador +=&lt;/i&gt;, tanto con un elemento individual como con otra colección, insertando los nuevos elementos al final de la colección:&lt;br /&gt;
&lt;pre class=&quot;hl&quot;&gt;&lt;span class=&quot;hl kwa&quot;&gt;val&lt;/span&gt; numeros &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;mutableListOf&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl str&quot;&gt;&quot;uno&quot;&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;hl str&quot;&gt;&quot;dos&quot;&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;
numeros &lt;span class=&quot;hl opt&quot;&gt;+=&lt;/span&gt; &lt;span class=&quot;hl str&quot;&gt;&quot;tres&quot;&lt;/span&gt;
&lt;span class=&quot;hl kwd&quot;&gt;println&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;numeros&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;hl slc&quot;&gt;// [uno, dos, tres]&lt;/span&gt;
numeros &lt;span class=&quot;hl opt&quot;&gt;+=&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;listOf&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl str&quot;&gt;&quot;cuatro&quot;&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;hl str&quot;&gt;&quot;cinco&quot;&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;hl kwd&quot;&gt;println&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;numeros&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;hl slc&quot;&gt;// [uno, dos, tres, cuatro, cinco]&lt;/span&gt;&lt;/pre&gt;
&lt;br /&gt;
&lt;h2&gt;Eliminar elementos&lt;/h2&gt;
Para eliminar un elemento de una colección mutable usamos la función &lt;i&gt;remove()&lt;/i&gt;, que toma un valor y, en caso de existir en la colección, elimina la primera ocurrencia de ese valor (en caso contrario no hace nada).&lt;br /&gt;
&lt;pre class=&quot;hl&quot;&gt;&lt;span class=&quot;hl kwa&quot;&gt;val&lt;/span&gt; numeros &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;mutableListOf&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl num&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;hl num&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;hl num&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;hl num&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;hl num&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;
numeros&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;remove&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl num&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;hl slc&quot;&gt;// elimina el primer 3&lt;/span&gt;
&lt;span class=&quot;hl kwd&quot;&gt;println&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;numeros&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;hl slc&quot;&gt;// [1, 2, 4, 3]&lt;/span&gt;
numeros&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;remove&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl num&quot;&gt;5&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;hl slc&quot;&gt;// no elimina nada&lt;/span&gt;
&lt;span class=&quot;hl kwd&quot;&gt;println&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;numeros&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;hl slc&quot;&gt;// [1, 2, 4, 3]&lt;/span&gt;&lt;/pre&gt;
&lt;br /&gt;
Para eliminar múltiples elementos a la vez, existen las siguientes funciones:&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;&lt;i&gt;removeAll()&lt;/i&gt;, que elimina todos los elementos que están presentes en la colección de argumentos. Alternativamente, se puede llamar con un predicado como argumento y en este caso la función elimina todos los elementos para los cuales el predicado resulta verdadero (true).&lt;/li&gt;
&lt;li&gt;&lt;i&gt;retainAll()&lt;/i&gt; que, al contrario que la anterior, elimina todos los elementos excepto los de la colección de argumentos. Cuando se usa con un predicado, deja solo los elementos que coinciden.&lt;/li&gt;
&lt;li&gt;&lt;i&gt;clear()&lt;/i&gt;, que elimina todos los elementos de una lista y la deja vacía.&lt;/li&gt;
&lt;/ul&gt;
&lt;pre class=&quot;hl&quot;&gt;&lt;span class=&quot;hl kwa&quot;&gt;val&lt;/span&gt; numeros &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;mutableListOf&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl num&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;hl num&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;hl num&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;hl num&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;hl kwd&quot;&gt;println&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;numeros&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;hl slc&quot;&gt;// [1, 2, 3, 4]&lt;/span&gt;
numeros&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;retainAll &lt;span class=&quot;hl opt&quot;&gt;{&lt;/span&gt; it &lt;span class=&quot;hl opt&quot;&gt;&amp;gt;=&lt;/span&gt; &lt;span class=&quot;hl num&quot;&gt;3&lt;/span&gt; &lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;hl kwd&quot;&gt;println&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;numeros&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;hl slc&quot;&gt;// [3, 4]&lt;/span&gt;
numeros&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;clear&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;()&lt;/span&gt;
&lt;span class=&quot;hl kwd&quot;&gt;println&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;numeros&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;hl slc&quot;&gt;// []&lt;/span&gt;

&lt;span class=&quot;hl kwa&quot;&gt;val&lt;/span&gt; numerosSet &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;mutableSetOf&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl str&quot;&gt;&quot;uno&quot;&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;hl str&quot;&gt;&quot;dos&quot;&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;hl str&quot;&gt;&quot;tres&quot;&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;hl str&quot;&gt;&quot;cuatro&quot;&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;
numerosSet&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;removeAll&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;setOf&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl str&quot;&gt;&quot;uno&quot;&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;hl str&quot;&gt;&quot;dos&quot;&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;))&lt;/span&gt;
&lt;span class=&quot;hl kwd&quot;&gt;println&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;numerosSet&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;hl slc&quot;&gt;// [tres, cuatro]&lt;/span&gt;&lt;/pre&gt;
&lt;br /&gt;
Y al igual que para agregar elementos de una colección usamos el operador +=, podemos eliminar elementos con el &lt;i&gt;operador -=&lt;/i&gt;, tanto con un elemento individual (elimina la primera aparición del mismo) como con otra colección (se eliminan todas las apariciones de sus elementos):&lt;br /&gt;
&lt;pre class=&quot;hl&quot;&gt;&lt;span class=&quot;hl kwa&quot;&gt;val&lt;/span&gt; numeros &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;mutableListOf&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl str&quot;&gt;&quot;uno&quot;&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;hl str&quot;&gt;&quot;dos&quot;&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;hl str&quot;&gt;&quot;tres&quot;&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;hl str&quot;&gt;&quot;tres&quot;&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;hl str&quot;&gt;&quot;cuatro&quot;&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;hl str&quot;&gt;&quot;cuatro&quot;&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;
numeros &lt;span class=&quot;hl opt&quot;&gt;-=&lt;/span&gt; &lt;span class=&quot;hl str&quot;&gt;&quot;tres&quot;&lt;/span&gt;
&lt;span class=&quot;hl kwd&quot;&gt;println&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;numeros&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;hl slc&quot;&gt;// [uno, dos, tres, cuatro, cuatro]&lt;/span&gt;
numeros &lt;span class=&quot;hl opt&quot;&gt;-=&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;listOf&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl str&quot;&gt;&quot;cuatro&quot;&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;hl str&quot;&gt;&quot;cinco&quot;&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;hl kwd&quot;&gt;println&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;numeros&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;hl slc&quot;&gt;// [uno, dos, tres]&lt;/span&gt;&lt;/pre&gt;
&lt;br /&gt;
Por otra parte, otras operaciones de escritura sobre colecciones consisten en &lt;b&gt;actualizar los valores&lt;/b&gt; de sus elementos, como veremos en próximas entradas cuando hablemos sobre operaciones específicas de cada tipo de colección.</content><link rel='replies' type='application/atom+xml' href='https://kotlindoc.blogspot.com/feeds/701179465979850480/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='https://kotlindoc.blogspot.com/2019/08/operaciones-con-colecciones-ix.html#comment-form' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='https://www.blogger.com/feeds/6895501055750567199/posts/default/701179465979850480'/><link rel='self' type='application/atom+xml' href='https://www.blogger.com/feeds/6895501055750567199/posts/default/701179465979850480'/><link rel='alternate' type='text/html' href='https://kotlindoc.blogspot.com/2019/08/operaciones-con-colecciones-ix.html' title='Operaciones con colecciones IX: Operaciones de escritura'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgAUuvM_4jPmYncl7JJ77FCoG8frPFHxra6d6Veyj8CUPhJOrKGmallo5SpA1cSyltL5XeKdH2XHWgXFA2qmDs-8qH2b4IF89gQeKI5F1iCneCbAcTJdrA0GRegFaS6-mKb8jvebcnA-gM/s72-c/colecEscritura.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6895501055750567199.post-1967197699118342380</id><published>2019-08-10T12:38:00.001+02:00</published><updated>2019-08-10T16:01:11.293+02:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="android básico"/><category scheme="http://www.blogger.com/atom/ns#" term="android studio"/><title type='text'>Ejercicio de diseño: de LinearLayout a ConstraintLayout</title><content type='html'>&lt;img alt=&quot;Ejercicio de diseño: de LinearLayout a ConstraintLayout&quot; border=&quot;0&quot; data-original-height=&quot;501&quot; data-original-width=&quot;809&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiPDH1B1vt2Q548tgL9VXpjJaVGs-R6HENbvmvTSmetPNCiQbkvr8fzGawBjeUoKyPlsvPP0kK_p0fLmWTV7TnBaX46r8O288RYgpjBH6STKTvwCnh-xPQfDrSf3wWHkfyRsfGypPBzWRY/s1600/dise%25C3%25B1o.png&quot; title=&quot;Ejercicio de diseño: de LinearLayout a ConstraintLayout&quot; /&gt;&lt;br /&gt;
&lt;br /&gt;
Hasta ahora hemos visto diversos conceptos relativos al diseño y la distribución de elementos en la pantalla, pero la mejor manera de familiarizarse con ellos es utilizarlos y trastear con el &lt;a href=&quot;https://kotlindoc.blogspot.com/2019/07/fundamentos-de-android-editor-grafico.html&quot;&gt;&lt;b&gt;editor de diseño&lt;/b&gt;&lt;/a&gt;. Por ello, en esta entrada vamos a practicar con el diseño de una aplicación, y concretamente vamos a transformar una aplicación diseñada a base de &lt;i&gt;LinearLayout&lt;/i&gt; para convertir el contenedor principal de elementos en un &lt;i&gt;ConstraintLayout&lt;/i&gt; (ver &lt;a href=&quot;https://kotlindoc.blogspot.com/2019/08/fundamentos-de-android-diseno-con.html&quot;&gt;Fundamentos de Android: Diseño con ConstraintLayout&lt;/a&gt;) y &lt;a name=&#39;more&#39;&gt;&lt;/a&gt;que el diseño sea más limpio reduciendo la jerarquía de elementos anidados. Además vamos utilizar otros conceptos conocidos como cadenas de elementos (&lt;i&gt;chain&lt;/i&gt;), elementos de imagen, recursos de distinto tipo (texto, dimensiones, colores, estilos, etc.) y algunos más.&lt;br /&gt;
&lt;br /&gt;
Vamos a partir del proyecto &lt;i&gt;ControlAcceso&lt;/i&gt;, que hemos ido retocando en las últimas entradas, tal como lo dejamos en &lt;a href=&quot;https://kotlindoc.blogspot.com/2019/08/data-binding-para-mostrar-datos.html&quot;&gt;Data Binding para mostrar datos&lt;/a&gt;. Concretamente, en esa entrada el código de los archivos de diseño quedó así:&lt;br /&gt;
&lt;pre class=&quot;hl&quot;&gt;&lt;span class=&quot;hl com&quot;&gt;&amp;lt;!--- activity_main.xml --&amp;gt;&lt;/span&gt;
&lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;?xml&lt;/span&gt; &lt;span class=&quot;hl kwb&quot;&gt;version&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;1.0&quot;&lt;/span&gt; &lt;span class=&quot;hl kwb&quot;&gt;encoding&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;utf-8&quot;&lt;/span&gt;&lt;span class=&quot;hl kwa&quot;&gt;?&amp;gt;&lt;/span&gt;

&lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;layout&lt;/span&gt; xmlns:&lt;span class=&quot;hl kwb&quot;&gt;android&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;http://schemas.android.com/apk/res/android&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; xmlns:&lt;span class=&quot;hl kwb&quot;&gt;tools&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;http://schemas.android.com/tools&quot;&lt;/span&gt;&lt;span class=&quot;hl kwa&quot;&gt;&amp;gt;&lt;/span&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;LinearLayout&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_width&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;match_parent&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_height&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;match_parent&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;orientation&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;vertical&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; tools:&lt;span class=&quot;hl kwb&quot;&gt;context&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;.MainActivity&quot;&lt;/span&gt;&lt;span class=&quot;hl kwa&quot;&gt;&amp;gt;&lt;/span&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;LinearLayout&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;id&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@+id/linearLayout&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwb&quot;&gt;style&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@style/estilo_linear&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_width&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;match_parent&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_height&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;wrap_content&quot;&lt;/span&gt;&lt;span class=&quot;hl kwa&quot;&gt;&amp;gt;&lt;/span&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;TextView&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;id&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@+id/user_txt&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwb&quot;&gt;style&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@style/estilo_texto&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_width&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;wrap_content&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_height&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;wrap_content&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_marginEnd&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@dimen/margen_txt_end1&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;text&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@string/usuario&quot;&lt;/span&gt; &lt;span class=&quot;hl kwa&quot;&gt;/&amp;gt;&lt;/span&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;EditText&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;id&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@+id/user_input&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwb&quot;&gt;style&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@style/estilo_texto&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_width&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;wrap_content&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_height&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;wrap_content&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;ems&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;10&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;hint&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@string/usuario&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;inputType&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;textPersonName&quot;&lt;/span&gt; &lt;span class=&quot;hl kwa&quot;&gt;/&amp;gt;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;/LinearLayout&amp;gt;&lt;/span&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;LinearLayout&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;id&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@+id/linearLayout2&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwb&quot;&gt;style&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@style/estilo_linear&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_width&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;match_parent&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_height&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;wrap_content&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;gravity&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;center_horizontal&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;orientation&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;horizontal&quot;&lt;/span&gt;&lt;span class=&quot;hl kwa&quot;&gt;&amp;gt;&lt;/span&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;TextView&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;id&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@+id/pass_txt&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwb&quot;&gt;style&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@style/estilo_texto&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_width&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;wrap_content&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_height&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;wrap_content&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_marginEnd&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@dimen/margen_txt_end2&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;text&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@string/contraseña&quot;&lt;/span&gt; &lt;span class=&quot;hl kwa&quot;&gt;/&amp;gt;&lt;/span&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;EditText&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;id&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@+id/pass_input&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwb&quot;&gt;style&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@style/estilo_texto&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_width&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;wrap_content&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_height&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;wrap_content&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;ems&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;10&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;hint&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@string/contraseña&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;inputType&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;textPassword&quot;&lt;/span&gt; &lt;span class=&quot;hl kwa&quot;&gt;/&amp;gt;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;/LinearLayout&amp;gt;&lt;/span&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;Button&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;id&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@+id/entrar_btn&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwb&quot;&gt;style&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@style/Widget.AppCompat.Button.Colored&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_width&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;wrap_content&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_height&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;wrap_content&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_gravity&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;center_horizontal&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_marginTop&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@dimen/margen_linea&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;text&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@string/btn_entrar&quot;&lt;/span&gt; &lt;span class=&quot;hl kwa&quot;&gt;/&amp;gt;&lt;/span&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;/LinearLayout&amp;gt;&lt;/span&gt;

&lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;/layout&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;pre class=&quot;hl&quot;&gt;&lt;span class=&quot;hl com&quot;&gt;&amp;lt;!--- activity_login_check.xml --&amp;gt;&lt;/span&gt;
&lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;?xml&lt;/span&gt; &lt;span class=&quot;hl kwb&quot;&gt;version&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;1.0&quot;&lt;/span&gt; &lt;span class=&quot;hl kwb&quot;&gt;encoding&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;utf-8&quot;&lt;/span&gt;&lt;span class=&quot;hl kwa&quot;&gt;?&amp;gt;&lt;/span&gt;

&lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;layout&lt;/span&gt; xmlns:&lt;span class=&quot;hl kwb&quot;&gt;android&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;http://schemas.android.com/apk/res/android&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; xmlns:&lt;span class=&quot;hl kwb&quot;&gt;tools&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;http://schemas.android.com/tools&quot;&lt;/span&gt;&lt;span class=&quot;hl kwa&quot;&gt;&amp;gt;&lt;/span&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;data&amp;gt;&lt;/span&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;variable&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwb&quot;&gt;name&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;usuario&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwb&quot;&gt;type&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;com.android.controlacceso.Usuario&quot;&lt;/span&gt; &lt;span class=&quot;hl kwa&quot;&gt;/&amp;gt;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;/data&amp;gt;&lt;/span&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;LinearLayout&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwb&quot;&gt;style&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@style/estilo_linear&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_width&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;match_parent&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_height&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;match_parent&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;orientation&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;vertical&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; tools:&lt;span class=&quot;hl kwb&quot;&gt;context&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;.LoginCheck&quot;&lt;/span&gt;&lt;span class=&quot;hl kwa&quot;&gt;&amp;gt;&lt;/span&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;TextView&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;id&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@+id/acceso_txt&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwb&quot;&gt;style&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@style/estilo_texto&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_width&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;wrap_content&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_height&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;wrap_content&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_marginTop&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@dimen/margen_linea&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;text&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@string/login_check&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;textAlignment&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;center&quot;&lt;/span&gt; &lt;span class=&quot;hl kwa&quot;&gt;/&amp;gt;&lt;/span&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;TextView&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;id&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@+id/login_txt&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwb&quot;&gt;style&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@style/estilo_texto&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_width&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;wrap_content&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_height&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;wrap_content&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_marginTop&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@dimen/margen_linea&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;text&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@={usuario.nombre}&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;textAlignment&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;center&quot;&lt;/span&gt; &lt;span class=&quot;hl kwa&quot;&gt;/&amp;gt;&lt;/span&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;LinearLayout&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_width&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;match_parent&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_height&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;wrap_content&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;orientation&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;horizontal&quot;&lt;/span&gt;&lt;span class=&quot;hl kwa&quot;&gt;&amp;gt;&lt;/span&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;EditText&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;id&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@+id/pass_txt&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwb&quot;&gt;style&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@style/estilo_texto&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_width&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;wrap_content&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_height&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;wrap_content&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_weight&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;1&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;background&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@null&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;ems&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;10&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;enabled&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;false&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;inputType&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;textPassword&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;text&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@={usuario.pass}&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;textAlignment&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;center&quot;&lt;/span&gt; &lt;span class=&quot;hl kwa&quot;&gt;/&amp;gt;&lt;/span&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;CheckBox&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;id&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@+id/checkBox&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_width&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;wrap_content&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_height&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;wrap_content&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_weight&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;1&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;text&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@string/btn_ver&quot;&lt;/span&gt; &lt;span class=&quot;hl kwa&quot;&gt;/&amp;gt;&lt;/span&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;/LinearLayout&amp;gt;&lt;/span&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;Button&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;id&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@+id/button_cerrar&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_width&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;wrap_content&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_height&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;wrap_content&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_marginTop&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@dimen/margen_linea&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;text&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@string/cerrar&quot;&lt;/span&gt; &lt;span class=&quot;hl kwa&quot;&gt;/&amp;gt;&lt;/span&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;/LinearLayout&amp;gt;&lt;/span&gt;

&lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;/layout&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;br /&gt;
En las siguientes imágenes se aprecia el editor de diseño de ambos archivos después de la conversión del &lt;i&gt;LinearLayout&lt;/i&gt; a un &lt;i&gt;ConstraintLayout&lt;/i&gt;, observándose en el árbol de componentes los elementos de diseño utilizados, y finalmente unas capturas de pantalla de la aplicación en funcionamiento:
&lt;br /&gt;
&lt;br /&gt;
&lt;img border=&quot;0&quot; data-original-height=&quot;885&quot; data-original-width=&quot;949&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgU904T3ji9zWChzX6fb0cN5PH5i8Q7_19Sd9nvXIAA2ASkYwlAXDAl9fnogguXsyvsrJTGBeL-mD4cCVkWd_UdhtuM90_QQGkCdH6Bf6mxa8nGMD_KNvvaKgdzzUk4ppaSxBCHzH8cqO0/s1600/activity_main.png&quot; /&gt;&lt;br /&gt;
&lt;img border=&quot;0&quot; data-original-height=&quot;887&quot; data-original-width=&quot;1036&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjbpID65lRD7c5TR2SheDHtubVkyIPCeqaZRlmncze2MFg5hyphenhyphen6ThDv5qSKiLYQrTchTHY_BScAxhvKq8efd8IumNY-HAk8drEdsP2DLElS79LfLUuakXIgMI0KGsRhZ5S1lCGIQCJeiqHI/s1600/activity_login.png&quot; /&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;img border=&quot;0&quot; data-original-height=&quot;1600&quot; data-original-width=&quot;900&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjclDx4m7Kf2u4YNJ87gCmnVMLNAPohsvPD0LFsMVFXhV35K88gthXDmYcV9QL8Lcjxum_ObBXSKqwOV2SS5mGnfWzgRPpjChX7_prgZ0lx4VGP734gtl96I-WRfDqE6Mwv4fM55QPalAI/s1600/app.gif&quot; /&gt;&lt;br /&gt;
&lt;br /&gt;
Como se supone que ya se conocen los métodos de aplicación de las técnicas utilizadas (en caso contrario revisar las entradas correspondientes), solo se expone el resultado final del código:&lt;br /&gt;
&lt;pre class=&quot;hl&quot;&gt;&lt;span class=&quot;hl com&quot;&gt;&amp;lt;!--- activity_main.xml --&amp;gt;&lt;/span&gt;
&lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;?xml&lt;/span&gt; &lt;span class=&quot;hl kwb&quot;&gt;version&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;1.0&quot;&lt;/span&gt; &lt;span class=&quot;hl kwb&quot;&gt;encoding&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;utf-8&quot;&lt;/span&gt;&lt;span class=&quot;hl kwa&quot;&gt;?&amp;gt;&lt;/span&gt;

&lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;layout&lt;/span&gt; xmlns:&lt;span class=&quot;hl kwb&quot;&gt;android&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;http://schemas.android.com/apk/res/android&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; xmlns:&lt;span class=&quot;hl kwb&quot;&gt;app&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;http://schemas.android.com/apk/res-auto&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; xmlns:&lt;span class=&quot;hl kwb&quot;&gt;tools&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;http://schemas.android.com/tools&quot;&lt;/span&gt;&lt;span class=&quot;hl kwa&quot;&gt;&amp;gt;&lt;/span&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;androidx&lt;/span&gt;.constraintlayout.widget.ConstraintLayout
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;id&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@+id/constraint_layout&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwb&quot;&gt;style&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@style/estilo_constraint&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; tools:&lt;span class=&quot;hl kwb&quot;&gt;context&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;.MainActivity&quot;&lt;/span&gt;&lt;span class=&quot;hl kwa&quot;&gt;&amp;gt;&lt;/span&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;TextView&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;id&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@+id/textView&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwb&quot;&gt;style&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@style/estilo_titulo&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;text&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@string/acceso&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; app:&lt;span class=&quot;hl kwb&quot;&gt;layout_constraintEnd_toEndOf&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;parent&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; app:&lt;span class=&quot;hl kwb&quot;&gt;layout_constraintStart_toStartOf&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;parent&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; app:&lt;span class=&quot;hl kwb&quot;&gt;layout_constraintTop_toTopOf&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;parent&quot;&lt;/span&gt; &lt;span class=&quot;hl kwa&quot;&gt;/&amp;gt;&lt;/span&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;ImageView&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;id&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@+id/imageView&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwb&quot;&gt;style&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@style/estilo_imagen&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;contentDescription&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@string/imagen_candado&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; app:&lt;span class=&quot;hl kwb&quot;&gt;layout_constraintEnd_toEndOf&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;parent&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; app:&lt;span class=&quot;hl kwb&quot;&gt;layout_constraintStart_toStartOf&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;parent&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; app:&lt;span class=&quot;hl kwb&quot;&gt;layout_constraintTop_toBottomOf&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@+id/textView&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; app:&lt;span class=&quot;hl kwb&quot;&gt;srcCompat&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@android:drawable/ic_secure&quot;&lt;/span&gt; &lt;span class=&quot;hl kwa&quot;&gt;/&amp;gt;&lt;/span&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;TextView&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;id&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@+id/user_txt&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwb&quot;&gt;style&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@style/estilo_texto&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_width&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;0dp&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_height&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;wrap_content&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_marginStart&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@dimen/margen16&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;text&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@string/usuario&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; app:&lt;span class=&quot;hl kwb&quot;&gt;layout_constraintBaseline_toBaselineOf&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@+id/user_input&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; app:&lt;span class=&quot;hl kwb&quot;&gt;layout_constraintEnd_toStartOf&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@+id/user_input&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; app:&lt;span class=&quot;hl kwb&quot;&gt;layout_constraintHorizontal_bias&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;0.5&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; app:&lt;span class=&quot;hl kwb&quot;&gt;layout_constraintHorizontal_chainStyle&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;packed&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; app:&lt;span class=&quot;hl kwb&quot;&gt;layout_constraintStart_toStartOf&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;parent&quot;&lt;/span&gt; &lt;span class=&quot;hl kwa&quot;&gt;/&amp;gt;&lt;/span&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;EditText&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;id&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@+id/user_input&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwb&quot;&gt;style&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@style/estilo_texto&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_width&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;0dp&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_height&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;wrap_content&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_marginTop&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@dimen/margen32&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_marginEnd&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@dimen/margen16&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;ems&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;10&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;hint&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@string/usuario&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;inputType&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;textPersonName&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;textAlignment&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;textEnd&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; app:&lt;span class=&quot;hl kwb&quot;&gt;layout_constraintEnd_toEndOf&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;parent&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; app:&lt;span class=&quot;hl kwb&quot;&gt;layout_constraintStart_toEndOf&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@+id/user_txt&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; app:&lt;span class=&quot;hl kwb&quot;&gt;layout_constraintTop_toBottomOf&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@+id/imageView&quot;&lt;/span&gt; &lt;span class=&quot;hl kwa&quot;&gt;/&amp;gt;&lt;/span&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;TextView&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;id&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@+id/pass_txt&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwb&quot;&gt;style&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@style/estilo_texto&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_width&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;0dp&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_height&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;wrap_content&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_marginStart&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@dimen/margen16&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;text&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@string/contraseña&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; app:&lt;span class=&quot;hl kwb&quot;&gt;layout_constraintBaseline_toBaselineOf&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@+id/pass_input&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; app:&lt;span class=&quot;hl kwb&quot;&gt;layout_constraintEnd_toStartOf&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@+id/pass_input&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; app:&lt;span class=&quot;hl kwb&quot;&gt;layout_constraintHorizontal_bias&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;0.5&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; app:&lt;span class=&quot;hl kwb&quot;&gt;layout_constraintStart_toStartOf&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;parent&quot;&lt;/span&gt; &lt;span class=&quot;hl kwa&quot;&gt;/&amp;gt;&lt;/span&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;EditText&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;id&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@+id/pass_input&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwb&quot;&gt;style&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@style/estilo_texto&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_width&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;0dp&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_height&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;wrap_content&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_marginTop&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@dimen/margen32&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_marginEnd&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@dimen/margen16&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;ems&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;10&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;hint&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@string/contraseña&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;inputType&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;textPassword&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;textAlignment&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;textEnd&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; app:&lt;span class=&quot;hl kwb&quot;&gt;layout_constraintEnd_toEndOf&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;parent&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; app:&lt;span class=&quot;hl kwb&quot;&gt;layout_constraintStart_toEndOf&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@+id/pass_txt&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; app:&lt;span class=&quot;hl kwb&quot;&gt;layout_constraintTop_toBottomOf&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@+id/user_input&quot;&lt;/span&gt; &lt;span class=&quot;hl kwa&quot;&gt;/&amp;gt;&lt;/span&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;Button&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;id&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@+id/entrar_btn&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwb&quot;&gt;style&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@style/Widget.AppCompat.Button.Colored&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_width&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;wrap_content&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_height&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;wrap_content&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_gravity&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;center_horizontal&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_marginBottom&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@dimen/margen32&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;text&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@string/sesion_inicio&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; app:&lt;span class=&quot;hl kwb&quot;&gt;layout_constraintBottom_toBottomOf&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;parent&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; app:&lt;span class=&quot;hl kwb&quot;&gt;layout_constraintEnd_toEndOf&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;parent&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; app:&lt;span class=&quot;hl kwb&quot;&gt;layout_constraintStart_toStartOf&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;parent&quot;&lt;/span&gt; &lt;span class=&quot;hl kwa&quot;&gt;/&amp;gt;&lt;/span&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;/androidx&lt;/span&gt;.constraintlayout.widget.ConstraintLayout&lt;span class=&quot;hl kwa&quot;&gt;&amp;gt;&lt;/span&gt;

&lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;/layout&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;pre class=&quot;hl&quot;&gt;&lt;span class=&quot;hl com&quot;&gt;&amp;lt;!--- activity_login_check.xml --&amp;gt;&lt;/span&gt;
&lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;?xml&lt;/span&gt; &lt;span class=&quot;hl kwb&quot;&gt;version&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;1.0&quot;&lt;/span&gt; &lt;span class=&quot;hl kwb&quot;&gt;encoding&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;utf-8&quot;&lt;/span&gt;&lt;span class=&quot;hl kwa&quot;&gt;?&amp;gt;&lt;/span&gt;

&lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;layout&lt;/span&gt; xmlns:&lt;span class=&quot;hl kwb&quot;&gt;android&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;http://schemas.android.com/apk/res/android&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; xmlns:&lt;span class=&quot;hl kwb&quot;&gt;app&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;http://schemas.android.com/apk/res-auto&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; xmlns:&lt;span class=&quot;hl kwb&quot;&gt;tools&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;http://schemas.android.com/tools&quot;&lt;/span&gt;&lt;span class=&quot;hl kwa&quot;&gt;&amp;gt;&lt;/span&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;data&amp;gt;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;variable&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwb&quot;&gt;name&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;usuario&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwb&quot;&gt;type&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;com.android.controlacceso.Usuario&quot;&lt;/span&gt; &lt;span class=&quot;hl kwa&quot;&gt;/&amp;gt;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;/data&amp;gt;&lt;/span&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;androidx&lt;/span&gt;.constraintlayout.widget.ConstraintLayout
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;id&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@+id/constraint_layout&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwb&quot;&gt;style&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@style/estilo_constraint&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;background&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@color/fondo&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;padding&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@dimen/padding16&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; tools:&lt;span class=&quot;hl kwb&quot;&gt;context&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;.LoginCheck&quot;&lt;/span&gt;&lt;span class=&quot;hl kwa&quot;&gt;&amp;gt;&lt;/span&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;TextView&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;id&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@+id/acceso_txt&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwb&quot;&gt;style&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@style/estilo_titulo&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_width&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;wrap_content&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_height&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;wrap_content&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;text&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@string/login_check&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;textAlignment&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;center&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; app:&lt;span class=&quot;hl kwb&quot;&gt;layout_constraintEnd_toEndOf&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;parent&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; app:&lt;span class=&quot;hl kwb&quot;&gt;layout_constraintStart_toStartOf&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;parent&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; app:&lt;span class=&quot;hl kwb&quot;&gt;layout_constraintTop_toTopOf&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;parent&quot;&lt;/span&gt; &lt;span class=&quot;hl kwa&quot;&gt;/&amp;gt;&lt;/span&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;ImageView&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;id&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@+id/imageView2&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwb&quot;&gt;style&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@style/estilo_imagen&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;contentDescription&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@string/imagen_candado_abierto&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; app:&lt;span class=&quot;hl kwb&quot;&gt;layout_constraintEnd_toEndOf&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;parent&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; app:&lt;span class=&quot;hl kwb&quot;&gt;layout_constraintStart_toStartOf&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;parent&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; app:&lt;span class=&quot;hl kwb&quot;&gt;layout_constraintTop_toBottomOf&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@+id/acceso_txt&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; app:&lt;span class=&quot;hl kwb&quot;&gt;srcCompat&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@android:drawable/ic_partial_secure&quot;&lt;/span&gt; &lt;span class=&quot;hl kwa&quot;&gt;/&amp;gt;&lt;/span&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;TextView&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;id&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@+id/login_txt&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwb&quot;&gt;style&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@style/estilo_texto&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_width&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;0dp&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_height&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;wrap_content&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_marginStart&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@dimen/margen32&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_marginTop&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@dimen/margen_linea&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_marginEnd&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@dimen/margen32&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;text&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@={usuario.nombre}&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;textAlignment&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;center&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; app:&lt;span class=&quot;hl kwb&quot;&gt;layout_constraintEnd_toEndOf&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;parent&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; app:&lt;span class=&quot;hl kwb&quot;&gt;layout_constraintStart_toStartOf&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;parent&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; app:&lt;span class=&quot;hl kwb&quot;&gt;layout_constraintTop_toBottomOf&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@+id/imageView2&quot;&lt;/span&gt; &lt;span class=&quot;hl kwa&quot;&gt;/&amp;gt;&lt;/span&gt;


&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;EditText&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;id&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@+id/pass_txt&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwb&quot;&gt;style&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@style/estilo_texto&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_width&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;wrap_content&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_height&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;wrap_content&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_marginStart&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@dimen/margen32&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_weight&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;1&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;background&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@null&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;ems&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;10&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;enabled&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;false&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;hint&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@string/code_pass&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;inputType&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;textPassword&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;text&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@={usuario.pass}&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;textAlignment&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;center&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; app:&lt;span class=&quot;hl kwb&quot;&gt;layout_constraintBaseline_toBaselineOf&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@+id/checkBox&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; app:&lt;span class=&quot;hl kwb&quot;&gt;layout_constraintEnd_toStartOf&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@+id/checkBox&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; app:&lt;span class=&quot;hl kwb&quot;&gt;layout_constraintHorizontal_bias&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;0.5&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; app:&lt;span class=&quot;hl kwb&quot;&gt;layout_constraintStart_toStartOf&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;parent&quot;&lt;/span&gt; &lt;span class=&quot;hl kwa&quot;&gt;/&amp;gt;&lt;/span&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;CheckBox&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;id&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@+id/checkBox&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_width&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;wrap_content&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_height&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;wrap_content&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_marginTop&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@dimen/margen32&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_marginEnd&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@dimen/margen8&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_weight&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;1&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;text&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@string/btn_ver&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; app:&lt;span class=&quot;hl kwb&quot;&gt;layout_constraintEnd_toEndOf&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;parent&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; app:&lt;span class=&quot;hl kwb&quot;&gt;layout_constraintHorizontal_bias&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;0.5&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; app:&lt;span class=&quot;hl kwb&quot;&gt;layout_constraintStart_toEndOf&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@+id/pass_txt&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; app:&lt;span class=&quot;hl kwb&quot;&gt;layout_constraintTop_toBottomOf&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@+id/login_txt&quot;&lt;/span&gt; &lt;span class=&quot;hl kwa&quot;&gt;/&amp;gt;&lt;/span&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;Button&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;id&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@+id/button_cerrar&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwb&quot;&gt;style&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@style/Widget.AppCompat.Button.Colored&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_width&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;wrap_content&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_height&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;wrap_content&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_marginStart&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@dimen/margen32&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_marginEnd&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@dimen/margen32&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_marginBottom&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@dimen/margen32&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;text&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@string/cerrar&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; app:&lt;span class=&quot;hl kwb&quot;&gt;layout_constraintBottom_toBottomOf&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;parent&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; app:&lt;span class=&quot;hl kwb&quot;&gt;layout_constraintEnd_toEndOf&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;parent&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; app:&lt;span class=&quot;hl kwb&quot;&gt;layout_constraintStart_toStartOf&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;parent&quot;&lt;/span&gt; &lt;span class=&quot;hl kwa&quot;&gt;/&amp;gt;&lt;/span&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;/androidx&lt;/span&gt;.constraintlayout.widget.ConstraintLayout&lt;span class=&quot;hl kwa&quot;&gt;&amp;gt;&lt;/span&gt;

&lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;/layout&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;br /&gt;
Por otra parte, hemos aprovechado estos cambios de diseño para mejorar el código del controlador del &lt;i&gt;CheckBox&lt;/i&gt; en el archivo de la actividad &lt;i&gt;LoginCheck&lt;/i&gt;, que estaba de esta manera:&lt;br /&gt;
&lt;pre class=&quot;hl&quot;&gt;binding&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;checkBox&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;setOnClickListener&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;View&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;OnClickListener &lt;span class=&quot;hl opt&quot;&gt;{&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;binding&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;checkBox&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;isChecked&lt;span class=&quot;hl opt&quot;&gt;) {&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; binding&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;passTxt&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;inputType &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; InputType&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;TYPE_CLASS_TEXT
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;hl kwa&quot;&gt;else&lt;/span&gt; &lt;span class=&quot;hl opt&quot;&gt;{&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; binding&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;passTxt&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;inputType &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; InputType&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;TYPE_CLASS_TEXT or InputType&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;TYPE_TEXT_VARIATION_PASSWORD
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;hl opt&quot;&gt;})&lt;/span&gt;&lt;/pre&gt;
para dejarlo así (lo que hace innecesaria la instrucción de importación &lt;i&gt;import android.view.View&lt;/i&gt;):&lt;br /&gt;
&lt;pre class=&quot;hl&quot;&gt;binding&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;checkBox&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;setOnClickListener &lt;span class=&quot;hl opt&quot;&gt;{&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;binding&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;checkBox&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;isChecked&lt;span class=&quot;hl opt&quot;&gt;) {&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; binding&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;passTxt&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;inputType &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; InputType&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;TYPE_CLASS_TEXT
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;hl kwa&quot;&gt;else&lt;/span&gt; &lt;span class=&quot;hl opt&quot;&gt;{&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; binding&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;passTxt&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;inputType &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; InputType&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;TYPE_CLASS_TEXT or InputType&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;TYPE_TEXT_VARIATION_PASSWORD
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt;&lt;/pre&gt;
</content><link rel='replies' type='application/atom+xml' href='https://kotlindoc.blogspot.com/feeds/1967197699118342380/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='https://kotlindoc.blogspot.com/2019/08/ejercicio-de-diseno-de-linearlayout.html#comment-form' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='https://www.blogger.com/feeds/6895501055750567199/posts/default/1967197699118342380'/><link rel='self' type='application/atom+xml' href='https://www.blogger.com/feeds/6895501055750567199/posts/default/1967197699118342380'/><link rel='alternate' type='text/html' href='https://kotlindoc.blogspot.com/2019/08/ejercicio-de-diseno-de-linearlayout.html' title='Ejercicio de diseño: de LinearLayout a ConstraintLayout'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiPDH1B1vt2Q548tgL9VXpjJaVGs-R6HENbvmvTSmetPNCiQbkvr8fzGawBjeUoKyPlsvPP0kK_p0fLmWTV7TnBaX46r8O288RYgpjBH6STKTvwCnh-xPQfDrSf3wWHkfyRsfGypPBzWRY/s72-c/dise%25C3%25B1o.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6895501055750567199.post-157528269195003644</id><published>2019-08-08T18:03:00.001+02:00</published><updated>2019-08-10T15:57:49.369+02:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="android básico"/><category scheme="http://www.blogger.com/atom/ns#" term="android studio"/><title type='text'>Data Binding para mostrar datos</title><content type='html'>&lt;img alt=&quot;Data Binding para mostrar datos en Kotlin&quot; border=&quot;0&quot; data-original-height=&quot;514&quot; data-original-width=&quot;591&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhx2Q219RSWhFMZPgCFvI6_PXyc_mGCYcf8rm_TvJ0F3-rezcHvv9btfr4Wz8AkttMxHyS57_6_AjOC2ZBS3AyNjYBzAtPbemarkuYISHy_ulToHVb6MCRGpFfcCKEXcoPHRU2rNQYzNMY/s1600/Data_Binding.png&quot; title=&quot;Data Binding para mostrar datos en Kotlin&quot; /&gt;&lt;br /&gt;
&lt;br /&gt;
En la entrada anterior (&lt;a href=&quot;https://kotlindoc.blogspot.com/2019/08/fundamentos-de-android-data-binding.html&quot;&gt;Fundamentos de Android: Data Binding&lt;/a&gt;) vimos cómo utilizar &lt;i&gt;Data Binding&lt;/i&gt; para acceder a los elementos del diseño desde la actividad. Pero además podemos usar &lt;b&gt;data binding para mostrar datos&lt;/b&gt; haciendo que los objetos de una &lt;i&gt;data class&lt;/i&gt; (ver &lt;a href=&quot;https://kotlindoc.blogspot.com/2019/05/clase-de-datos-o-data-class-en-kotlin.html&quot;&gt;Clase de datos o data class en Kotlin&lt;/a&gt;) estén directamente disponibles para un elemento del diseño.&lt;br /&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;br /&gt;
Para verlo con un ejemplo vamos a continuar con el proyecto &lt;i&gt;ControlAcceso&lt;/i&gt; como lo dejamos en &lt;a href=&quot;https://kotlindoc.blogspot.com/2019/08/fundamentos-de-android-data-binding.html&quot;&gt;la entrada sobre data binding&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;
Vemos que en el archivo &lt;i&gt;activity_login_check.xml&lt;/i&gt; el &lt;i&gt;TextView&lt;/i&gt;
 login_txt muesra el texto desde un recurso de texto 
(@string/bienvenido) que luego es cambiado por la actividad 
(binding.loginTxt.text = getString(R.string.bienvenido, user)) con el 
dato recuperado que se ha enviado desde la primera actividad con la 
clase &lt;i&gt;Intent&lt;/i&gt;. Nuestro objetivo será que la segunda actividad almacene en la clase Usuario el dato recibido y que después el &lt;i&gt;TextView&lt;/i&gt; del diseño remplace el recurso de texto por una referencia al valor almacenado en la &lt;i&gt;data class&lt;/i&gt;.&lt;br /&gt;
&lt;br /&gt;
Primero crearemos una &lt;i&gt;data class&lt;/i&gt; para el nombre de usuario y la contraseña en un nuevo archivo llamado &lt;i&gt;Usuario.kt&lt;/i&gt; en el directorio &lt;i&gt;java&lt;/i&gt; (sobre java/com/android/controlacceso -&amp;gt; &lt;i&gt;New&lt;/i&gt; -&amp;gt; &lt;i&gt;Kotlin File/Class&lt;/i&gt;):&lt;br /&gt;
&lt;pre class=&quot;hl&quot;&gt;data &lt;span class=&quot;hl kwa&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;Usuario&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl kwa&quot;&gt;var&lt;/span&gt; nombre&lt;span class=&quot;hl opt&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;hl kwb&quot;&gt;String&lt;/span&gt; &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;hl str&quot;&gt;&quot;&quot;&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;hl kwa&quot;&gt;var&lt;/span&gt; pass&lt;span class=&quot;hl opt&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;hl kwb&quot;&gt;String&lt;/span&gt; &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;hl str&quot;&gt;&quot;&quot;&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;&lt;/pre&gt;
&lt;br /&gt;
Para añadir los datos al diseño, abrimos &lt;i&gt;activity_login_check.xml&lt;/i&gt; en modo &lt;i&gt;Text&lt;/i&gt;, e insertamos la etiqueta &amp;lt;data&amp;gt; &amp;lt;/data&amp;gt; en la parte superior del diseño entre las etiquetas &amp;lt;layout&amp;gt; y &amp;lt;LinearLayout&amp;gt;:&lt;br /&gt;
&lt;pre class=&quot;hl&quot;&gt;&lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;layout&lt;/span&gt; xmlns:&lt;span class=&quot;hl kwb&quot;&gt;android&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;http://schemas.android.com/apk/res/android&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; xmlns:&lt;span class=&quot;hl kwb&quot;&gt;tools&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;http://schemas.android.com/tools&quot;&lt;/span&gt;&lt;span class=&quot;hl kwa&quot;&gt;&amp;gt;&lt;/span&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;data&amp;gt;&lt;/span&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;/data&amp;gt;&lt;/span&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;LinearLayout&lt;/span&gt;&lt;/pre&gt;
&lt;br /&gt;
Dentro de las etiquetas &amp;lt;data&amp;gt; podemos declarar variables con un nombre y un parámetro de tipo con la referencia completa a la clase:&lt;br /&gt;
&lt;pre class=&quot;hl&quot;&gt;&lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;data&amp;gt;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;variable&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwb&quot;&gt;name&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;usuario&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwb&quot;&gt;type&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;com.android.controlacceso.Usuario&quot;&lt;/span&gt; &lt;span class=&quot;hl kwa&quot;&gt;/&amp;gt;&lt;/span&gt;
&lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;/data&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;br /&gt;
Ahora en lugar de utilizar el recurso de texto para el &lt;i&gt;TextView&lt;/i&gt;, podemos hacer referencia a la variable usuario. Así, donde tenemos&lt;br /&gt;
&lt;pre class=&quot;hl&quot;&gt;android:&lt;span class=&quot;hl kwb&quot;&gt;text&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@string/bienvenido&quot;&lt;/span&gt;&lt;/pre&gt;
escribimos en su lugar:&lt;br /&gt;
&lt;pre class=&quot;hl&quot;&gt;android:&lt;span class=&quot;hl kwb&quot;&gt;text&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@={usuario.nombre}&quot;&lt;/span&gt;&lt;/pre&gt;
Donde la directiva &lt;i&gt;@={}&lt;/i&gt; sirve para obtener los datos a los que se hace referencia dentro de las llaves, y &lt;i&gt;usuario&lt;/i&gt; hace referencia a la variable que definimos antes con el mismo nombre (que apunta a la clase Usuario) y obtiene el valor de la propiedad &lt;i&gt;nombre&lt;/i&gt; de esa clase.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
En el archivo &lt;i&gt;LoginCheck.kt&lt;/i&gt;, antes de &lt;i&gt;onCreate&lt;/i&gt;, creamos una variable privada de la clase Usuario:&lt;br /&gt;
&lt;pre class=&quot;hl&quot;&gt;&lt;span class=&quot;hl kwa&quot;&gt;private&lt;/span&gt; lateinit &lt;span class=&quot;hl kwa&quot;&gt;var&lt;/span&gt; usuario&lt;span class=&quot;hl opt&quot;&gt;:&lt;/span&gt; Usuario&lt;/pre&gt;
&lt;br /&gt;
Una vez que la segunda actividad recibe el valor desde la primera actividad, le asignamos a la variable &lt;i&gt;usuario&lt;/i&gt; una instancia de la clase Usuario con ese valor:&lt;br /&gt;
&lt;pre class=&quot;hl&quot;&gt;usuario &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;Usuario&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;user&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;toString&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;())&lt;/span&gt;&lt;/pre&gt;
&lt;br /&gt;
Y utilizando el objeto de enlace (&lt;i&gt;binding object&lt;/i&gt;) asignamos el valor de esta variable a la variable del mismo nombre que hemos creado en el archivo de diseño:&lt;br /&gt;
&lt;pre class=&quot;hl&quot;&gt;binding&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;usuario &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; usuario&lt;/pre&gt;
&lt;br /&gt;
Y por tanto ya no necesitamos ajustar el valor del &lt;i&gt;TextView&lt;/i&gt; desde la actividad puesto que es accesible directamente desde el diseño:&lt;br /&gt;
&lt;pre class=&quot;hl&quot;&gt;&lt;span class=&quot;hl slc&quot;&gt;// binding.loginTxt.text = getString(R.string.bienvenido, user)&lt;/span&gt;&lt;/pre&gt;
&lt;br /&gt;
Esto puede mostrar un error porque se necesita actualizar el objeto de enlace después de realizar estos cambios; intenta resolverlo actualizando los archivos generados desde &lt;i&gt;Build&lt;/i&gt; -&amp;gt; &lt;i&gt;Clean Project&lt;/i&gt; seguido de &lt;i&gt;Build&lt;/i&gt; -&amp;gt; &lt;i&gt;Rebuild Project&lt;/i&gt;.&lt;br /&gt;
&lt;br /&gt;
Ejecutamos en el emulador para comprobar que funciona.&lt;br /&gt;
&lt;br /&gt;
También podríamos hacer que el usuario pudiera ver la contraseña introducida una vez que ha iniciado sesión. Para ello, repitiendo los pasos anteriores, debemos:&lt;br /&gt;
&lt;ol&gt;
&lt;li&gt;Enviar el valor de la contraseña desde la primera a la segunda actividad.&lt;/li&gt;
&lt;li&gt;Vincular el valor de una &lt;i&gt;view&lt;/i&gt; a la variable del diseño, y concretamente a la propiedad de la clase que nos interesa.&lt;/li&gt;
&lt;li&gt;En la actividad, crear una instancia de la clase Usuario con los valores recibidos, y almacenarla en una variable (y vincular su valor a la variable de diseño).&lt;/li&gt;
&lt;/ol&gt;
&lt;br /&gt;
Para la primera tarea, utilizamos la clase &lt;i&gt;Bundle&lt;/i&gt; para enviar varios datos a la vez:&lt;br /&gt;
&lt;pre class=&quot;hl&quot;&gt;&lt;span class=&quot;hl kwa&quot;&gt;val&lt;/span&gt; intento1 &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;Intent&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl kwa&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; LoginCheck&lt;span class=&quot;hl opt&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl kwa&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;java&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;hl kwa&quot;&gt;val&lt;/span&gt; bundle &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;Bundle&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;()&lt;/span&gt;
bundle&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;putString&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl str&quot;&gt;&quot;usuario&quot;&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; binding&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;userInput&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;text&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;toString&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;())&lt;/span&gt;
bundle&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;putString&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl str&quot;&gt;&quot;pass&quot;&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; binding&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;passInput&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;text&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;toString&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;())&lt;/span&gt;
intento1&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;putExtra&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl str&quot;&gt;&quot;datosUsuario&quot;&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; bundle&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;hl kwd&quot;&gt;startActivity&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;intento1&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;&lt;/pre&gt;
&lt;br /&gt;
En el archivo de diseño &lt;i&gt;activity_login_check.xml&lt;/i&gt; ya tenemos creada una variable que apunta a la clase Usuario de la &lt;i&gt;data class&lt;/i&gt;. Entonces en el mismo archivo, creamos un nuevo elemento (en este caso un &lt;i&gt;EditText&lt;/i&gt;) y vinculamos su valor a esa variable (a la propiedad &lt;i&gt;pass&lt;/i&gt; de la clase Usuario). Además junto a él creamos un &lt;i&gt;CheckBox&lt;/i&gt; para mostrar / ocultar la contraseña. Ambos elementos contenidos en un &lt;i&gt;LinearLayout&lt;/i&gt; horizontal sobre el botón CERRAR:&lt;br /&gt;
&lt;pre class=&quot;hl&quot;&gt;&lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;LinearLayout&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_width&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;match_parent&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_height&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;wrap_content&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;orientation&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;horizontal&quot;&lt;/span&gt;&lt;span class=&quot;hl kwa&quot;&gt;&amp;gt;&lt;/span&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;EditText&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;id&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@+id/pass_txt&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwb&quot;&gt;style&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@style/estilo_texto&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_width&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;wrap_content&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_height&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;wrap_content&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_weight&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;1&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;background&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@null&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;ems&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;10&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;enabled&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;false&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;inputType&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;textPassword&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;text&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@={usuario.pass}&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;textAlignment&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;center&quot;&lt;/span&gt; &lt;span class=&quot;hl kwa&quot;&gt;/&amp;gt;&lt;/span&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;CheckBox&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;id&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@+id/checkBox&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_width&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;wrap_content&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_height&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;wrap_content&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_weight&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;1&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;text&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@string/btn_ver&quot;&lt;/span&gt; &lt;span class=&quot;hl kwa&quot;&gt;/&amp;gt;&lt;/span&gt;

&lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;/LinearLayout&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;br /&gt;
Observa que en el &lt;i&gt;EditText&lt;/i&gt; hemos ajustado el atributo &lt;i&gt;background&lt;/i&gt; a &lt;i&gt;null&lt;/i&gt; para que no muestre la línea inferior característica de los elementos editables, el atributo &lt;i&gt;enabled&lt;/i&gt; a &lt;i&gt;false&lt;/i&gt; para que no sea editable por el usuario y el atributo &lt;i&gt;inputType&lt;/i&gt; a &lt;i&gt;textPassword&lt;/i&gt; para que por defecto no muestre el texto de la contraseña.&lt;br /&gt;
&lt;br /&gt;
En la actividad correspondiente (&lt;i&gt;LoginCheck&lt;/i&gt;), recibimos los datos desde la primera actividad y con ellos creamos una instancia de la clase usuario que almacenamos en la variable declarada previamente:&lt;br /&gt;
&lt;pre class=&quot;hl&quot;&gt;&lt;span class=&quot;hl kwa&quot;&gt;val&lt;/span&gt; bundle &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; intent&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;getBundleExtra&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl str&quot;&gt;&quot;datosUsuario&quot;&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;hl kwa&quot;&gt;val&lt;/span&gt; user &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; bundle?&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;getString&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl str&quot;&gt;&quot;usuario&quot;&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;).&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;toString&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;()&lt;/span&gt;
&lt;span class=&quot;hl kwa&quot;&gt;val&lt;/span&gt; pass &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; bundle?&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;getString&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl str&quot;&gt;&quot;pass&quot;&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;).&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;toString&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;()&lt;/span&gt;

usuario &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;Usuario&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;user&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; pass&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;&lt;/pre&gt;
&lt;br /&gt;
Además, como ya teníamos, a través del objeto de enlace asignamos a la variable del diseño los valores de la instancia de clase:&lt;br /&gt;
&lt;pre class=&quot;hl&quot;&gt;binding&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;usuario &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; usuario&lt;/pre&gt;
&lt;br /&gt;
Por último, añadimos un controlador para el &lt;i&gt;CheckBox&lt;/i&gt; para que cambie el tipo de datos introducidos en el &lt;i&gt;EditText&lt;/i&gt; en función de si está o no activado:&lt;br /&gt;
&lt;pre class=&quot;hl&quot;&gt;binding&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;checkBox&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;setOnClickListener&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;View&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;OnClickListener &lt;span class=&quot;hl opt&quot;&gt;{&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;binding&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;checkBox&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;isChecked&lt;span class=&quot;hl opt&quot;&gt;) {&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; binding&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;passTxt&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;inputType &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; InputType&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;TYPE_CLASS_TEXT
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;hl kwa&quot;&gt;else&lt;/span&gt; &lt;span class=&quot;hl opt&quot;&gt;{&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; binding&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;passTxt&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;inputType &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; InputType&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;TYPE_CLASS_TEXT or InputType&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;TYPE_TEXT_VARIATION_PASSWORD
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;hl opt&quot;&gt;})&lt;/span&gt;&lt;/pre&gt;
&lt;br /&gt;
&lt;img border=&quot;0&quot; data-original-height=&quot;579&quot; data-original-width=&quot;347&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhfWHmtPIYBAmxDWB-IVZXquUWGCVX9BqrvMYtDJQeOGAHY9BkMu9XTuVruWFiC8guzEZb4P-RZrFhW2xYxKF5s9f6wnBDS2x4Kohvqs2ZNQHh57PzZr4Qq6NkyhT78YOE416eCnS_eE9g/s1600/app.gif&quot; /&gt;&lt;br /&gt;
&lt;br /&gt;
A continuación se muestran los códigos de los archivos de las actividades y de los diseños:&lt;br /&gt;
&lt;pre class=&quot;hl&quot;&gt;&lt;span class=&quot;hl slc&quot;&gt;// MainActivity.kt&lt;/span&gt;
&lt;span class=&quot;hl kwa&quot;&gt;package&lt;/span&gt; com&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;android&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;controlacceso

&lt;span class=&quot;hl kwa&quot;&gt;import&lt;/span&gt; android&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;content&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;Intent
&lt;span class=&quot;hl kwa&quot;&gt;import&lt;/span&gt; android&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;os&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;Bundle
&lt;span class=&quot;hl kwa&quot;&gt;import&lt;/span&gt; android&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;widget&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;Toast
&lt;span class=&quot;hl kwa&quot;&gt;import&lt;/span&gt; androidx&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;appcompat&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;app&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;AppCompatActivity
&lt;span class=&quot;hl kwa&quot;&gt;import&lt;/span&gt; androidx&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;databinding&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;DataBindingUtil
&lt;span class=&quot;hl kwa&quot;&gt;import&lt;/span&gt; com&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;android&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;controlacceso&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;databinding&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;ActivityMainBinding

&lt;span class=&quot;hl kwa&quot;&gt;class&lt;/span&gt; MainActivity &lt;span class=&quot;hl opt&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;AppCompatActivity&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;() {&lt;/span&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;private&lt;/span&gt; lateinit &lt;span class=&quot;hl kwa&quot;&gt;var&lt;/span&gt; binding&lt;span class=&quot;hl opt&quot;&gt;:&lt;/span&gt; ActivityMainBinding

&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;override fun&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;onCreate&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;savedInstanceState&lt;span class=&quot;hl opt&quot;&gt;:&lt;/span&gt; Bundle?&lt;span class=&quot;hl opt&quot;&gt;) {&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;super&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;onCreate&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;savedInstanceState&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; binding &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; DataBindingUtil&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;setContentView&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl kwa&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; R&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;layout&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;activity_main&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; binding&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;entrarBtn&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;setOnClickListener &lt;span class=&quot;hl opt&quot;&gt;{&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;hl opt&quot;&gt;(!&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;esNuloVacio&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;binding&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;userInput&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;text&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;toString&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;()) &amp;amp;&amp;amp; !&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;esNuloVacio&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;binding&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;passInput&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;text&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;toString&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;())) {&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;val&lt;/span&gt; intento1 &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;Intent&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl kwa&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; LoginCheck&lt;span class=&quot;hl opt&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl kwa&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;java&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;val&lt;/span&gt; bundle &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;Bundle&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;()&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; bundle&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;putString&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl str&quot;&gt;&quot;usuario&quot;&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; binding&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;userInput&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;text&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;toString&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;())&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; bundle&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;putString&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl str&quot;&gt;&quot;pass&quot;&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; binding&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;passInput&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;text&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;toString&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;())&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; intento1&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;putExtra&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl str&quot;&gt;&quot;datosUsuario&quot;&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; bundle&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; binding&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;apply &lt;span class=&quot;hl opt&quot;&gt;{&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; userInput&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;setText&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl str&quot;&gt;&quot;&quot;&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; passInput&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;setText&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl str&quot;&gt;&quot;&quot;&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwd&quot;&gt;startActivity&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;intento1&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;hl kwa&quot;&gt;else&lt;/span&gt; &lt;span class=&quot;hl opt&quot;&gt;{&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Toast&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;makeText&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;hl str&quot;&gt;&quot;ERROR: Usuario y contraseña requeridos.&quot;&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Toast&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;LENGTH_SHORT
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl opt&quot;&gt;).&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;show&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;()&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;private fun&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;esNuloVacio&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;str&lt;span class=&quot;hl opt&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;hl kwb&quot;&gt;String&lt;/span&gt;?&lt;span class=&quot;hl opt&quot;&gt;):&lt;/span&gt; &lt;span class=&quot;hl kwb&quot;&gt;Boolean&lt;/span&gt; &lt;span class=&quot;hl opt&quot;&gt;{&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;hl opt&quot;&gt;!(&lt;/span&gt;str &lt;span class=&quot;hl opt&quot;&gt;!=&lt;/span&gt; &lt;span class=&quot;hl kwa&quot;&gt;null&lt;/span&gt; &lt;span class=&quot;hl opt&quot;&gt;&amp;amp;&amp;amp; !&lt;/span&gt;str&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;trim&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;().&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;isEmpty&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;())&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt;&lt;/pre&gt;
&lt;pre class=&quot;hl&quot;&gt;&lt;span class=&quot;hl com&quot;&gt;&amp;lt;!--- activity_main.xml --&amp;gt;&lt;/span&gt;
&lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;?xml&lt;/span&gt; &lt;span class=&quot;hl kwb&quot;&gt;version&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;1.0&quot;&lt;/span&gt; &lt;span class=&quot;hl kwb&quot;&gt;encoding&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;utf-8&quot;&lt;/span&gt;&lt;span class=&quot;hl kwa&quot;&gt;?&amp;gt;&lt;/span&gt;

&lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;layout&lt;/span&gt; xmlns:&lt;span class=&quot;hl kwb&quot;&gt;android&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;http://schemas.android.com/apk/res/android&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; xmlns:&lt;span class=&quot;hl kwb&quot;&gt;tools&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;http://schemas.android.com/tools&quot;&lt;/span&gt;&lt;span class=&quot;hl kwa&quot;&gt;&amp;gt;&lt;/span&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;LinearLayout&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_width&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;match_parent&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_height&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;match_parent&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;orientation&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;vertical&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; tools:&lt;span class=&quot;hl kwb&quot;&gt;context&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;.MainActivity&quot;&lt;/span&gt;&lt;span class=&quot;hl kwa&quot;&gt;&amp;gt;&lt;/span&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;LinearLayout&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;id&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@+id/linearLayout&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwb&quot;&gt;style&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@style/estilo_linear&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_width&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;match_parent&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_height&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;wrap_content&quot;&lt;/span&gt;&lt;span class=&quot;hl kwa&quot;&gt;&amp;gt;&lt;/span&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;TextView&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;id&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@+id/user_txt&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwb&quot;&gt;style&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@style/estilo_texto&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_width&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;wrap_content&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_height&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;wrap_content&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_marginEnd&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@dimen/margen_txt_end1&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;text&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@string/usuario&quot;&lt;/span&gt; &lt;span class=&quot;hl kwa&quot;&gt;/&amp;gt;&lt;/span&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;EditText&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;id&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@+id/user_input&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwb&quot;&gt;style&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@style/estilo_texto&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_width&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;wrap_content&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_height&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;wrap_content&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;ems&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;10&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;hint&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@string/usuario&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;inputType&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;textPersonName&quot;&lt;/span&gt; &lt;span class=&quot;hl kwa&quot;&gt;/&amp;gt;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;/LinearLayout&amp;gt;&lt;/span&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;LinearLayout&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;id&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@+id/linearLayout2&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwb&quot;&gt;style&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@style/estilo_linear&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_width&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;match_parent&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_height&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;wrap_content&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;gravity&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;center_horizontal&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;orientation&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;horizontal&quot;&lt;/span&gt;&lt;span class=&quot;hl kwa&quot;&gt;&amp;gt;&lt;/span&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;TextView&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;id&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@+id/pass_txt&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwb&quot;&gt;style&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@style/estilo_texto&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_width&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;wrap_content&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_height&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;wrap_content&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_marginEnd&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@dimen/margen_txt_end2&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;text&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@string/contraseña&quot;&lt;/span&gt; &lt;span class=&quot;hl kwa&quot;&gt;/&amp;gt;&lt;/span&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;EditText&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;id&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@+id/pass_input&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwb&quot;&gt;style&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@style/estilo_texto&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_width&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;wrap_content&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_height&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;wrap_content&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;ems&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;10&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;hint&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@string/contraseña&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;inputType&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;textPassword&quot;&lt;/span&gt; &lt;span class=&quot;hl kwa&quot;&gt;/&amp;gt;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;/LinearLayout&amp;gt;&lt;/span&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;Button&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;id&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@+id/entrar_btn&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwb&quot;&gt;style&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@style/Widget.AppCompat.Button.Colored&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_width&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;wrap_content&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_height&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;wrap_content&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_gravity&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;center_horizontal&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_marginTop&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@dimen/margen_linea&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;text&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@string/btn_entrar&quot;&lt;/span&gt; &lt;span class=&quot;hl kwa&quot;&gt;/&amp;gt;&lt;/span&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;/LinearLayout&amp;gt;&lt;/span&gt;

&lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;/layout&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;pre class=&quot;hl&quot;&gt;&lt;span class=&quot;hl slc&quot;&gt;// LoginCheck.kt&lt;/span&gt;
&lt;span class=&quot;hl kwa&quot;&gt;package&lt;/span&gt; com&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;android&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;controlacceso

&lt;span class=&quot;hl kwa&quot;&gt;import&lt;/span&gt; android&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;os&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;Bundle
&lt;span class=&quot;hl kwa&quot;&gt;import&lt;/span&gt; android&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;text&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;InputType
&lt;span class=&quot;hl kwa&quot;&gt;import&lt;/span&gt; android&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;view&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;View
&lt;span class=&quot;hl kwa&quot;&gt;import&lt;/span&gt; androidx&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;appcompat&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;app&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;AppCompatActivity
&lt;span class=&quot;hl kwa&quot;&gt;import&lt;/span&gt; androidx&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;databinding&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;DataBindingUtil
&lt;span class=&quot;hl kwa&quot;&gt;import&lt;/span&gt; com&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;android&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;controlacceso&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;databinding&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;ActivityLoginCheckBinding

&lt;span class=&quot;hl kwa&quot;&gt;class&lt;/span&gt; LoginCheck &lt;span class=&quot;hl opt&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;AppCompatActivity&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;() {&lt;/span&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;private&lt;/span&gt; lateinit &lt;span class=&quot;hl kwa&quot;&gt;var&lt;/span&gt; binding&lt;span class=&quot;hl opt&quot;&gt;:&lt;/span&gt; ActivityLoginCheckBinding

&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;private&lt;/span&gt; lateinit &lt;span class=&quot;hl kwa&quot;&gt;var&lt;/span&gt; usuario&lt;span class=&quot;hl opt&quot;&gt;:&lt;/span&gt; Usuario

&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;override fun&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;onCreate&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;savedInstanceState&lt;span class=&quot;hl opt&quot;&gt;:&lt;/span&gt; Bundle?&lt;span class=&quot;hl opt&quot;&gt;) {&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;super&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;onCreate&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;savedInstanceState&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; binding &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; DataBindingUtil&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;setContentView&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl kwa&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; R&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;layout&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;activity_login_check&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;val&lt;/span&gt; bundle &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; intent&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;getBundleExtra&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl str&quot;&gt;&quot;datosUsuario&quot;&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;val&lt;/span&gt; user &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; bundle?&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;getString&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl str&quot;&gt;&quot;usuario&quot;&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;).&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;toString&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;()&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;val&lt;/span&gt; pass &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; bundle?&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;getString&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl str&quot;&gt;&quot;pass&quot;&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;).&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;toString&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;()&lt;/span&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; usuario &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;Usuario&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;user&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; pass&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; binding&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;usuario &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; usuario

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; binding&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;checkBox&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;setOnClickListener&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;View&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;OnClickListener &lt;span class=&quot;hl opt&quot;&gt;{&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;binding&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;checkBox&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;isChecked&lt;span class=&quot;hl opt&quot;&gt;) {&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; binding&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;passTxt&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;inputType &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; InputType&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;TYPE_CLASS_TEXT
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;hl kwa&quot;&gt;else&lt;/span&gt; &lt;span class=&quot;hl opt&quot;&gt;{&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; binding&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;passTxt&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;inputType &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; InputType&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;TYPE_CLASS_TEXT or InputType&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;TYPE_TEXT_VARIATION_PASSWORD
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl opt&quot;&gt;})&lt;/span&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; binding&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;buttonCerrar&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;setOnClickListener &lt;span class=&quot;hl opt&quot;&gt;{&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwd&quot;&gt;finish&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;()&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt;&lt;/pre&gt;
&lt;pre class=&quot;hl&quot;&gt;&lt;span class=&quot;hl com&quot;&gt;&amp;lt;!--- activity_login_check.xml --&amp;gt;&lt;/span&gt;
&lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;?xml&lt;/span&gt; &lt;span class=&quot;hl kwb&quot;&gt;version&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;1.0&quot;&lt;/span&gt; &lt;span class=&quot;hl kwb&quot;&gt;encoding&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;utf-8&quot;&lt;/span&gt;&lt;span class=&quot;hl kwa&quot;&gt;?&amp;gt;&lt;/span&gt;

&lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;layout&lt;/span&gt; xmlns:&lt;span class=&quot;hl kwb&quot;&gt;android&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;http://schemas.android.com/apk/res/android&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; xmlns:&lt;span class=&quot;hl kwb&quot;&gt;tools&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;http://schemas.android.com/tools&quot;&lt;/span&gt;&lt;span class=&quot;hl kwa&quot;&gt;&amp;gt;&lt;/span&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;data&amp;gt;&lt;/span&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;variable&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwb&quot;&gt;name&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;usuario&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwb&quot;&gt;type&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;com.android.controlacceso.Usuario&quot;&lt;/span&gt; &lt;span class=&quot;hl kwa&quot;&gt;/&amp;gt;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;/data&amp;gt;&lt;/span&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;LinearLayout&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwb&quot;&gt;style&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@style/estilo_linear&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_width&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;match_parent&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_height&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;match_parent&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;orientation&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;vertical&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; tools:&lt;span class=&quot;hl kwb&quot;&gt;context&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;.LoginCheck&quot;&lt;/span&gt;&lt;span class=&quot;hl kwa&quot;&gt;&amp;gt;&lt;/span&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;TextView&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;id&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@+id/acceso_txt&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwb&quot;&gt;style&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@style/estilo_texto&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_width&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;wrap_content&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_height&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;wrap_content&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_marginTop&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@dimen/margen_linea&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;text&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@string/login_check&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;textAlignment&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;center&quot;&lt;/span&gt; &lt;span class=&quot;hl kwa&quot;&gt;/&amp;gt;&lt;/span&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;TextView&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;id&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@+id/login_txt&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwb&quot;&gt;style&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@style/estilo_texto&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_width&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;wrap_content&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_height&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;wrap_content&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_marginTop&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@dimen/margen_linea&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;text&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@={usuario.nombre}&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;textAlignment&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;center&quot;&lt;/span&gt; &lt;span class=&quot;hl kwa&quot;&gt;/&amp;gt;&lt;/span&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;LinearLayout&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_width&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;match_parent&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_height&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;wrap_content&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;orientation&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;horizontal&quot;&lt;/span&gt;&lt;span class=&quot;hl kwa&quot;&gt;&amp;gt;&lt;/span&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;EditText&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;id&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@+id/pass_txt&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwb&quot;&gt;style&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@style/estilo_texto&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_width&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;wrap_content&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_height&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;wrap_content&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_weight&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;1&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;background&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@null&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;ems&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;10&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;enabled&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;false&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;inputType&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;textPassword&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;text&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@={usuario.pass}&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;textAlignment&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;center&quot;&lt;/span&gt; &lt;span class=&quot;hl kwa&quot;&gt;/&amp;gt;&lt;/span&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;CheckBox&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;id&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@+id/checkBox&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_width&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;wrap_content&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_height&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;wrap_content&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_weight&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;1&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;text&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@string/btn_ver&quot;&lt;/span&gt; &lt;span class=&quot;hl kwa&quot;&gt;/&amp;gt;&lt;/span&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;/LinearLayout&amp;gt;&lt;/span&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;Button&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;id&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@+id/button_cerrar&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_width&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;wrap_content&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_height&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;wrap_content&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_marginTop&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@dimen/margen_linea&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;text&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@string/cerrar&quot;&lt;/span&gt; &lt;span class=&quot;hl kwa&quot;&gt;/&amp;gt;&lt;/span&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;/LinearLayout&amp;gt;&lt;/span&gt;

&lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;/layout&amp;gt;&lt;/span&gt;&lt;/pre&gt;
</content><link rel='replies' type='application/atom+xml' href='https://kotlindoc.blogspot.com/feeds/157528269195003644/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='https://kotlindoc.blogspot.com/2019/08/data-binding-para-mostrar-datos.html#comment-form' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='https://www.blogger.com/feeds/6895501055750567199/posts/default/157528269195003644'/><link rel='self' type='application/atom+xml' href='https://www.blogger.com/feeds/6895501055750567199/posts/default/157528269195003644'/><link rel='alternate' type='text/html' href='https://kotlindoc.blogspot.com/2019/08/data-binding-para-mostrar-datos.html' title='Data Binding para mostrar datos'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhx2Q219RSWhFMZPgCFvI6_PXyc_mGCYcf8rm_TvJ0F3-rezcHvv9btfr4Wz8AkttMxHyS57_6_AjOC2ZBS3AyNjYBzAtPbemarkuYISHy_ulToHVb6MCRGpFfcCKEXcoPHRU2rNQYzNMY/s72-c/Data_Binding.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6895501055750567199.post-3360825465201823710</id><published>2019-08-06T17:48:00.001+02:00</published><updated>2019-08-10T15:59:57.734+02:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="android básico"/><category scheme="http://www.blogger.com/atom/ns#" term="android studio"/><title type='text'>Fundamentos de Android: Data Binding</title><content type='html'>&lt;img alt=&quot;GoogleIO19&quot; border=&quot;0&quot; data-original-height=&quot;431&quot; data-original-width=&quot;886&quot; height=&quot;311&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg1g4WOWWHAYDOVTioHpD_qEZqdzfqRQuldEN_uWYCQmtLpxeNiO22S_Ji6_Qzn1BjqzCcivF-dTem3-Z4tdwaOTAf9kQXy7iLnVJdfLgdEuYN3zsZ9jBIocjJQH5zg_Xhy7ep-g1BuEcg/s640/GoogleIO19.gif&quot; title=&quot;GoogleIO19&quot; width=&quot;640&quot; /&gt;&lt;br /&gt;
&lt;br /&gt;
Hasta ahora hemos visto dos maneras para acceder a los elementos visuales del diseño (&lt;i&gt;views&lt;/i&gt;) desde la actividad:&lt;br /&gt;
&lt;ol&gt;
&lt;li&gt;El clásico &lt;b&gt;método findViewById&lt;/b&gt; con la referencia del recurso del elemento como argumento, por ejemplo:&lt;/li&gt;
&lt;pre class=&quot;hl&quot;&gt;&lt;span class=&quot;hl kwa&quot;&gt;val&lt;/span&gt; dadoBoton&lt;span class=&quot;hl opt&quot;&gt;:&lt;/span&gt; Button &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;findViewById&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;R&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;id&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;dado_boton&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;&lt;/pre&gt;
&lt;li&gt;Y el &quot;&lt;b&gt;método síntético&lt;/b&gt;&quot; (&lt;i&gt;synthetics&lt;/i&gt;) de las extensiones de Android de esta manera:&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;/li&gt;
&lt;pre class=&quot;hl&quot;&gt;&lt;span class=&quot;hl slc&quot;&gt;// requiere import kotlinx.android.synthetic.main.activity_main.*&lt;/span&gt;
&lt;span class=&quot;hl kwa&quot;&gt;val&lt;/span&gt; dadoBoton&lt;span class=&quot;hl opt&quot;&gt;:&lt;/span&gt; Button &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; dado_boton&lt;/pre&gt;
&lt;/ol&gt;
Sin duda la segunda opción resulta más elegante y práctica, y cada vez ha sido más usada tendiendo a sustituir a la primera. No obstante, realmente nunca ha sido una práctica formalmente recomendada; su API no fue construida por Google y es parte de las Extensiones creadas por JetBrains, y aunque Google en ocasiones también la ha usado, finalmente ha establecido que no es la mejor práctica (más información, en inglés, en &lt;a href=&quot;https://proandroiddev.com/the-argument-over-kotlin-synthetics-735305dd4ed0&quot;&gt;The Argument Over Kotlin Synthetics&lt;/a&gt;).&lt;br /&gt;
&lt;br /&gt;
Y aunque a este método se le han achacado problemas de seguridad y rendimiento, parece que en este criterio de Google ha podido influir el hecho de que no está disponible en Java, por lo que pone en cuestión la interoperabilidad de Kotlin con este lenguaje de programación. Pese a todo, en general sigue siendo una buena opción en Kotlin.&lt;br /&gt;
&lt;br /&gt;
Ante esta situación han ido apareciendo algunas alternativas para resolver, con sus ventajas e inconvenientes, esta situación, como son &lt;b&gt;Data Binding&lt;/b&gt; y &lt;b&gt;Butterknife&lt;/b&gt;. Y aunque al parecer el sucesor definitivo será &lt;b&gt;View Binding&lt;/b&gt;, que estará disponible en próximas versiones de &lt;i&gt;Android Studio&lt;/i&gt; como anunció Yigit Boyar en Google I/O&#39;19 (&lt;a href=&quot;https://www.youtube.com/watch?v=Qxj2eBmXLHg&quot;&gt;What&#39;s New in Architecture Components&lt;/a&gt;), de momento en esta entrada trataremos del uso de &lt;i&gt;Data Binding&lt;/i&gt;, la opción que actualmente defiende Google.&lt;br /&gt;
&lt;br /&gt;
&lt;img alt=&quot;Kotlin: How To Access Views&quot; border=&quot;0&quot; data-original-height=&quot;600&quot; data-original-width=&quot;1200&quot; height=&quot;320&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhNGzYge7ODVOU4kU1maWjZUmN7towoZk7B-40luay1PoxvRS1kHjrC9CFE5Q67JbRaKCzoqheeKP5wqs3eqrN_e0nXsg1hI6rP0cPrCfJvp_GR0y-pdAcRnuapCB1B9hjcxLRDGwBOcNM/s640/HowToAccessViews.jpg&quot; title=&quot;Kotlin: How To Access Views&quot; width=&quot;640&quot; /&gt;&lt;br /&gt;
&lt;br /&gt;
Hay que tener en cuenta que cada vez que se usa &lt;i&gt;findViewById&lt;/i&gt; (y también &lt;i&gt;synthetics&lt;/i&gt;) para buscar un elemento (&lt;i&gt;view&lt;/i&gt;), el sistema Android debe atravesar en tiempo de ejecución toda la jerarquía de elementos para localizarlo, lo que no es un problema en aplicaciones con diseños pequeños, pero en aplicaciones mayores y complejas puede llevar el tiempo suficiente como para ralentizar notablemente la aplicación (el almacenamiento de &lt;i&gt;views&lt;/i&gt; en variables puede ayudar, pero tampoco es la solución).&lt;br /&gt;
&lt;br /&gt;
Una solución es crear un objeto que contenga una referencia a cada &lt;i&gt;view&lt;/i&gt; y que este objeto, llamado &lt;b&gt;objeto de enlace&lt;/b&gt; (&lt;i&gt;binding object&lt;/i&gt;), pueda ser utilizado por toda la aplicación. Esta técnica se llama &lt;b&gt;enlace o vínculo de datos&lt;/b&gt; (&lt;i&gt;data binding&lt;/i&gt;) y se basa en que, una vez que se ha creado el objeto de enlace para la aplicación, se puede acceder a las &lt;i&gt;views&lt;/i&gt; y a otros datos a través de ese objeto sin tener que atravesar la jerarquía de vistas o buscar los datos.&lt;br /&gt;
&lt;br /&gt;
En general el vínculo de datos o &lt;i&gt;data binding&lt;/i&gt; tiene los siguientes beneficios:&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;El código es más corto, más fácil de leer y más fácil de mantener que el código que usa &lt;i&gt;findByView()&lt;/i&gt;.&lt;/li&gt;
&lt;li&gt;Los datos y los elementos de diseño están claramente separados.&lt;/li&gt;
&lt;li&gt;El sistema Android solo atraviesa la jerarquía de vistas una vez para obtener cada vista, lo que ocurre durante el inicio de la aplicación y no en tiempo de ejecución cuando el usuario interactúa con la aplicación.&lt;/li&gt;
&lt;li&gt;Se obtiene seguridad de tipo para acceder a las &lt;i&gt;views&lt;/i&gt;, lo que significa que el compilador valida los tipos durante la compilación y arroja un error si intenta asignar el tipo incorrecto a una variable.&lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;
Para verlo con un ejemplo vamos a partir del código del proyecto &lt;i&gt;ControlAcceso&lt;/i&gt; que vimos en &lt;a href=&quot;https://kotlindoc.blogspot.com/2019/07/fundamentos-de-android-comunicacion.html&quot;&gt;Fundamentos de Android: comunicación entre actividades&lt;/a&gt;. Cocretamente, los archivos de las actividades y del diseño quedaron así:&lt;br /&gt;
&lt;pre class=&quot;hl&quot;&gt;&lt;span class=&quot;hl slc&quot;&gt;// MainActivity.kt&lt;/span&gt;
&lt;span class=&quot;hl kwa&quot;&gt;package&lt;/span&gt; com&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;android&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;controlacceso

&lt;span class=&quot;hl kwa&quot;&gt;import&lt;/span&gt; android&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;content&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;Intent
&lt;span class=&quot;hl kwa&quot;&gt;import&lt;/span&gt; android&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;os&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;Bundle
&lt;span class=&quot;hl kwa&quot;&gt;import&lt;/span&gt; android&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;widget&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;Toast
&lt;span class=&quot;hl kwa&quot;&gt;import&lt;/span&gt; androidx&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;appcompat&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;app&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;AppCompatActivity
&lt;span class=&quot;hl kwa&quot;&gt;import&lt;/span&gt; kotlinx&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;android&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;synthetic&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;main&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;activity_main&lt;span class=&quot;hl opt&quot;&gt;.*&lt;/span&gt;

&lt;span class=&quot;hl kwa&quot;&gt;class&lt;/span&gt; MainActivity &lt;span class=&quot;hl opt&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;AppCompatActivity&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;() {&lt;/span&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;override fun&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;onCreate&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;savedInstanceState&lt;span class=&quot;hl opt&quot;&gt;:&lt;/span&gt; Bundle?&lt;span class=&quot;hl opt&quot;&gt;) {&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;super&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;onCreate&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;savedInstanceState&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwd&quot;&gt;setContentView&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;R&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;layout&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;activity_main&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; entrar_btn&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;setOnClickListener &lt;span class=&quot;hl opt&quot;&gt;{&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;hl opt&quot;&gt;(!&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;esNuloVacio&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;user_input&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;text&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;toString&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;()) &amp;amp;&amp;amp; !&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;esNuloVacio&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;pass_input&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;text&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;toString&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;())) {&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;val&lt;/span&gt; intento1 &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;Intent&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl kwa&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; LoginCheck&lt;span class=&quot;hl opt&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl kwa&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;java&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; intento1&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;putExtra&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl str&quot;&gt;&quot;usuario&quot;&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; user_input&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;text&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;toString&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;())&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; user_input&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;setText&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl str&quot;&gt;&quot;&quot;&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; pass_input&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;setText&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl str&quot;&gt;&quot;&quot;&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwd&quot;&gt;startActivity&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;intento1&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;hl kwa&quot;&gt;else&lt;/span&gt; &lt;span class=&quot;hl opt&quot;&gt;{&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Toast&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;makeText&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;hl str&quot;&gt;&quot;ERROR: Usuario y contraseña requeridos.&quot;&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Toast&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;LENGTH_SHORT
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl opt&quot;&gt;).&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;show&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;()&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;private fun&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;esNuloVacio&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;str&lt;span class=&quot;hl opt&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;hl kwb&quot;&gt;String&lt;/span&gt;?&lt;span class=&quot;hl opt&quot;&gt;):&lt;/span&gt; &lt;span class=&quot;hl kwb&quot;&gt;Boolean&lt;/span&gt; &lt;span class=&quot;hl opt&quot;&gt;{&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;hl opt&quot;&gt;!(&lt;/span&gt;str &lt;span class=&quot;hl opt&quot;&gt;!=&lt;/span&gt; &lt;span class=&quot;hl kwa&quot;&gt;null&lt;/span&gt; &lt;span class=&quot;hl opt&quot;&gt;&amp;amp;&amp;amp; !&lt;/span&gt;str&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;trim&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;().&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;isEmpty&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;())&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt;&lt;/pre&gt;
&lt;pre class=&quot;hl&quot;&gt;&lt;span class=&quot;hl com&quot;&gt;&amp;lt;!--- activity_main.xml --&amp;gt;&lt;/span&gt;
&lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;?xml&lt;/span&gt; &lt;span class=&quot;hl kwb&quot;&gt;version&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;1.0&quot;&lt;/span&gt; &lt;span class=&quot;hl kwb&quot;&gt;encoding&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;utf-8&quot;&lt;/span&gt;&lt;span class=&quot;hl kwa&quot;&gt;?&amp;gt;&lt;/span&gt;

&lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;LinearLayout&lt;/span&gt; xmlns:&lt;span class=&quot;hl kwb&quot;&gt;android&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;http://schemas.android.com/apk/res/android&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; xmlns:&lt;span class=&quot;hl kwb&quot;&gt;tools&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;http://schemas.android.com/tools&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_width&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;match_parent&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_height&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;match_parent&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;orientation&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;vertical&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; tools:&lt;span class=&quot;hl kwb&quot;&gt;context&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;.MainActivity&quot;&lt;/span&gt;&lt;span class=&quot;hl kwa&quot;&gt;&amp;gt;&lt;/span&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;LinearLayout&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;id&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@+id/linearLayout&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwb&quot;&gt;style&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@style/estilo_linear&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_width&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;match_parent&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_height&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;wrap_content&quot;&lt;/span&gt;&lt;span class=&quot;hl kwa&quot;&gt;&amp;gt;&lt;/span&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;TextView&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;id&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@+id/user_txt&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwb&quot;&gt;style&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@style/estilo_texto&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_width&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;wrap_content&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_height&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;wrap_content&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_marginEnd&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@dimen/margen_txt_end1&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;text&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@string/usuario&quot;&lt;/span&gt; &lt;span class=&quot;hl kwa&quot;&gt;/&amp;gt;&lt;/span&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;EditText&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;id&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@+id/user_input&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwb&quot;&gt;style&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@style/estilo_texto&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_width&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;wrap_content&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_height&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;wrap_content&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;ems&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;10&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;hint&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@string/usuario&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;inputType&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;textPersonName&quot;&lt;/span&gt; &lt;span class=&quot;hl kwa&quot;&gt;/&amp;gt;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;/LinearLayout&amp;gt;&lt;/span&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;LinearLayout&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;id&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@+id/linearLayout2&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwb&quot;&gt;style&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@style/estilo_linear&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_width&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;match_parent&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_height&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;wrap_content&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;gravity&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;center_horizontal&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;orientation&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;horizontal&quot;&lt;/span&gt;&lt;span class=&quot;hl kwa&quot;&gt;&amp;gt;&lt;/span&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;TextView&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;id&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@+id/pass_txt&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwb&quot;&gt;style&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@style/estilo_texto&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_width&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;wrap_content&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_height&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;wrap_content&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_marginEnd&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@dimen/margen_txt_end2&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;text&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@string/contraseña&quot;&lt;/span&gt; &lt;span class=&quot;hl kwa&quot;&gt;/&amp;gt;&lt;/span&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;EditText&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;id&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@+id/pass_input&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwb&quot;&gt;style&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@style/estilo_texto&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_width&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;wrap_content&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_height&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;wrap_content&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;ems&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;10&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;hint&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@string/contraseña&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;inputType&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;textPassword&quot;&lt;/span&gt; &lt;span class=&quot;hl kwa&quot;&gt;/&amp;gt;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;/LinearLayout&amp;gt;&lt;/span&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;Button&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;id&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@+id/entrar_btn&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwb&quot;&gt;style&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@style/Widget.AppCompat.Button.Colored&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_width&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;wrap_content&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_height&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;wrap_content&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_gravity&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;center_horizontal&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_marginTop&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@dimen/margen_linea&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;text&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@string/btn_entrar&quot;&lt;/span&gt; &lt;span class=&quot;hl kwa&quot;&gt;/&amp;gt;&lt;/span&gt;

&lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;/LinearLayout&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;pre class=&quot;hl&quot;&gt;&lt;span class=&quot;hl slc&quot;&gt;// LoginCheck.kt&lt;/span&gt;
&lt;span class=&quot;hl kwa&quot;&gt;package&lt;/span&gt; com&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;android&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;controlacceso

&lt;span class=&quot;hl kwa&quot;&gt;import&lt;/span&gt; android&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;os&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;Bundle
&lt;span class=&quot;hl kwa&quot;&gt;import&lt;/span&gt; androidx&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;appcompat&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;app&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;AppCompatActivity
&lt;span class=&quot;hl kwa&quot;&gt;import&lt;/span&gt; kotlinx&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;android&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;synthetic&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;main&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;activity_login_check&lt;span class=&quot;hl opt&quot;&gt;.*&lt;/span&gt;

&lt;span class=&quot;hl kwa&quot;&gt;class&lt;/span&gt; LoginCheck &lt;span class=&quot;hl opt&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;AppCompatActivity&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;() {&lt;/span&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;override fun&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;onCreate&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;savedInstanceState&lt;span class=&quot;hl opt&quot;&gt;:&lt;/span&gt; Bundle?&lt;span class=&quot;hl opt&quot;&gt;) {&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;super&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;onCreate&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;savedInstanceState&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwd&quot;&gt;setContentView&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;R&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;layout&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;activity_login_check&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;val&lt;/span&gt; bundle &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; intent&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;extras
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;val&lt;/span&gt; user &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; bundle?&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;getString&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl str&quot;&gt;&quot;usuario&quot;&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; login_txt&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;text &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;getString&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;R&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;string&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;bienvenido&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; user&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; button_cerrar&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;setOnClickListener &lt;span class=&quot;hl opt&quot;&gt;{&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwd&quot;&gt;finish&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;()&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt;&lt;/pre&gt;
&lt;pre class=&quot;hl&quot;&gt;&lt;span class=&quot;hl com&quot;&gt;&amp;lt;!--- activity_login_check.xml --&amp;gt;&lt;/span&gt;
&lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;?xml&lt;/span&gt; &lt;span class=&quot;hl kwb&quot;&gt;version&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;1.0&quot;&lt;/span&gt; &lt;span class=&quot;hl kwb&quot;&gt;encoding&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;utf-8&quot;&lt;/span&gt;&lt;span class=&quot;hl kwa&quot;&gt;?&amp;gt;&lt;/span&gt;

&lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;LinearLayout&lt;/span&gt; xmlns:&lt;span class=&quot;hl kwb&quot;&gt;android&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;http://schemas.android.com/apk/res/android&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; xmlns:&lt;span class=&quot;hl kwb&quot;&gt;tools&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;http://schemas.android.com/tools&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwb&quot;&gt;style&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@style/estilo_linear&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_width&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;match_parent&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_height&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;match_parent&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;orientation&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;vertical&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; tools:&lt;span class=&quot;hl kwb&quot;&gt;context&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;.LoginCheck&quot;&lt;/span&gt;&lt;span class=&quot;hl kwa&quot;&gt;&amp;gt;&lt;/span&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;TextView&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;id&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@+id/acceso_txt&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwb&quot;&gt;style&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@style/estilo_texto&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_width&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;wrap_content&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_height&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;wrap_content&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_marginTop&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@dimen/margen_linea&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;text&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@string/login_check&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;textAlignment&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;center&quot;&lt;/span&gt; &lt;span class=&quot;hl kwa&quot;&gt;/&amp;gt;&lt;/span&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;TextView&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;id&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@+id/login_txt&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwb&quot;&gt;style&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@style/estilo_texto&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_width&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;wrap_content&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_height&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;wrap_content&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_marginTop&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@dimen/margen_linea&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;text&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@string/bienvenido&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;textAlignment&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;center&quot;&lt;/span&gt; &lt;span class=&quot;hl kwa&quot;&gt;/&amp;gt;&lt;/span&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;Button&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;id&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@+id/button_cerrar&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_width&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;wrap_content&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_height&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;wrap_content&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_marginTop&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@dimen/margen_linea&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;text&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@string/cerrar&quot;&lt;/span&gt; &lt;span class=&quot;hl kwa&quot;&gt;/&amp;gt;&lt;/span&gt;
&lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;/LinearLayout&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;br /&gt;
A partir de este código vamos a configurar el vínculo de datos (&lt;i&gt;data binding&lt;/i&gt;) y lo vamos a usar para reemplazar las referencias a los elementos del diseño con llamadas al objeto de enlace o &lt;i&gt;binding object&lt;/i&gt;.&lt;br /&gt;
&lt;br /&gt;
Para usar &lt;i&gt;data binding&lt;/i&gt;, lo primero que tenemos que hacer es habilitarlo en el archivo Gradle (por defecto no está habilitado porque aumenta el tiempo de compilación y puede afectar al tiempo de inicio de la aplicación).&lt;br /&gt;
&lt;br /&gt;
Abrimos app/build.gradle (Module: app) y dentro de la sección de &lt;i&gt;android&lt;/i&gt; añadimos una sección de &lt;i&gt;dataBinding&lt;/i&gt; y lo habilitamos configurando &lt;i&gt;enabled&lt;/i&gt; en &lt;i&gt;true&lt;/i&gt;:&lt;br /&gt;
&lt;pre class=&quot;hl&quot;&gt;dataBinding &lt;span class=&quot;hl kwa&quot;&gt;{&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; enabled &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; true
&lt;span class=&quot;hl kwa&quot;&gt;}&lt;/span&gt;&lt;/pre&gt;
&lt;br /&gt;
Entonces sincronizamos el proyecto desde el aviso que ha aparecido junto a la barra de herramientas con el texto &lt;i&gt;Gradle files have changed... Sync Now&lt;/i&gt;. En caso de que no aparezca este aviso, puedes sincronizar desde &lt;i&gt;File&lt;/i&gt; &amp;gt; &lt;i&gt;Sync Project with Gradle Files&lt;/i&gt;.&lt;br /&gt;
&lt;br /&gt;
Después, para trabajar con &lt;i&gt;data binding&lt;/i&gt; debemos ajustar el diseño XML con una etiqueta &amp;lt;&lt;i&gt;layout&lt;/i&gt;&amp;gt; que será la clase raíz que contendrá el resto de elementos y grupos de elementos, lo que permite que el &lt;i&gt;binding object&lt;/i&gt; pueda reconocer los elementos que contiene. Para ello abrimos el archivo layout/activity_main.xml en vista &lt;i&gt;Text&lt;/i&gt; y añadimos &amp;lt;&lt;i&gt;layout&lt;/i&gt;&amp;gt; y &amp;lt;/&lt;i&gt;layout&lt;/i&gt;&amp;gt; como la etiqueta más externa alrededor del &amp;lt;&lt;i&gt;LinearLayout&lt;/i&gt;&amp;gt;:&lt;br /&gt;
&lt;pre class=&quot;hl&quot;&gt;&lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;layout&amp;gt;&lt;/span&gt;
&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;LinearLayout&lt;/span&gt; ... &lt;span class=&quot;hl kwa&quot;&gt;&amp;gt;&lt;/span&gt;
&amp;nbsp;&amp;nbsp; ...
&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;/LinearLayout&amp;gt;&lt;/span&gt;
&lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;/layout&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;br /&gt;
Si necesitas recolocar la sangría del código, lo puedes hacer desde &lt;i&gt;Code&lt;/i&gt; &amp;gt; &lt;i&gt;Reformat code&lt;/i&gt;. Como las declaraciones de espacio de nombres deben estar en la etiqueta más externa, las cortamos del &amp;lt;&lt;i&gt;LinearLayout&lt;/i&gt;&amp;gt; y las pegamos en la nueva etiqueta &amp;lt;&lt;i&gt;layout&lt;/i&gt;&amp;gt;:&lt;br /&gt;
&lt;pre class=&quot;hl&quot;&gt;&lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;layout&lt;/span&gt; xmlns:&lt;span class=&quot;hl kwb&quot;&gt;android&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;http://schemas.android.com/apk/res/android&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; xmlns:&lt;span class=&quot;hl kwb&quot;&gt;tools&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;http://schemas.android.com/tools&quot;&lt;/span&gt;&lt;span class=&quot;hl kwa&quot;&gt;&amp;gt;&lt;/span&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;LinearLayout&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_width&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;match_parent&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_height&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;match_parent&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;orientation&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;vertical&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; tools:&lt;span class=&quot;hl kwb&quot;&gt;context&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;.MainActivity&quot;&lt;/span&gt;&lt;span class=&quot;hl kwa&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;br /&gt;
Bien, ahora vamos a crear un objeto de enlace (&lt;i&gt;binding object&lt;/i&gt;) en la actividad principal de modo que nos sirva para acceder a las &lt;i&gt;views&lt;/i&gt;. Abrimos el archivo MainActivity.tk y antes de &lt;i&gt;onCreate()&lt;/i&gt;, a nivel superior, creamos una varible (habitualmente llamada &lt;i&gt;binding&lt;/i&gt;) para almacenar este objeto:&lt;br /&gt;
&lt;pre class=&quot;hl&quot;&gt;&lt;span class=&quot;hl kwa&quot;&gt;private&lt;/span&gt; lateinit &lt;span class=&quot;hl kwa&quot;&gt;var&lt;/span&gt; binding&lt;span class=&quot;hl opt&quot;&gt;:&lt;/span&gt; ActivityMainBinding&lt;/pre&gt;
&lt;br /&gt;
El tipo de la variable &lt;i&gt;binding&lt;/i&gt;, la clase &lt;i&gt;ActivityMainBinding&lt;/i&gt;, es creado específicamente para esta actividad y su nombre se deriva del nombre del archivo de diseño, que es &lt;i&gt;activity_main&lt;/i&gt;, más &lt;i&gt;Binding&lt;/i&gt;. Al crear esta variable, &lt;i&gt;Android Studio&lt;/i&gt; ha solicitado la importación de ActivityMainBinding, que se ve así:&lt;br /&gt;
&lt;pre class=&quot;hl&quot;&gt;&lt;span class=&quot;hl kwa&quot;&gt;import&lt;/span&gt; com&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;android&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;controlacceso&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;databinding&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;ActivityMainBinding&lt;/pre&gt;
&lt;br /&gt;
También tenemos que reemplazar la actual función &lt;i&gt;setContentView()&lt;/i&gt; con una instrucción que crea el objeto de enlace y asocia, con el método &lt;i&gt;setContentView&lt;/i&gt; de la clase &lt;i&gt;DataBindingUtil&lt;/i&gt; (que tiene que ser importada), la actividad de MainActivity (&lt;i&gt;this&lt;/i&gt;) con el diseño de activity_main:&lt;br /&gt;
&lt;pre class=&quot;hl&quot;&gt;&lt;span class=&quot;hl slc&quot;&gt;//setContentView(R.layout.activity_main)&lt;/span&gt;
binding &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; DataBindingUtil&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;setContentView&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl kwa&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; R&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;layout&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;activity_main&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;&lt;/pre&gt;
&lt;br /&gt;
Ahora ya podemos reemplazar en el código todas las llamadas a las &lt;i&gt;views&lt;/i&gt; con referencias mediante el objeto de enlace (&lt;i&gt;binding data&lt;/i&gt;), teniendo en cuenta que el compilador genera los nombres de las &lt;i&gt;views&lt;/i&gt; en el objeto a partir de sus ID, transformando sus nombres en formato &lt;i&gt;camelCase&lt;/i&gt; (por ejemplo, done_button será doneButton en el &lt;i&gt;binding object&lt;/i&gt;). Así, en nuestro código tenemos la llamada a &lt;i&gt;entrar_btn&lt;/i&gt; que la podemos remplazar por &lt;i&gt;binding.entrarBtn&lt;/i&gt; de esta manera:&lt;br /&gt;
&lt;pre class=&quot;hl&quot;&gt;&lt;span class=&quot;hl slc&quot;&gt;//entrar_btn.setOnClickListener {&lt;/span&gt;
binding&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;entrarBtn&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;setOnClickListener &lt;span class=&quot;hl opt&quot;&gt;{&lt;/span&gt;&lt;/pre&gt;
&lt;br /&gt;
Repetimos con el resto de llamadas a los elementos del diseño, quedando el archivo MainActivity.tk así (se han mantenido comentadas las llamadas a las &lt;i&gt;views&lt;/i&gt;):&lt;br /&gt;
&lt;pre class=&quot;hl&quot;&gt;&lt;span class=&quot;hl kwa&quot;&gt;package&lt;/span&gt; com&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;android&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;controlacceso

&lt;span class=&quot;hl kwa&quot;&gt;import&lt;/span&gt; android&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;content&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;Intent
&lt;span class=&quot;hl kwa&quot;&gt;import&lt;/span&gt; android&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;os&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;Bundle
&lt;span class=&quot;hl kwa&quot;&gt;import&lt;/span&gt; android&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;widget&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;Toast
&lt;span class=&quot;hl kwa&quot;&gt;import&lt;/span&gt; androidx&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;appcompat&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;app&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;AppCompatActivity
&lt;span class=&quot;hl kwa&quot;&gt;import&lt;/span&gt; androidx&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;databinding&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;DataBindingUtil
&lt;span class=&quot;hl kwa&quot;&gt;import&lt;/span&gt; com&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;android&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;controlacceso&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;databinding&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;ActivityMainBinding
&lt;span class=&quot;hl slc&quot;&gt;//import kotlinx.android.synthetic.main.activity_main.*&lt;/span&gt;

&lt;span class=&quot;hl kwa&quot;&gt;class&lt;/span&gt; MainActivity &lt;span class=&quot;hl opt&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;AppCompatActivity&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;() {&lt;/span&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;private&lt;/span&gt; lateinit &lt;span class=&quot;hl kwa&quot;&gt;var&lt;/span&gt; binding&lt;span class=&quot;hl opt&quot;&gt;:&lt;/span&gt; ActivityMainBinding

&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;override fun&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;onCreate&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;savedInstanceState&lt;span class=&quot;hl opt&quot;&gt;:&lt;/span&gt; Bundle?&lt;span class=&quot;hl opt&quot;&gt;) {&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;super&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;onCreate&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;savedInstanceState&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl slc&quot;&gt;//setContentView(R.layout.activity_main)&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; binding &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; DataBindingUtil&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;setContentView&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl kwa&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; R&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;layout&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;activity_main&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl slc&quot;&gt;//entrar_btn.setOnClickListener {&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; binding&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;entrarBtn&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;setOnClickListener &lt;span class=&quot;hl opt&quot;&gt;{&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl slc&quot;&gt;//if (!esNuloVacio(user_input.text.toString()) &amp;amp;&amp;amp; !esNuloVacio(pass_input.text.toString())) {&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;hl opt&quot;&gt;(!&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;esNuloVacio&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;binding&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;userInput&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;text&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;toString&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;()) &amp;amp;&amp;amp; !&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;esNuloVacio&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;binding&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;passInput&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;text&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;toString&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;())) {&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;val&lt;/span&gt; intento1 &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;Intent&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl kwa&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; LoginCheck&lt;span class=&quot;hl opt&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl kwa&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;java&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl slc&quot;&gt;//intento1.putExtra(&quot;usuario&quot;, user_input.text.toString())&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; intento1&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;putExtra&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl str&quot;&gt;&quot;usuario&quot;&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; binding&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;userInput&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;text&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;toString&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;())&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl slc&quot;&gt;//user_input.setText(&quot;&quot;)&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; binding&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;userInput&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;setText&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl str&quot;&gt;&quot;&quot;&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl slc&quot;&gt;//pass_input.setText(&quot;&quot;)&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; binding&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;passInput&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;setText&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl str&quot;&gt;&quot;&quot;&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwd&quot;&gt;startActivity&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;intento1&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;hl kwa&quot;&gt;else&lt;/span&gt; &lt;span class=&quot;hl opt&quot;&gt;{&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Toast&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;makeText&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;hl str&quot;&gt;&quot;ERROR: Usuario y contraseña requeridos.&quot;&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Toast&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;LENGTH_SHORT
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl opt&quot;&gt;).&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;show&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;()&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;private fun&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;esNuloVacio&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;str&lt;span class=&quot;hl opt&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;hl kwb&quot;&gt;String&lt;/span&gt;?&lt;span class=&quot;hl opt&quot;&gt;):&lt;/span&gt; &lt;span class=&quot;hl kwb&quot;&gt;Boolean&lt;/span&gt; &lt;span class=&quot;hl opt&quot;&gt;{&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;hl opt&quot;&gt;!(&lt;/span&gt;str &lt;span class=&quot;hl opt&quot;&gt;!=&lt;/span&gt; &lt;span class=&quot;hl kwa&quot;&gt;null&lt;/span&gt; &lt;span class=&quot;hl opt&quot;&gt;&amp;amp;&amp;amp; !&lt;/span&gt;str&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;trim&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;().&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;isEmpty&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;())&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt;&lt;/pre&gt;
&lt;br /&gt;
Como vemos, ya no es necesaria la importación de kotlinx.android.synthetic.&lt;br /&gt;
&lt;br /&gt;
Aplicamos los mismos pasos para la actividad LoginCheck.kt y su archivo de diseño activity_login_check.xml:&lt;br /&gt;
&lt;ol&gt;
&lt;li&gt;Etiqueta &amp;lt;&lt;i&gt;layout&lt;/i&gt;&amp;gt; en el archivo de diseño como elemento raíz, con las correspondientes declaraciones de espacio de nombres.&lt;/li&gt;
&lt;li&gt;Creamos la varible que almacena el &lt;i&gt;binding object&lt;/i&gt; (e importamos la clase correspondiente).&lt;/li&gt;
&lt;li&gt;Creamos el objeto de enlace y asociamos la actividad con su diseño.&lt;/li&gt;
&lt;li&gt;Remplazamos las llamadas a las &lt;i&gt;views&lt;/i&gt; por referencias en el objeto.&lt;/li&gt;
&lt;/ol&gt;
&lt;br /&gt;
&lt;u&gt;Nota&lt;/u&gt;: si &lt;i&gt;Android Studio&lt;/i&gt; advierte de algún error en el paso 2, y concretamente de un error como &lt;i&gt;Unresolved reference: databinding...&lt;/i&gt;, intenta resolverlo actualizando los archivos generados desde &lt;i&gt;Build&lt;/i&gt; -&amp;gt; &lt;i&gt;Clean Project&lt;/i&gt; seguido de &lt;i&gt;Build&lt;/i&gt; &amp;gt; &lt;i&gt;Rebuild Project&lt;/i&gt;. Si no se soluciona, prueba con &lt;i&gt;File&lt;/i&gt; &amp;gt; &lt;i&gt;Invalidate Caches/Restart&lt;/i&gt; para realizar una limpieza más exhaustiva.&lt;br /&gt;
&lt;br /&gt;
Aplicando estos cambios, el archivo LoginCheck.kt nos queda así:&lt;br /&gt;
&lt;pre class=&quot;hl&quot;&gt;&lt;span class=&quot;hl kwa&quot;&gt;package&lt;/span&gt; com&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;android&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;controlacceso

&lt;span class=&quot;hl kwa&quot;&gt;import&lt;/span&gt; android&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;os&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;Bundle
&lt;span class=&quot;hl kwa&quot;&gt;import&lt;/span&gt; androidx&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;appcompat&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;app&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;AppCompatActivity
&lt;span class=&quot;hl kwa&quot;&gt;import&lt;/span&gt; androidx&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;databinding&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;DataBindingUtil
&lt;span class=&quot;hl kwa&quot;&gt;import&lt;/span&gt; com&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;android&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;controlacceso&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;databinding&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;ActivityLoginCheckBinding

&lt;span class=&quot;hl kwa&quot;&gt;class&lt;/span&gt; LoginCheck &lt;span class=&quot;hl opt&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;AppCompatActivity&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;() {&lt;/span&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;private&lt;/span&gt; lateinit &lt;span class=&quot;hl kwa&quot;&gt;var&lt;/span&gt; binding&lt;span class=&quot;hl opt&quot;&gt;:&lt;/span&gt; ActivityLoginCheckBinding

&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;override fun&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;onCreate&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;savedInstanceState&lt;span class=&quot;hl opt&quot;&gt;:&lt;/span&gt; Bundle?&lt;span class=&quot;hl opt&quot;&gt;) {&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;super&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;onCreate&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;savedInstanceState&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; binding &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; DataBindingUtil&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;setContentView&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl kwa&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; R&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;layout&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;activity_login_check&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;val&lt;/span&gt; bundle &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; intent&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;extras
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;val&lt;/span&gt; user &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; bundle?&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;getString&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl str&quot;&gt;&quot;usuario&quot;&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; binding&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;loginTxt&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;text &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;getString&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;R&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;string&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;bienvenido&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; user&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; binding&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;buttonCerrar&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;setOnClickListener &lt;span class=&quot;hl opt&quot;&gt;{&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwd&quot;&gt;finish&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;()&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt;&lt;/pre&gt;
&lt;br /&gt;
Ejecuta la aplicación en el emulador para comprobar que funciona. De esta manera hemos conseguido utilizar referencias de los elementos del diseño de una manera más sofisticada con &lt;i&gt;binding&lt;/i&gt;. Además, en ocasiones podemos agrupar instrucciones &lt;i&gt;binding&lt;/i&gt; usando la función &lt;i&gt;apply{}&lt;/i&gt;:&lt;br /&gt;
&lt;pre class=&quot;hl&quot;&gt;&lt;span class=&quot;hl slc&quot;&gt;// binding.userInput.setText(&quot;&quot;)&lt;/span&gt;
&lt;span class=&quot;hl slc&quot;&gt;// binding.passInput.setText(&quot;&quot;)&lt;/span&gt;
binding&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;apply &lt;span class=&quot;hl opt&quot;&gt;{&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; userInput&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;setText&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl str&quot;&gt;&quot;&quot;&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; passInput&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;setText&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl str&quot;&gt;&quot;&quot;&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt;&lt;/pre&gt;
</content><link rel='replies' type='application/atom+xml' href='https://kotlindoc.blogspot.com/feeds/3360825465201823710/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='https://kotlindoc.blogspot.com/2019/08/fundamentos-de-android-data-binding.html#comment-form' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='https://www.blogger.com/feeds/6895501055750567199/posts/default/3360825465201823710'/><link rel='self' type='application/atom+xml' href='https://www.blogger.com/feeds/6895501055750567199/posts/default/3360825465201823710'/><link rel='alternate' type='text/html' href='https://kotlindoc.blogspot.com/2019/08/fundamentos-de-android-data-binding.html' title='Fundamentos de Android: Data Binding'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg1g4WOWWHAYDOVTioHpD_qEZqdzfqRQuldEN_uWYCQmtLpxeNiO22S_Ji6_Qzn1BjqzCcivF-dTem3-Z4tdwaOTAf9kQXy7iLnVJdfLgdEuYN3zsZ9jBIocjJQH5zg_Xhy7ep-g1BuEcg/s72-c/GoogleIO19.gif" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6895501055750567199.post-4328293334879004001</id><published>2019-08-04T16:35:00.000+02:00</published><updated>2019-08-10T16:02:28.116+02:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="android básico"/><category scheme="http://www.blogger.com/atom/ns#" term="android studio"/><title type='text'>Fundamentos de Android: Diseño con ConstraintLayout</title><content type='html'>&lt;img alt=&quot;Fundamentos de Android: Diseño con ConstraintLayout&quot; border=&quot;0&quot; data-original-height=&quot;800&quot; data-original-width=&quot;1600&quot; height=&quot;320&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh4LgX1_wi90-k0pzKs5Z9fakaN8bhAYv1WeOD56Rqi0cpPxsDswXVZMdAt4gcD_HZ474-xH6UXRKKeP-4PGivsEQlH4pZ785LDQldeJM52L1087aKC_rdbXn-hVjlAm2w15Ti1It4s6bE/s640/constraint_layout.png&quot; title=&quot;Fundamentos de Android: Diseño con ConstraintLayout&quot; width=&quot;640&quot; /&gt;&lt;br /&gt;
&lt;br /&gt;
Hasta ahora en nuestros diseños hemos utilizado &lt;i&gt;LinearLayout&lt;/i&gt; como contenedor de elementos. En esta entrada vamos a utilizar &lt;i&gt;ConstraintLayout&lt;/i&gt; para realizar el diseño de una aplicación sencilla, además de repasar otros conceptos ya conocidos como, por ejemplo, el manejo de recursos de distinto tipo (dimensiones, texto, estilos, fuentes...) y la interacción del usuario que puedes revisar en entradas previas.&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
Un &lt;i&gt;ConstraintLayout&lt;/i&gt; es un &lt;b&gt;contenedor de elementos&lt;/b&gt; o &lt;i&gt;ViewGroup&lt;/i&gt; (grupo de vistas), disponible a partir de API 9, que permite posicionar y dimensionar otros elementos o vistas (&lt;i&gt;views&lt;/i&gt;) de manera &lt;b&gt;flexible&lt;/b&gt;. Este tipo de contenedor permite crear diseños complejos sin otros grupos anidados. Además, es muy fácil de usar directamente desde el editor de diseño, arrastrando los elementos sin necesidad de editar el código XML.&lt;br /&gt;
&lt;br /&gt;
Podemos entender un &lt;i&gt;constraint&lt;/i&gt; (quizá en este contexto se puede traducir como &lt;b&gt;fijación o sujeción&lt;/b&gt;) como una &lt;b&gt;conexión o alineación entre dos elementos&lt;/b&gt; en la interfaz de usuario; y cada una conecta o alinea un elemento con otro, con el elemento padre o con una guía no visible. En este tipo de diseño, posicionamos cada elemento definiendo al menos una &lt;b&gt;referencia horizontal y vertical&lt;/b&gt; respecto a otros elementos.&lt;br /&gt;
&lt;br /&gt;
Vamos a practicar con este diseño creando un nuevo proyecto en &lt;i&gt;Android Studio&lt;/i&gt; a partir de una actividad vacía (&lt;i&gt;Empty Activity&lt;/i&gt;). Como sabemos, esta plantilla utiliza en el diseño un &lt;i&gt;ConstraintLayout&lt;/i&gt; como grupo raíz por defecto (además de un &lt;i&gt;TextView&lt;/i&gt; con el texto &quot;Hello World!&quot;):&lt;br /&gt;
&lt;br /&gt;
&lt;img border=&quot;0&quot; data-original-height=&quot;715&quot; data-original-width=&quot;904&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh-JkD7_irmbwDykMnDdLR1Idq6g5oe50lfOFFGb3j1ovR_w_9SWvsGGlqY0n7JpRRIACvN5oR3PDW4ct0cCsQvs7wZl7fvwie-w3luPKqfTlZ1X-8lI2Yuf5qsjILiEKkQARulzjhg8_Y/s1600/newProject.png&quot; /&gt;&lt;br /&gt;
&lt;br /&gt;
Abrimos &lt;i&gt;layout/activity_main.xml&lt;/i&gt; en la vista &lt;i&gt;Design&lt;/i&gt;. Como vamos a ajustar el diseño manualmente, debemos desactivar la conexión automática de elementos; nos aseguramos que está desactivada desde un botón en la barra de herramientas como se ve en la imagen:&lt;br /&gt;
&lt;br /&gt;
&lt;img border=&quot;0&quot; data-original-height=&quot;264&quot; data-original-width=&quot;698&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjtCOQf8TgbN1g1jPIovKAlV1-ml9fenphfYOW8_9dI83c-ob_5aMc8NagSaUCsSbuoq-HjPbTKnXrJ-jGUR9yXs8WniZu57d-uRrJ0xXG6cYjvQeQCiFluhgLhu_M93ERid55L2TjgTSI/s1600/autoOff.png&quot; /&gt;&lt;br /&gt;
&lt;br /&gt;
Junto al botón &lt;i&gt;Autoconnect&lt;/i&gt; está el botón para establecer los márgenes por defecto (&lt;i&gt;Default Margins&lt;/i&gt;) cuyo valor predeterminado es 8dp; lo ajustamos a 16dp, para que a partir de ahora se aplique a los nuevos &lt;i&gt;constraints&lt;/i&gt; que utilicemos.&lt;br /&gt;
&lt;br /&gt;
&lt;img border=&quot;0&quot; data-original-height=&quot;276&quot; data-original-width=&quot;693&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiXdAZJhJLHNI06tSaxG_2kDC7aZ62mT_kKFSdAwe0h5lIODTHqHio7pj7hUviWLUHYSyjEvaWm98PstD-0kHB_t_Hxc__2bT7QTI26k7UcHFv935FwT35JhMLdq0y8_C747cz8ZH1CN2w/s1600/defaultMargins.png&quot; /&gt;&lt;br /&gt;
&lt;br /&gt;
Seleccionamos el &lt;i&gt;TextView&lt;/i&gt; y nos fijamos que en el panel de atributos vemos el &lt;b&gt;inspector de elementos&lt;/b&gt; (&lt;i&gt;view inspector&lt;/i&gt;), que solo está disponible para los elementos contenidos en un &lt;i&gt;ConstraintLayout&lt;/i&gt;. Este inspector incluye controles para ajustar atributos del diseño como los &lt;i&gt;constraints&lt;/i&gt;, los tipos de &lt;i&gt;constraint&lt;/i&gt;, el descentramiento o desviación horizontal y vertical (&lt;i&gt;constraint bias&lt;/i&gt;) y los márgenes.&lt;br /&gt;
&lt;br /&gt;
&lt;img alt=&quot;Inspector de elementos (view inspector)&quot; border=&quot;0&quot; data-original-height=&quot;211&quot; data-original-width=&quot;538&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhg3AmtH2Uo7RoyCuDgrqTErPa3uzOorPfpHoxcP7DoziPDIcqIzbIH41SFmQa06BdivyvhAPIs3h61DVvv7g_d28-Ei46-vzqowulAlRQtN_PZzBD4UKrUNoLmwv0cPlgJTVJPIHUqMCM/s1600/inspector.png&quot; title=&quot;Inspector de elementos (view inspector)&quot; /&gt;&lt;br /&gt;
&lt;br /&gt;
Vamos a practicar con el inspector de elementos o vistas. Por ejemplo, el atributo de desviación (&lt;i&gt;constraint bias&lt;/i&gt;) posiciona el elemento a lo largo de los ejes horizontal y vertical (por defecto todo elemento se centra con un valor del 50%). Para cambiar los valores debemos arrastrar los controles deslizantes sobre los ejes y comprobamos que simultáneamente cambia la posición del &lt;i&gt;TextView&lt;/i&gt; en los ejes de la pantalla.&lt;br /&gt;
&lt;br /&gt;
Observamos en el inspector de vistas que el valor para los cuatro márgenes (izquierdo, derecho, superior e inferior) es 0; desde el desplegable, a los tres primeros lo cambiamos a 16 (que es 16dp). Podemos comprobar en la vista &lt;i&gt;Text&lt;/i&gt; que se han añadido estos valores:&lt;br /&gt;
&lt;pre class=&quot;hl&quot;&gt;android:&lt;span class=&quot;hl kwb&quot;&gt;layout_marginLeft&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;16dp&quot;&lt;/span&gt;
android:&lt;span class=&quot;hl kwb&quot;&gt;layout_marginTop&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;16dp&quot;&lt;/span&gt;
android:&lt;span class=&quot;hl kwb&quot;&gt;layout_marginRight&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;16dp&quot;&lt;/span&gt;&lt;/pre&gt;
&lt;br /&gt;
En el inspector de vistas, las flechas dentro del cuadrado representan un tipo de &lt;i&gt;constraint&lt;/i&gt;, con tres tipos posibles que cambian sucesivamente al pulsar sobre ellas:&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;&lt;i&gt;Wrap Content&lt;/i&gt;: el elemento se expande solo lo necesario para ajustarse a su contenido.&lt;/li&gt;
&lt;li&gt;&lt;i&gt;Fixed&lt;/i&gt;: se especifica una dimensión fija para los márgenes del elemento.&lt;/li&gt;
&lt;li&gt;&lt;i&gt;Match Constraints&lt;/i&gt;: el elemento se expande tanto como sea posible (teniendo en cuenta los márgenes propios). Este tipo es muy flexible ya que permite que el diseño se adapte a diferentes tamaños y orientaciones de pantalla.&lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;
En nuestra aplicación, cambiamos izquierda y derecha a &lt;i&gt;Match Constraints&lt;/i&gt;:&lt;br /&gt;
&lt;br /&gt;
&lt;img border=&quot;0&quot; data-original-height=&quot;212&quot; data-original-width=&quot;492&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgQZQfCD1zUrqZmIiWMDxssANFkK27jtOSCmrXV_jr1SCn-alMqKkuZJlxe_ohwBTFiHgS58N6DIGYikdiNMcEh5GWMPgUDFqPrPo0XzJTFt6YefFdAeBGTW3E0L6_PveT6RzmN3ylO5l8/s1600/match.png&quot; /&gt;&lt;br /&gt;
&lt;br /&gt;
En el inspector de vistas, eliminamos la fijación inferior pulsando en el punto &lt;i&gt;Delete Bottom Constraint&lt;/i&gt;. Ahora pasamos a la vista &lt;i&gt;Text&lt;/i&gt;, y en el atributo &lt;i&gt;android:layout_marginLeft&lt;/i&gt; extraemos el recurso de dimensión con el nombre margen_ancho:&lt;br /&gt;
&lt;br /&gt;
&lt;img border=&quot;0&quot; data-original-height=&quot;436&quot; data-original-width=&quot;423&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhaTNPAM9FUNZfA-lYenEeo-gROJvx_4_gSOHTqcVFO_ONYJ8y5y8XbIffQr6LvYGoZGFheittbTFoH-Cfg6aRzV8dnE86U4nCk10Km4FW6BLc5E-XhDBurZojTKWY1r1CeSlzG7nElk_Q/s1600/margen_ancho.png&quot; /&gt;&lt;br /&gt;
&lt;br /&gt;
Y lo aplicamos a los márgenes superior y derecho:&lt;br /&gt;
&lt;pre class=&quot;hl&quot;&gt;android:&lt;span class=&quot;hl kwb&quot;&gt;layout_marginLeft&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@dimen/margen_ancho&quot;&lt;/span&gt;
android:&lt;span class=&quot;hl kwb&quot;&gt;layout_marginTop&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@dimen/margen_ancho&quot;&lt;/span&gt;
android:&lt;span class=&quot;hl kwb&quot;&gt;layout_marginRight&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@dimen/margen_ancho&quot;&lt;/span&gt;&lt;/pre&gt;
&lt;br /&gt;
Ahora, desde el panel de atributos, le podemos agregar una tipografía desplegando el campo &lt;i&gt;fontFamily&lt;/i&gt; y seleccionando &lt;i&gt;More Fonts&lt;/i&gt; para abrir la ventana &lt;i&gt;Resources&lt;/i&gt;; buscamos roboto y seleccionamos Roboto -&amp;gt; Regular; y la añadimos al proyecto:&lt;br /&gt;
&lt;br /&gt;
&lt;img border=&quot;0&quot; data-original-height=&quot;725&quot; data-original-width=&quot;773&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgTCwgA1hBcf1xs2qEWYTlZLHfOSLxygdWi4_8Cpn09BanQLI8D6ZSI4q_P0eGzWXJsEqB2VIR1efyfMosKYxTlLOm7E6AN9B0TNomhyphenhyphenjmY6YEPKD84pdqb8QNAkU7yP_atSdmgOwoFOGI/s1600/Resources_font.png&quot; /&gt;&lt;br /&gt;
&lt;br /&gt;
Esto agrega la carpeta res/font que contiene el archivo de fuente roboto.ttf. Además, en la vista &lt;i&gt;Text&lt;/i&gt; tenemos el atributo &lt;i&gt;android:fontFamily=&quot;@font/roboto&quot;&lt;/i&gt;. En el atributo &lt;i&gt;textSize&lt;/i&gt; le asignamos un valor de 24sp para el tamaño de la fuente y con el botón de los tres puntos creamos un nuevo recurso de dimensión:&lt;br /&gt;
&lt;br /&gt;
&lt;img border=&quot;0&quot; data-original-height=&quot;436&quot; data-original-width=&quot;423&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhQ4JU7sH1ItTl1E0sKVxMwKObfCKxaWKs62F_UUKZQs7I3cxjms7HAj6HrKDxQZ74doOG39rKXJGE1OtobepHcDWRApRM40ZTmovdT4IAs0vBhx0ZFRqdTMgmmgrVtXouxvsHZqOAm0bY/s1600/box_text_size.png&quot; /&gt;&lt;br /&gt;
&lt;br /&gt;
Ahora en &lt;i&gt;values/styles.xml&lt;/i&gt; podemos añadir un estilo personalizado como éste (fondo y texto de colores determinados, alineado al centro, de tamaño establecido en la dimensión box_text_size, negrita y fuente establecida en font/roboto):&lt;br /&gt;
&lt;pre class=&quot;hl&quot;&gt;&lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;style&lt;/span&gt; &lt;span class=&quot;hl kwb&quot;&gt;name&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;whiteBox&quot;&lt;/span&gt;&lt;span class=&quot;hl kwa&quot;&gt;&amp;gt;&lt;/span&gt;
&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;item&lt;/span&gt; &lt;span class=&quot;hl kwb&quot;&gt;name&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;android:background&quot;&lt;/span&gt;&lt;span class=&quot;hl kwa&quot;&gt;&amp;gt;&lt;/span&gt;@android:color/holo_green_light&lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;/item&amp;gt;&lt;/span&gt;
&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;item&lt;/span&gt; &lt;span class=&quot;hl kwb&quot;&gt;name&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;android:textAlignment&quot;&lt;/span&gt;&lt;span class=&quot;hl kwa&quot;&gt;&amp;gt;&lt;/span&gt;center&lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;/item&amp;gt;&lt;/span&gt;
&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;item&lt;/span&gt; &lt;span class=&quot;hl kwb&quot;&gt;name&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;android:textSize&quot;&lt;/span&gt;&lt;span class=&quot;hl kwa&quot;&gt;&amp;gt;&lt;/span&gt;@dimen/box_text_size&lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;/item&amp;gt;&lt;/span&gt;
&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;item&lt;/span&gt; &lt;span class=&quot;hl kwb&quot;&gt;name&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;android:textStyle&quot;&lt;/span&gt;&lt;span class=&quot;hl kwa&quot;&gt;&amp;gt;&lt;/span&gt;bold&lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;/item&amp;gt;&lt;/span&gt;
&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;item&lt;/span&gt; &lt;span class=&quot;hl kwb&quot;&gt;name&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;android:textColor&quot;&lt;/span&gt;&lt;span class=&quot;hl kwa&quot;&gt;&amp;gt;&lt;/span&gt;@android:color/white&lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;/item&amp;gt;&lt;/span&gt;
&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;item&lt;/span&gt; &lt;span class=&quot;hl kwb&quot;&gt;name&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;android:fontFamily&quot;&lt;/span&gt;&lt;span class=&quot;hl kwa&quot;&gt;&amp;gt;&lt;/span&gt;@font/roboto&lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;/item&amp;gt;&lt;/span&gt;
&lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;/style&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;br /&gt;
Ahora en el atributo &lt;i&gt;text&lt;/i&gt; (el que no tiene el icono de llave inglesa) pulsamos sobre los tres puntos para abrir la ventana &lt;i&gt;Resources&lt;/i&gt;; y agregamos un nuevo recurso de texto:&lt;br /&gt;
&lt;br /&gt;
&lt;img border=&quot;0&quot; data-original-height=&quot;436&quot; data-original-width=&quot;423&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhYuuJyhTOrt3qqOd2M_DO81Eb2XlVelwG0-3sJ1ow9jSfqK_9rZLj8Lzn4OHSXiAJkLfaBZCpERrkEEQyxxAwP7y3S1uydV3aLoHn0RYpLqQUkYTEA2gjMXhi_pqXPKwGidQCweqngLuY/s1600/resources_box1.png&quot; /&gt;&lt;br /&gt;
&lt;br /&gt;
Volvemos al &lt;i&gt;TextView&lt;/i&gt; en vista de &lt;i&gt;Design&lt;/i&gt;, y le aplicamos el estilo &lt;i&gt;whiteBox&lt;/i&gt;:&lt;br /&gt;
&lt;br /&gt;
&lt;img border=&quot;0&quot; data-original-height=&quot;576&quot; data-original-width=&quot;854&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiot7voYVbckJ3VP5S4GktLmj8Exx7vTNF7EUqSRZHW1MxRpU_LES9dfSkPWeEDpLMVhXsceTaWqZDcwEoTgvI5nBdJaUo93T20C4FD6BMC_iBpJkxWM-6aAYl688yKf9qleOR5TXyhATo/s1600/aplicarEstilo.png&quot; /&gt;&lt;br /&gt;
&lt;br /&gt;
Puesto que este estilo ya contiene el atributo &lt;i&gt;android:fontFamily&lt;/i&gt; con el valor Roboto, en el &lt;i&gt;TextView&lt;/i&gt;, en modo &lt;i&gt;Text&lt;/i&gt;, podemos eliminar este atributo. Volvemos a la vista &lt;i&gt;Design&lt;/i&gt; y pulsamos en el botón &lt;i&gt;Device for preview (D)&lt;/i&gt; que por defecto muestra &lt;i&gt;Pixel&lt;/i&gt;, para desplegar una lista de dispositivos, y seleccionamos algunos para ver cómo el &lt;i&gt;TextView&lt;/i&gt; se adapta a las distintas pantallas. Podremos ver algo así:&lt;br /&gt;
&lt;br /&gt;
&lt;img border=&quot;0&quot; data-original-height=&quot;630&quot; data-original-width=&quot;586&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhumzvXupz3hqVDCUV6UAWmStnXCScl_X0iHJRp4krmsFwUns6hw4-V2aXeg_feaop7FndHN0uVbItHZEkKWlvoeQXMlmHKO0HM2tpCahYCvr6IAz_Dsr_N2svy36EzWyd4pCaiGbH2qlU/s1600/preview.png&quot; /&gt;&lt;br /&gt;
&lt;br /&gt;
Bien, ahora añadimos otro &lt;i&gt;TextView&lt;/i&gt; bajo el que ya tenemos (arrastrándolo desde la paleta directamente a la vista previa) y lo alineamos manualmente al margen izquierdo. En el editor de diseño, con el nuevo &lt;i&gt;TextView&lt;/i&gt; seleccionado, nos situamos sobre el punto superior, que es el controlador de sujeción (&lt;i&gt;constraint handle&lt;/i&gt;), y entonces se vuelve verde y parpadea:&lt;br /&gt;
&lt;br /&gt;
&lt;img border=&quot;0&quot; data-original-height=&quot;351&quot; data-original-width=&quot;617&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgtcUYXuHsE6B3L7r9ciSF-U3dn3p8aWh0Ubc7lGVzgGRg6gzmxkgupnNt8JgrGq8IyyMB85qQ0wDHOFJSH0KymVL9hZO1BjhaUPsPHRaoKonxtv-Xa830XfMmJ_aNffuLS0uS31CohTTY/s1600/constraint_handle.png&quot; /&gt;&lt;br /&gt;
&lt;br /&gt;
Entonces creamos un &lt;i&gt;Top Constraint&lt;/i&gt; conectando la parte superior del &lt;i&gt;TextView&lt;/i&gt; con la parte inferior del otro &lt;i&gt;TextView&lt;/i&gt;:&lt;br /&gt;
&lt;br /&gt;
&lt;img border=&quot;0&quot; data-original-height=&quot;338&quot; data-original-width=&quot;767&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgvl9QL4USo0-nJgzuc9pJIYiaWKmKTbN43-vHUIup0CKBd4m_vFDQsBqdd7UnCIF1orUHnbiIPSb4hsSBJVfqiM5mBTU6fXI7q-mZ6vjerqbxxCXrPhdP8B4sGMQYxAs32JyWGr5XRgoo/s1600/Top_Constraint.png&quot; /&gt;&lt;br /&gt;
&lt;br /&gt;
Al crear la conexión entre ambos elementos, automáticamente el margen superior se ajusta a 16dp porque es el valor por defecto que configuramos antes. Repetimos el mismo proceso para crear una fijación en el lado izquierdo respecto al elemento raíz. Ten en cuenta que además de utilizar directamente el elemento desde el editor de diseño, también podemos crear fijaciones desde el inspector de vistas:&lt;br /&gt;
&lt;br /&gt;
&lt;img border=&quot;0&quot; data-original-height=&quot;282&quot; data-original-width=&quot;1248&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhY2Gcz-qellFplaOixqJU8_0V9BZ53HUpyZgk0oJIo6fMr8tgqkrHCviMr2X71vRGcj_553rUBIPEUceqU6gb-C9pvliMGBJRvGWN6DwxEUxomLh_3ccJvyRip6BGhE1UXFue-cIrF1Ig/s1600/left_constraint.png&quot; /&gt;&lt;br /&gt;
&lt;br /&gt;
Desde el panel de atributos, ajustamos algunos valores así:&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;ID: box_dos_txt&lt;/li&gt;
&lt;li&gt;layout_height: 130dp&lt;/li&gt;
&lt;li&gt;layout_width: 130dp&lt;/li&gt;
&lt;li&gt;text: @string/box_dos&lt;/li&gt;
&lt;li&gt;style: @style/whiteBox&lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;
&lt;img border=&quot;0&quot; data-original-height=&quot;629&quot; data-original-width=&quot;354&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj6aokZh5ntKvN9XM5tCKfrFcLgTQQpl0J4HLXcDu-UaYqMSUYQftO_xeXBBXiRpQHMlC7vLtep8p24wnE8PU70TWzK7ll5GjrOXocvELlKRBEDp1fd-S5cmFudz0YPIiclGT5SqWqTgH0/s1600/preview_box_dos.png&quot; /&gt;&lt;br /&gt;
&lt;br /&gt;
Ten en cuenta que estamos utilizando dimensiones fijas para la altura y anchura del &lt;i&gt;TextView&lt;/i&gt;, pero suele ser &lt;b&gt;más recomendable usar fijaciones flexibles y relativas&lt;/b&gt;, por ejemplo &lt;i&gt;match_constraint&lt;/i&gt; o &lt;i&gt;wrap_content&lt;/i&gt;, puesto que en general cuanto más elementos de tamaño fijo tiene una aplicación menos adaptable será su diseño para diferentes configuraciones de pantalla.&lt;br /&gt;
&lt;br /&gt;
Otra forma de crear fijaciones es con una &lt;b&gt;cadena de elementos&lt;/b&gt; (&lt;i&gt;chain&lt;/i&gt;), esto es, agrupando o encadenando elementos vinculados entre sí con sujeciones bidireccionales. Por ejemplo, el siguiente diagrama muestra dos elementos que están fijados entre sí, lo que crea una cadena horizontal:&lt;br /&gt;
&lt;br /&gt;
&lt;img border=&quot;0&quot; data-original-height=&quot;224&quot; data-original-width=&quot;464&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgTfszGvaobIKGQLL1p3Q60q9gZ8XDvdp8wjXF7y7kGxVvH-86YtcIrfsmKbMRSqJoZFGjCINh-3YM_8zK61P-4zFpQyhw6kGF4dmntuEr_1yO9gLaa3eo60dH5HSkBVrr3IUERGlhRdl8/s1600/chain.png&quot; /&gt;&lt;br /&gt;
&lt;br /&gt;
El primer elemento de una cadena se conoce como cabeza o cabecera de la cadena (&lt;i&gt;head of the chain&lt;/i&gt;), y sus atributos controlan, posicionan y distribuyen todas los elementos en la cadena. Para cadenas horizontales, la cabeza es la vista más a la izquierda mientras que para cadenas verticales, la cabeza es la vista superior.&lt;br /&gt;
&lt;br /&gt;
Se pueden aplicar distintos &lt;b&gt;estilos a las cadenas&lt;/b&gt; para definir la forma en que los elementos encadenados se extienden y alinean:&lt;br /&gt;
&lt;ol&gt;
&lt;li&gt;&lt;i&gt;Spread&lt;/i&gt;: Después de tener en cuenta los márgenes, los elementos se distribuyen uniformemente en el espacio disponible (es el estilo por defecto).&lt;/li&gt;
&lt;li&gt;&lt;i&gt;Spread inside&lt;/i&gt;: El primer y el último elementos se adjuntan al elemento padre en cada extremo de la cadena, mientras que el resto de elementos se distribuyen uniformemente en el espacio disponible.&lt;/li&gt;
&lt;li&gt;&lt;i&gt;Weighted&lt;/i&gt;: Los elementos cambian de tamaño para llenar todo el espacio en función de los valores establecidos en los atributos &lt;i&gt;layout_constraintHorizontal_weight&lt;/i&gt; o &lt;i&gt;layout_constraintVertical_weight&lt;/i&gt;. De manera predeterminada, el espacio se distribuye uniformemente entre cada elemento según &lt;i&gt;match constraints&lt;/i&gt; (0dp), pero se puede asignar un valor a cada elemento para ocupar más o menos espacio.&lt;/li&gt;
&lt;li&gt;&lt;i&gt;Packed&lt;/i&gt;: Los elementos se agrupan (después de tener en cuenta los márgenes) y luego se puede ajustar la posición de toda la cadena cambiando la desviación (&lt;i&gt;bias&lt;/i&gt;) de la cabeza.&lt;/li&gt;
&lt;/ol&gt;
&lt;br /&gt;
&lt;img border=&quot;0&quot; data-original-height=&quot;385&quot; data-original-width=&quot;495&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEguiBSvL63hl2DPgtCTLVEmhcW0qeAqvKc70xpAagJIlagLkesLQ_pzVVi9NXY_dlF2-MfUVKt0aF46ajEhs0dYy49CYqE1jllZ6p1kfJRO7wMbcpv3hEMAn0-Phd_IvLnmi4N_Nyr3RCM/s1600/chain_style.png&quot; /&gt;&lt;br /&gt;
&lt;br /&gt;
Podemos aplicar uno de estos estilos a una cadena desde el editor de diseño en el atributo &lt;i&gt;layout_constraintHorizontal_chainStyle&lt;/i&gt; o en el atributo &lt;i&gt;layout_constraintVertical_chainStyle&lt;/i&gt; para la cabeza de la cadena, o bien desde el código XML, por ejemplo:&lt;br /&gt;
&lt;pre class=&quot;hl&quot;&gt;// Horizontal spread chain
app:&lt;span class=&quot;hl kwb&quot;&gt;layout_constraintHorizontal_chainStyle&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;spread&quot;&lt;/span&gt;

// Vertical spread inside chain
app:&lt;span class=&quot;hl kwb&quot;&gt;layout_constraintVertical_chainStyle&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;spread_inside&quot;&lt;/span&gt;

// Horizontal packed chain
app:&lt;span class=&quot;hl kwb&quot;&gt;layout_constraintHorizontal_chainStyle&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;packed&quot;&lt;/span&gt;&lt;/pre&gt;
&lt;br /&gt;
Para &lt;b&gt;crear una cadena vertical&lt;/b&gt; en nuestra aplicación, en el archivo &lt;i&gt;activity_main.xml&lt;/i&gt;, vista &lt;i&gt;Design&lt;/i&gt;, creamos otros tres elementos &lt;i&gt;TextView&lt;/i&gt; arrastrándolos a la derecha del &lt;i&gt;TextView&lt;/i&gt; box_dos_txt:&lt;br /&gt;
&lt;br /&gt;
&lt;img border=&quot;0&quot; data-original-height=&quot;478&quot; data-original-width=&quot;813&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjCYSM1yqIB3u1Y1zWc1fGEf9HsYg3dcfFv_AJogFmlJzEWHQemTdmsbKCPKvqRlWGSPnWdrDkbiCsedLKf_KFEyKE_X7XzH-FIgkHxcgUSAODA65D6zwmrlAukKQloyBVGdj78qpMxLGU/s1600/tres_textviews.png&quot; /&gt;&lt;br /&gt;
&lt;br /&gt;
Como hicimos antes con los otros &lt;i&gt;TextView&lt;/i&gt;, ajustamos sus atributos de &lt;i&gt;id&lt;/i&gt;, &lt;i&gt;text&lt;/i&gt; y &lt;i&gt;style&lt;/i&gt;. Observa que para aplicar el mismo estilo a los tres (&lt;i&gt;@style/whiteBox&lt;/i&gt;), desde el árbol de componentes puedes seleccionarlos conjuntamente y aplicarlo de una vez.&lt;br /&gt;
&lt;br /&gt;
Ahora, para crear la cadena, desde el editor de diseño seleccionamos los tres elementos y con el botón secundario pulsamos en &lt;i&gt;Chains&lt;/i&gt; &amp;gt; &lt;i&gt;Create Vertical Chain&lt;/i&gt;. Esto crea una cadena vertical que se extiende desde Box Uno hasta el final del diseño.&lt;br /&gt;
&lt;br /&gt;
Seleccionamos el elemento Box Tres y creamos una sujeción desde su parte superior hasta la parte superior del Cuadro Dos (esta nueva sujeción reemplaza la sujeción superior existente por lo que no es necesario eliminarla explícitamente):&lt;br /&gt;
&lt;br /&gt;
&lt;img border=&quot;0&quot; data-original-height=&quot;595&quot; data-original-width=&quot;837&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhdh00LNMViDVsUzocEI-1oLhTP4Ros-gbt7-Kcn7JGwrnZG3MbsuDmQXx6DX6csrt1RGwwDPz0-HeXikcWcwU7icCAs4hWnXjLVFJN0Ew0PfBYhW0_zIyOQWY5n0XsMjt1UZTVYf3gMLA/s1600/TresaDos.png&quot; /&gt;&lt;br /&gt;
&lt;br /&gt;
Creamos otra sujeción desde la parte inferior del Box Cinco hasta la parte inferior del Box Dos:&lt;br /&gt;
&lt;br /&gt;
&lt;img border=&quot;0&quot; data-original-height=&quot;470&quot; data-original-width=&quot;814&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiI0BpkEhNaVd8sR6ZNxVEcIE86EJ9nlPGChqBgFCYdfQHrCRyQmpYS466gw1JXLtXS258K1l0DXlZ2hurK4IloMVivXBs846nNV7F7WD406HmPDDaR-KPQiaGuVx0_7reraHZEzbhumJg/s1600/CincoADos.png&quot; /&gt;&lt;br /&gt;
&lt;br /&gt;
También creamos una sujeción desde el lado izquierdo del Box Tres al lado derecho del Box Dos. Repetimos para los Boxes Cuatro y Cinco. Además creamos sujeciones del lado derecho de estos tres elementos al lado derecho del diseño, y para los tres cambiamos el atributo &lt;i&gt;layout_width&lt;/i&gt; a &lt;i&gt;match_constraint&lt;/i&gt; (que es lo mismo que poner el valor 0dp).&lt;br /&gt;
&lt;br /&gt;
&lt;img border=&quot;0&quot; data-original-height=&quot;546&quot; data-original-width=&quot;785&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEim4VK0wDJmMq6sJUtqjJYS14zl2fOCuzXnb2SQM8ieKa9HJdsysYXDw7eaKJvDOVBDvaQHILCEDz-WcytlPu_Q7Vben00qSTMZzI8bWbk_FkwOmfD7SdkUMZiZdGRuGvAxeHNe4ApV5D8/s1600/match_constraint3.png&quot; /&gt;&lt;br /&gt;
&lt;br /&gt;
Para separar estos tres elementos entre sí, agregamos márgenes asignando al atributo &lt;i&gt;Layout_Margin&lt;/i&gt; el valor que tenemos guardado en el recurso de dimensiones llamado margen_ancho; para los tres elementos lo aplicamos a &lt;i&gt;Layout_Margin start&lt;/i&gt; y &lt;i&gt;end&lt;/i&gt; y para el Box Cuatro también a &lt;i&gt;top&lt;/i&gt; y &lt;i&gt;bottom&lt;/i&gt; (y eliminamos el resto de márgenes de estos elementos).&lt;br /&gt;
&lt;br /&gt;
Podemos comprobar que el diseño se adapta a cambios en la pantalla ajustando la orientación a &lt;i&gt;Landscape&lt;/i&gt; (horizontal) de la vista previa desde el icono &lt;i&gt;Orientation for Preview (O)&lt;/i&gt; de la barra de herramientas:&lt;br /&gt;
&lt;br /&gt;
&lt;img border=&quot;0&quot; data-original-height=&quot;578&quot; data-original-width=&quot;1028&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgOsexOnGlmnJNMwUDKqBB1BHO36pDgqaYZRO0CzNjgd4WwK2Wq88FfYeXwXwr4IGMSBs8bIy2cFN6s2caKdRf6_t5cGqD_dMGEU5Oe0MOkz93DopDIWA0uxe4D0qgpp7FexSKab8hIvHM/s1600/Landscape.png&quot; /&gt;&lt;br /&gt;
&lt;br /&gt;
Ahora vamos a añadir cierta &lt;b&gt;interacción del usuario&lt;/b&gt; para que cuando toque algunos elementos cambien de color. Para ello primero cambiaremos el color de todos los elementos de texto a blanco, desde &lt;i&gt;values/styles.xml&lt;/i&gt;, en el estilo &lt;i&gt;whiteBox&lt;/i&gt; cambiamos el color de fondo (&lt;i&gt;android:background&lt;/i&gt;) a blanco:&lt;br /&gt;
&lt;pre class=&quot;hl&quot;&gt;&lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;item&lt;/span&gt; &lt;span class=&quot;hl kwb&quot;&gt;name&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;android:background&quot;&lt;/span&gt;&lt;span class=&quot;hl kwa&quot;&gt;&amp;gt;&lt;/span&gt;@android:color/white&lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;/item&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;br /&gt;
En &lt;i&gt;MainActivity.kt&lt;/i&gt;, después de la función &lt;i&gt;onCreate()&lt;/i&gt;, escribimos una función llamada &lt;i&gt;pintarView&lt;/i&gt; con un &lt;i&gt;View&lt;/i&gt; como parámetro que será el elemento que cambiará de color:&lt;br /&gt;
&lt;pre class=&quot;hl&quot;&gt;&lt;span class=&quot;hl kwa&quot;&gt;private fun&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;pintarView&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;view&lt;span class=&quot;hl opt&quot;&gt;:&lt;/span&gt; View&lt;span class=&quot;hl opt&quot;&gt;) { }&lt;/span&gt;&lt;/pre&gt;
&lt;br /&gt;
Dentro de esta función podemos utilizar una instrucción &lt;i&gt;when&lt;/i&gt; con el &lt;i&gt;id&lt;/i&gt; de recurso del elemento utilizado como argumento, de modo que cuando el bloque &lt;i&gt;when&lt;/i&gt; verifique el &lt;i&gt;id&lt;/i&gt; del elemento se aplicará el cambio de color de fondo para ese elemento con el método &lt;i&gt;setBackgroundColor()&lt;/i&gt; y como argumento constantes de la clase &lt;i&gt;Color&lt;/i&gt; (requiere &lt;i&gt;import android.graphics.Color&lt;/i&gt;):&lt;br /&gt;
&lt;pre class=&quot;hl&quot;&gt;&lt;span class=&quot;hl kwa&quot;&gt;private fun&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;pintarView&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;view&lt;span class=&quot;hl opt&quot;&gt;:&lt;/span&gt; View&lt;span class=&quot;hl opt&quot;&gt;) {&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;when&lt;/span&gt; &lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;view&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;id&lt;span class=&quot;hl opt&quot;&gt;) {&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; R&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;id&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;box_uno_txt &lt;span class=&quot;hl opt&quot;&gt;-&amp;gt;&lt;/span&gt; view&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;setBackgroundColor&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;Color&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;DKGRAY&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; R&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;id&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;box_dos_txt &lt;span class=&quot;hl opt&quot;&gt;-&amp;gt;&lt;/span&gt; view&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;setBackgroundColor&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;Color&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;GRAY&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; R&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;id&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;box_tres_txt &lt;span class=&quot;hl opt&quot;&gt;-&amp;gt;&lt;/span&gt; view&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;setBackgroundColor&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;Color&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;BLUE&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; R&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;id&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;box_cuatro_txt &lt;span class=&quot;hl opt&quot;&gt;-&amp;gt;&lt;/span&gt; view&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;setBackgroundColor&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;Color&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;MAGENTA&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; R&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;id&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;box_cinco_txt &lt;span class=&quot;hl opt&quot;&gt;-&amp;gt;&lt;/span&gt; view&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;setBackgroundColor&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;Color&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;BLUE&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt;&lt;/pre&gt;
&lt;br /&gt;
También queremos que si el usuario toca el fondo, éste cambie a un tono de gris claro que revelará los contornos de los elementos de texto, lo que orientará al usuario sobre dónde tocar. Para ello, si ninguna de las condiciones de &lt;i&gt;when&lt;/i&gt; se verifica, sabemos que el usuario ha tocado el fondo, por lo que añadimos una instrucción &lt;i&gt;else&lt;/i&gt; con un color gris:&lt;br /&gt;
&lt;pre class=&quot;hl&quot;&gt;&lt;span class=&quot;hl kwa&quot;&gt;else&lt;/span&gt; &lt;span class=&quot;hl opt&quot;&gt;-&amp;gt;&lt;/span&gt; view&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;setBackgroundColor&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;Color&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;LTGRAY&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;&lt;/pre&gt;
&lt;br /&gt;
Otra posible manera de escribir lo mismo es:&lt;br /&gt;
&lt;pre class=&quot;hl&quot;&gt;&lt;span class=&quot;hl kwa&quot;&gt;val&lt;/span&gt; color &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;hl kwa&quot;&gt;when&lt;/span&gt; &lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;view&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;id&lt;span class=&quot;hl opt&quot;&gt;) {&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; R&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;id&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;box_uno_txt &lt;span class=&quot;hl opt&quot;&gt;-&amp;gt;&lt;/span&gt; Color&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;DKGRAY
&amp;nbsp;&amp;nbsp;&amp;nbsp; R&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;id&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;box_dos_txt &lt;span class=&quot;hl opt&quot;&gt;-&amp;gt;&lt;/span&gt; Color&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;GRAY
&amp;nbsp;&amp;nbsp;&amp;nbsp; R&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;id&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;box_tres_txt &lt;span class=&quot;hl opt&quot;&gt;-&amp;gt;&lt;/span&gt; Color&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;BLUE
&amp;nbsp;&amp;nbsp;&amp;nbsp; R&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;id&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;box_cuatro_txt &lt;span class=&quot;hl opt&quot;&gt;-&amp;gt;&lt;/span&gt; Color&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;MAGENTA
&amp;nbsp;&amp;nbsp;&amp;nbsp; R&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;id&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;box_cinco_txt &lt;span class=&quot;hl opt&quot;&gt;-&amp;gt;&lt;/span&gt; Color&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;BLUE
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;else&lt;/span&gt; &lt;span class=&quot;hl opt&quot;&gt;-&amp;gt;&lt;/span&gt; Color&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;LTGRAY
&lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt;
view&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;setBackgroundColor&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;color&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;&lt;/pre&gt;
&lt;br /&gt;
También debemos añadir una identificación (&lt;i&gt;id&lt;/i&gt;) al elemento raíz del diseño para cambiar su color; para ello desde &lt;i&gt;activity_main.xml&lt;/i&gt;, asignamos un valor al &lt;i&gt;ID&lt;/i&gt; del &lt;i&gt;ConstraintLayout&lt;/i&gt;.&lt;br /&gt;
&lt;br /&gt;
Ahora nos falta detectar los clics, y para ello escribimos la función &lt;i&gt;clicView()&lt;/i&gt; para que pueda invocar a la función &lt;i&gt;pintarView&lt;/i&gt; para cada elemento pulsado. Esta función es invocada desde &lt;i&gt;onCreate&lt;/i&gt;:&lt;br /&gt;
&lt;pre class=&quot;hl&quot;&gt;&lt;span class=&quot;hl kwa&quot;&gt;override fun&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;onCreate&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;savedInstanceState&lt;span class=&quot;hl opt&quot;&gt;:&lt;/span&gt; Bundle?&lt;span class=&quot;hl opt&quot;&gt;) {&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;super&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;onCreate&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;savedInstanceState&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwd&quot;&gt;setContentView&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;R&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;layout&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;activity_main&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwd&quot;&gt;clicView&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;()&lt;/span&gt;
&lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;hl kwa&quot;&gt;private fun&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;clicView&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;() { }&lt;/span&gt;&lt;/pre&gt;
&lt;br /&gt;
En la función &lt;i&gt;clicView&lt;/i&gt; declaramos una lista con los elementos que nos interesa que tengan una acción al ser pulsados:&lt;br /&gt;
&lt;pre class=&quot;hl&quot;&gt;&lt;span class=&quot;hl kwa&quot;&gt;val&lt;/span&gt; clickableViews &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;listOf&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;box_uno_txt&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; box_dos_txt&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; box_tres_txt&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; box_cuatro_txt&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; box_cinco_txt&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; constraint_layout&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;&lt;/pre&gt;
&lt;br /&gt;
Así, con un bucle &lt;i&gt;for&lt;/i&gt; podemos crear rápidamente un controlador de clic para cada elemento:&lt;br /&gt;
&lt;pre class=&quot;hl&quot;&gt;&lt;span class=&quot;hl kwa&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;item &lt;span class=&quot;hl kwa&quot;&gt;in&lt;/span&gt; clickableViews&lt;span class=&quot;hl opt&quot;&gt;) {&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; item&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;setOnClickListener &lt;span class=&quot;hl opt&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;pintarView&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;it&lt;span class=&quot;hl opt&quot;&gt;) }&lt;/span&gt;
&lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt;&lt;/pre&gt;
&lt;br /&gt;
Ejecuta la aplicación en el emulador para comprobar que funciona. De momento el código de &lt;i&gt;MainActivity.tk&lt;/i&gt; queda así:&lt;br /&gt;
&lt;pre class=&quot;hl&quot;&gt;&lt;span class=&quot;hl kwa&quot;&gt;package&lt;/span&gt; com&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;android&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;colores

&lt;span class=&quot;hl kwa&quot;&gt;import&lt;/span&gt; android&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;graphics&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;Color
&lt;span class=&quot;hl kwa&quot;&gt;import&lt;/span&gt; android&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;os&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;Bundle
&lt;span class=&quot;hl kwa&quot;&gt;import&lt;/span&gt; android&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;view&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;View
&lt;span class=&quot;hl kwa&quot;&gt;import&lt;/span&gt; androidx&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;appcompat&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;app&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;AppCompatActivity
&lt;span class=&quot;hl kwa&quot;&gt;import&lt;/span&gt; kotlinx&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;android&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;synthetic&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;main&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;activity_main&lt;span class=&quot;hl opt&quot;&gt;.*&lt;/span&gt;

&lt;span class=&quot;hl kwa&quot;&gt;class&lt;/span&gt; MainActivity &lt;span class=&quot;hl opt&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;AppCompatActivity&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;() {&lt;/span&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;override fun&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;onCreate&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;savedInstanceState&lt;span class=&quot;hl opt&quot;&gt;:&lt;/span&gt; Bundle?&lt;span class=&quot;hl opt&quot;&gt;) {&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;super&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;onCreate&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;savedInstanceState&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwd&quot;&gt;setContentView&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;R&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;layout&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;activity_main&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwd&quot;&gt;clicView&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;()&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;private fun&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;clicView&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;() {&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;val&lt;/span&gt; clickableViews &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwd&quot;&gt;listOf&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;box_uno_txt&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; box_dos_txt&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; box_tres_txt&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; box_cuatro_txt&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; box_cinco_txt&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; constraint_layout&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;item &lt;span class=&quot;hl kwa&quot;&gt;in&lt;/span&gt; clickableViews&lt;span class=&quot;hl opt&quot;&gt;) {&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; item&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;setOnClickListener &lt;span class=&quot;hl opt&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;pintarView&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;it&lt;span class=&quot;hl opt&quot;&gt;) }&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;private fun&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;pintarView&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;view&lt;span class=&quot;hl opt&quot;&gt;:&lt;/span&gt; View&lt;span class=&quot;hl opt&quot;&gt;) {&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl com&quot;&gt;/*when (view.id) {&lt;/span&gt;
&lt;span class=&quot;hl com&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; R.id.box_uno_txt -&amp;gt; view.setBackgroundColor(Color.DKGRAY)&lt;/span&gt;
&lt;span class=&quot;hl com&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; R.id.box_dos_txt -&amp;gt; view.setBackgroundColor(Color.GRAY)&lt;/span&gt;
&lt;span class=&quot;hl com&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; R.id.box_tres_txt -&amp;gt; view.setBackgroundColor(Color.BLUE)&lt;/span&gt;
&lt;span class=&quot;hl com&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; R.id.box_cuatro_txt -&amp;gt; view.setBackgroundColor(Color.MAGENTA)&lt;/span&gt;
&lt;span class=&quot;hl com&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; R.id.box_cinco_txt -&amp;gt; view.setBackgroundColor(Color.BLUE)&lt;/span&gt;
&lt;span class=&quot;hl com&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; else -&amp;gt; view.setBackgroundColor(Color.LTGRAY)&lt;/span&gt;
&lt;span class=&quot;hl com&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }*/&lt;/span&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;val&lt;/span&gt; color &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;hl kwa&quot;&gt;when&lt;/span&gt; &lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;view&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;id&lt;span class=&quot;hl opt&quot;&gt;) {&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; R&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;id&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;box_uno_txt &lt;span class=&quot;hl opt&quot;&gt;-&amp;gt;&lt;/span&gt; Color&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;DKGRAY
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; R&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;id&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;box_dos_txt &lt;span class=&quot;hl opt&quot;&gt;-&amp;gt;&lt;/span&gt; Color&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;GRAY
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; R&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;id&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;box_tres_txt &lt;span class=&quot;hl opt&quot;&gt;-&amp;gt;&lt;/span&gt; Color&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;BLUE
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; R&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;id&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;box_cuatro_txt &lt;span class=&quot;hl opt&quot;&gt;-&amp;gt;&lt;/span&gt; Color&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;MAGENTA
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; R&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;id&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;box_cinco_txt &lt;span class=&quot;hl opt&quot;&gt;-&amp;gt;&lt;/span&gt; Color&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;BLUE
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;else&lt;/span&gt; &lt;span class=&quot;hl opt&quot;&gt;-&amp;gt;&lt;/span&gt; Color&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;LTGRAY
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; view&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;setBackgroundColor&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;color&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt;&lt;/pre&gt;
&lt;br /&gt;
Otra posibilidad es usar imágenes en lugar de colores y texto, de modo que cuando el usuario toca los elementos se muestran las imágenes; en ese caso se utilizaría la función &lt;i&gt;setBackgroundResource()&lt;/i&gt; para establecer una imagen como fondo del elemento.&lt;br /&gt;
&lt;br /&gt;
Aunque funciona (hace lo que se supone que debe hacer), estaría bien añadir unas mínimas instrucciones que indiquen al usuario cómo usar la aplicación. Para ello, vamos a crear dos &lt;i&gt;TextView&lt;/i&gt; bajo el resto de elementos, uno con la etiqueta &#39;Cómo jugar&#39; y el otro con la información. El primero lo creamos con estos atributos:&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;ID: etiqueta_info&lt;/li&gt;
&lt;li&gt;text: @string/etiqueta_info&lt;/li&gt;
&lt;li&gt;fontFamily: @font/roboto&lt;/li&gt;
&lt;li&gt;textSize: @dimen/box_text_size&lt;/li&gt;
&lt;li&gt;textStyle: B (bold)&lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;
Y creamos una sujeción desde su lado izquierdo hasta el elemento raíz, y a &lt;i&gt;Layout_Margin start&lt;/i&gt; le asignamos el valor del recurso @dimen/margen_ancho.&lt;br /&gt;
&lt;pre class=&quot;hl&quot;&gt;&lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;TextView&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;id&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@+id/etiqueta_info&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_width&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;wrap_content&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_height&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;wrap_content&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_marginStart&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@dimen/margen_ancho&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;fontFamily&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@font/roboto&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;text&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@string/etiqueta_info&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;textSize&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@dimen/box_text_size&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;textStyle&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;bold&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; app:&lt;span class=&quot;hl kwb&quot;&gt;layout_constraintStart_toStartOf&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;parent&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; tools:&lt;span class=&quot;hl kwb&quot;&gt;layout_editor_absoluteY&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;235dp&quot;&lt;/span&gt; &lt;span class=&quot;hl kwa&quot;&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;br /&gt;
Vemos que el último atributo difiere en el prefijo del espacio de nombres (&lt;i&gt;tools&lt;/i&gt;): son los conocidos como &lt;b&gt;atributos de tiempo de diseño&lt;/b&gt; (&lt;i&gt;design-time attributes&lt;/i&gt;). Estos atributos solo se usan y aplican durante el plan del diseño pero no en tiempo de ejecución; así, cuando se ejecuta la aplicación esos atributos son ignorados. En este caso se ha agregado este atributo porque todavía no hemos especificado una sujeción vertical para el elemento y, como sabemos, todos los elementos contenidos en un &lt;i&gt;ConstraintLayout&lt;/i&gt; deben fijarse horizontal y verticalmente (de lo contrario, los elementos saltan a un borde del elemento padre cuando ejecuta la aplicación, y por eso el Editor de Diseño agrega atributos de tiempo de diseño para mantener el elemento en su lugar durante el diseño, y los elimina en el momento que se crea la sujeción que falta).&lt;br /&gt;
&lt;br /&gt;
Creamos otro &lt;i&gt;TextView&lt;/i&gt; a la derecha y bajo el anterior con estos atributos:&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;ID: info_text&lt;/li&gt;
&lt;li&gt;layout_width: match_constraint&lt;/li&gt;
&lt;li&gt;text: @string/text_info&lt;/li&gt;
&lt;li&gt;fontFamily: @font/roboto&lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;
Creamos una sujeción desde su lado derecho hasta el borde derecho del elemento padre y otra desde su lado izquierdo hasta la derecha de etiqueta_info.&lt;br /&gt;
&lt;br /&gt;
&lt;img border=&quot;0&quot; data-original-height=&quot;619&quot; data-original-width=&quot;727&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjizVcLcMfzdiOaekIB1JsYBp2FhObKp6vxNJoRTyzwgi_KBVdJWkZ5EpwmlcIBwEeNBsJElhun3QAdl3-RDbYVyLXsEnsT4cED3CORLRyhztoYOY6TY_oGhMmxSMSZlQ9OpciReI-xj4Q/s1600/info_text.png&quot; /&gt;&lt;br /&gt;
&lt;br /&gt;
Ahora podemos alinear los textos de ambos &lt;i&gt;TextView&lt;/i&gt; utilizando la &lt;b&gt;sujeción de línea base&lt;/b&gt; (&lt;i&gt;Baseline constraint&lt;/i&gt;), lo que suele resultar especialmente útil con elementos de texto con fuentes de distinto tamaño. Para ello, al seleccionar el elemento etiqueta_info y mantener el ratón sobre él, aparece el icono de &lt;i&gt;Edit Baseline&lt;/i&gt;; lo pulsamos y aparece una línea verde parpadeante bajo el texto. Pulsamos sobre ella y la arrastramos hasta la linea verde de debajo del texto del elemento info_text (para eliminarla volvemos a pulsar sobre la línea, ahora roja, bajo el texto).&lt;br /&gt;
&lt;br /&gt;
Como vimos, nos faltaba especificar sujeciones verticales a los nuevos elementos de texto; creamos sujeciones para el info_text: desde su parte inferior hasta la parte inferior del elemento padre y desde su parte superior hasta la parte inferior del Box Dos (como vemos, no hace falta especificar una sujeción vertical para etiqueta_info puesto que este elemento está fijado a info_text, que sí está fijado verticalmente).&lt;br /&gt;
&lt;br /&gt;
Para terminar, vamos a agregar una &lt;b&gt;cadena de botones&lt;/b&gt;. Arrastramos tres botones desde la paleta hasta la parte inferior del diseño y a cada uno le asignamos un &lt;i&gt;id&lt;/i&gt; y un recurso de texto. Alineamos verticalemente las etiquetas de los botones entre sí creando una sujeción de línea base (&lt;i&gt;Baseline constraint&lt;/i&gt;) desde el texto de cada botón lateral al texto del botón central. Seleccionamos los tres botones y creamos una cadena horizontal (&lt;i&gt;Chains&lt;/i&gt; &amp;gt; &lt;i&gt;Create Horizontal chain&lt;/i&gt;). Ajustamos los márgenes: el margen izquierdo del botón izquierdo, los márgenes derecho e izquierdo del botón central y el márgen derecho del botón derecho con un valor de 16dp (@dimen/margen_ancho).&lt;br /&gt;
&lt;br /&gt;
Y ajustamos las sujecciones del botón central: desde su parte superior a la parte inferior del info_text y desde su parte inferior hasta la parte inferior del diseño. Cambiamos también su desviación vertical (&lt;i&gt;vertical bias&lt;/i&gt;) a 100 para situar los botones en la parte inferior del diseño.&lt;br /&gt;
&lt;pre class=&quot;hl&quot;&gt;&lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;Button&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;id&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@+id/boton_rojo&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_width&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;wrap_content&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_height&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;wrap_content&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_marginStart&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@dimen/margen_ancho&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;text&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@string/boton_rojo&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; app:&lt;span class=&quot;hl kwb&quot;&gt;layout_constraintBaseline_toBaselineOf&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@+id/boton_amarillo&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; app:&lt;span class=&quot;hl kwb&quot;&gt;layout_constraintEnd_toStartOf&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@+id/boton_amarillo&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; app:&lt;span class=&quot;hl kwb&quot;&gt;layout_constraintHorizontal_bias&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;0.5&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; app:&lt;span class=&quot;hl kwb&quot;&gt;layout_constraintStart_toStartOf&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;parent&quot;&lt;/span&gt; &lt;span class=&quot;hl kwa&quot;&gt;/&amp;gt;&lt;/span&gt;

&lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;Button&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;id&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@+id/boton_amarillo&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_width&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;wrap_content&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_height&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;wrap_content&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_marginLeft&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@dimen/margen_ancho&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_marginTop&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;16dp&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_marginRight&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@dimen/margen_ancho&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_marginBottom&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;16dp&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;text&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@string/boton_amarillo&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; app:&lt;span class=&quot;hl kwb&quot;&gt;layout_constraintBottom_toBottomOf&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;parent&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; app:&lt;span class=&quot;hl kwb&quot;&gt;layout_constraintEnd_toStartOf&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@+id/boton_verde&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; app:&lt;span class=&quot;hl kwb&quot;&gt;layout_constraintHorizontal_bias&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;0.5&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; app:&lt;span class=&quot;hl kwb&quot;&gt;layout_constraintStart_toEndOf&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@+id/boton_rojo&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; app:&lt;span class=&quot;hl kwb&quot;&gt;layout_constraintTop_toBottomOf&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@+id/info_text&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; app:&lt;span class=&quot;hl kwb&quot;&gt;layout_constraintVertical_bias&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;1.0&quot;&lt;/span&gt; &lt;span class=&quot;hl kwa&quot;&gt;/&amp;gt;&lt;/span&gt;

&lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;Button&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;id&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@+id/boton_verde&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_width&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;wrap_content&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_height&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;wrap_content&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_marginEnd&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@dimen/margen_ancho&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;text&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@string/boton_verde&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; app:&lt;span class=&quot;hl kwb&quot;&gt;layout_constraintBaseline_toBaselineOf&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@+id/boton_amarillo&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; app:&lt;span class=&quot;hl kwb&quot;&gt;layout_constraintEnd_toEndOf&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;parent&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; app:&lt;span class=&quot;hl kwb&quot;&gt;layout_constraintHorizontal_bias&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;0.5&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; app:&lt;span class=&quot;hl kwb&quot;&gt;layout_constraintStart_toEndOf&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@+id/boton_amarillo&quot;&lt;/span&gt; &lt;span class=&quot;hl kwa&quot;&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;br /&gt;
Probamos el diseño en diferentes dispositivos y orientaciones. Ya solo nos queda añadir los controladores para los botones, para que cuando sean pulsados cambie el color de los &lt;i&gt;TextView&lt;/i&gt;. Primero añadimos algunos colores al archivo values/colors.xml:&lt;br /&gt;
&lt;pre class=&quot;hl&quot;&gt;&lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;color&lt;/span&gt; &lt;span class=&quot;hl kwb&quot;&gt;name&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;verde&quot;&lt;/span&gt;&lt;span class=&quot;hl kwa&quot;&gt;&amp;gt;&lt;/span&gt;#&lt;span class=&quot;hl num&quot;&gt;12&lt;/span&gt;C700&lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;/color&amp;gt;&lt;/span&gt;
&lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;color&lt;/span&gt; &lt;span class=&quot;hl kwb&quot;&gt;name&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;rojo&quot;&lt;/span&gt;&lt;span class=&quot;hl kwa&quot;&gt;&amp;gt;&lt;/span&gt;#E54304&lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;/color&amp;gt;&lt;/span&gt;
&lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;color&lt;/span&gt; &lt;span class=&quot;hl kwb&quot;&gt;name&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;amarillo&quot;&lt;/span&gt;&lt;span class=&quot;hl kwa&quot;&gt;&amp;gt;&lt;/span&gt;#FFFF00&lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;/color&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;br /&gt;
En &lt;i&gt;MainActivity.kt&lt;/i&gt;, en la lista de elementos &lt;i&gt;clickableViews&lt;/i&gt; añadimos los botones a través de sus atributos &lt;i&gt;id&lt;/i&gt;:&lt;br /&gt;
&lt;pre class=&quot;hl&quot;&gt;&lt;span class=&quot;hl kwa&quot;&gt;val&lt;/span&gt; clickableViews &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;listOf&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; box_uno_txt&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; box_dos_txt&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; box_tres_txt&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; box_cuatro_txt&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; box_cinco_txt&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; constraint_layout&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; boton_rojo&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; boton_amarillo&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; boton_verde
&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;&lt;/pre&gt;
&lt;br /&gt;
Y en la función &lt;i&gt;pintarView()&lt;/i&gt; dentro de la expresión &lt;i&gt;when&lt;/i&gt; (antes de la instrucción &lt;i&gt;else&lt;/i&gt;) escribimos el código para cambiar los colores cuando se pulsan los botones:&lt;br /&gt;
&lt;pre class=&quot;hl&quot;&gt;&lt;span class=&quot;hl kwa&quot;&gt;private fun&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;pintarView&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;view&lt;span class=&quot;hl opt&quot;&gt;:&lt;/span&gt; View&lt;span class=&quot;hl opt&quot;&gt;) {&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;when&lt;/span&gt; &lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;view&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;id&lt;span class=&quot;hl opt&quot;&gt;) {&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; R&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;id&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;box_uno_txt &lt;span class=&quot;hl opt&quot;&gt;-&amp;gt;&lt;/span&gt; view&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;setBackgroundColor&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;Color&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;DKGRAY&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; R&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;id&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;box_dos_txt &lt;span class=&quot;hl opt&quot;&gt;-&amp;gt;&lt;/span&gt; view&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;setBackgroundColor&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;Color&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;GRAY&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; R&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;id&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;box_tres_txt &lt;span class=&quot;hl opt&quot;&gt;-&amp;gt;&lt;/span&gt; view&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;setBackgroundColor&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;Color&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;BLUE&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; R&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;id&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;box_cuatro_txt &lt;span class=&quot;hl opt&quot;&gt;-&amp;gt;&lt;/span&gt; view&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;setBackgroundColor&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;Color&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;MAGENTA&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; R&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;id&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;box_cinco_txt &lt;span class=&quot;hl opt&quot;&gt;-&amp;gt;&lt;/span&gt; view&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;setBackgroundColor&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;Color&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;BLUE&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; R&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;id&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;boton_rojo &lt;span class=&quot;hl opt&quot;&gt;-&amp;gt;&lt;/span&gt; box_tres_txt&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;setBackgroundResource&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;R&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;color&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;rojo&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; R&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;id&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;boton_amarillo &lt;span class=&quot;hl opt&quot;&gt;-&amp;gt;&lt;/span&gt; box_cuatro_txt&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;setBackgroundResource&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;R&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;color&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;amarillo&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; R&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;id&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;boton_verde &lt;span class=&quot;hl opt&quot;&gt;-&amp;gt;&lt;/span&gt; box_cinco_txt&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;setBackgroundResource&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;R&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;color&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;verde&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;else&lt;/span&gt; &lt;span class=&quot;hl opt&quot;&gt;-&amp;gt;&lt;/span&gt; view&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;setBackgroundColor&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;Color&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;LTGRAY&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt;&lt;/pre&gt;
&lt;br /&gt;
&lt;img border=&quot;0&quot; data-original-height=&quot;1600&quot; data-original-width=&quot;900&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg7ffNKYUrCCnUCQziqngR7uGJt3t8vpPNd2ZgYYl29P75tB4c-MlTLBEtj_g_sp0zTWD68OiohpZwrKj1M7O5jwZ07qPsr7ehPZot5AOd-SKjOtEdTOdJDMJwu37OjAZuOYdc9YRNLl5I/s1600/app.png&quot; /&gt;</content><link rel='replies' type='application/atom+xml' href='https://kotlindoc.blogspot.com/feeds/4328293334879004001/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='https://kotlindoc.blogspot.com/2019/08/fundamentos-de-android-diseno-con.html#comment-form' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='https://www.blogger.com/feeds/6895501055750567199/posts/default/4328293334879004001'/><link rel='self' type='application/atom+xml' href='https://www.blogger.com/feeds/6895501055750567199/posts/default/4328293334879004001'/><link rel='alternate' type='text/html' href='https://kotlindoc.blogspot.com/2019/08/fundamentos-de-android-diseno-con.html' title='Fundamentos de Android: Diseño con ConstraintLayout'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh4LgX1_wi90-k0pzKs5Z9fakaN8bhAYv1WeOD56Rqi0cpPxsDswXVZMdAt4gcD_HZ474-xH6UXRKKeP-4PGivsEQlH4pZ785LDQldeJM52L1087aKC_rdbXn-hVjlAm2w15Ti1It4s6bE/s72-c/constraint_layout.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6895501055750567199.post-3449447870730180342</id><published>2019-08-01T16:47:00.002+02:00</published><updated>2019-08-10T16:03:09.744+02:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="colecciones"/><title type='text'>Operaciones con colecciones VIII: obtener valores de agrupación</title><content type='html'>&lt;img alt=&quot;Operaciones con colecciones VIII: obtener valores de agrupación&quot; border=&quot;0&quot; data-original-height=&quot;582&quot; data-original-width=&quot;886&quot; height=&quot;420&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhjRMVD6tBl3uvztCPWxcCbxd9AYKmnL1GjxsD6QWOkzud80_ptiqvfI4VPXAoL_eZOp57VlvIjSQKkC49twPSYvmSS2mgbntBsm6Nom58fukaP32A2xQ2b8qlwty6XC3Bsks7QQmueOwY/s640/agrupacion.png&quot; title=&quot;Operaciones con colecciones VIII: obtener valores de agrupación&quot; width=&quot;640&quot; /&gt;&lt;br /&gt;
&lt;br /&gt;
Continuando la serie sobre &lt;a href=&quot;https://kotlindoc.blogspot.com/2019/06/operaciones-con-colecciones-i.html&quot;&gt;operaciones con colecciones&lt;/a&gt;, en esta entrada vamos a ver un conjunto de funciones que realizan operaciones (de agrupación o agregación, del inglés &lt;i&gt;aggregate operations&lt;/i&gt;) para calcular ciertos valores o índices de agrupación a partir de los datos de la colección, como por ejemplo, los valores mínimo y máximo, el número de elementos, la suma de todos los elementos, la media o la suma acumulada&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;. Un ejemplo de operación de agrupamiento es el cálculo del promedio de temperatura a partir de los valores de temperatura diaria durante un mes.&lt;br /&gt;
&lt;br /&gt;
Ejemplos de este tipo de funciones son:&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;&lt;i&gt;min()&lt;/i&gt; y &lt;i&gt;max()&lt;/i&gt;, que devuelven el elemento más pequeño y el más grande respectivamente.&lt;/li&gt;
&lt;li&gt;&lt;i&gt;average()&lt;/i&gt;, que devuelve el valor promedio en una colección de números.&lt;/li&gt;
&lt;li&gt;&lt;i&gt;sum()&lt;/i&gt;, que devuelve la suma de elementos en una colección de números.&lt;/li&gt;
&lt;li&gt;&lt;i&gt;count()&lt;/i&gt;, que devuelve el número de elementos en una colección.&lt;/li&gt;
&lt;/ul&gt;
&lt;pre class=&quot;hl&quot;&gt;&lt;span class=&quot;hl kwa&quot;&gt;fun&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;main&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;() {&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;val&lt;/span&gt; gradosC &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;listOf&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl num&quot;&gt;25.5&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;hl num&quot;&gt;26.1&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;hl num&quot;&gt;24.3&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;hl num&quot;&gt;25.2&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwd&quot;&gt;println&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl str&quot;&gt;&quot;Datos:&lt;/span&gt; &lt;span class=&quot;hl ipl&quot;&gt;${gradosC.count()}&lt;/span&gt;&lt;span class=&quot;hl str&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwd&quot;&gt;println&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl str&quot;&gt;&quot;Máximo: %.1f&quot;&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;format&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;gradosC&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;max&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;()))&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwd&quot;&gt;println&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl str&quot;&gt;&quot;Mínimo: %.1f&quot;&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;format&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;gradosC&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;min&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;()))&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwd&quot;&gt;println&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl str&quot;&gt;&quot;Media: %.1f&quot;&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;format&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;gradosC&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;average&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;()))&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwd&quot;&gt;println&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl str&quot;&gt;&quot;Suma: %.1f&quot;&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;format&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;gradosC&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;sum&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;()))&lt;/span&gt;
&lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt;&lt;/pre&gt;
&lt;br /&gt;
También hay otras funciones que sirven para recuperar los &lt;b&gt;elementos más pequeños y más grandes&lt;/b&gt; mediante funciones de selección o mediante un comparador personalizado, como son:&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;&lt;i&gt;maxBy()&lt;/i&gt; y &lt;i&gt;minBy()&lt;/i&gt;, que mediante una función de selección devuelven el elemento con el valor más grande o más pequeño (o en caso de igualdad, el primero que encuentra).&lt;/li&gt;
&lt;li&gt;&lt;i&gt;maxWith()&lt;/i&gt; y &lt;i&gt;minWith()&lt;/i&gt;, que tomando como referencia un objeto de tipo &lt;i&gt;Comparator&lt;/i&gt; devuelven el elemento más grande o más pequeño (o en caso de igualdad, el primero que encuentra).&lt;/li&gt;
&lt;/ul&gt;
&lt;pre class=&quot;hl&quot;&gt;&lt;span class=&quot;hl kwa&quot;&gt;fun&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;main&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;() {&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;val&lt;/span&gt; numeros &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;listOf&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl num&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;hl num&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;hl num&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;hl num&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;hl num&quot;&gt;5&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;val&lt;/span&gt; moduloDos &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; numeros&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;minBy &lt;span class=&quot;hl opt&quot;&gt;{&lt;/span&gt; it &lt;span class=&quot;hl opt&quot;&gt;%&lt;/span&gt; &lt;span class=&quot;hl num&quot;&gt;2&lt;/span&gt; &lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwd&quot;&gt;println&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;moduloDos&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;hl slc&quot;&gt;// 2&lt;/span&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;val&lt;/span&gt; strings &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;listOf&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl str&quot;&gt;&quot;uno&quot;&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;hl str&quot;&gt;&quot;dos&quot;&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;hl str&quot;&gt;&quot;tres&quot;&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;hl str&quot;&gt;&quot;cuatro&quot;&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;hl str&quot;&gt;&quot;cinco&quot;&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;val&lt;/span&gt; masLargo &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; strings&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;maxWith&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;compareBy &lt;span class=&quot;hl opt&quot;&gt;{&lt;/span&gt; it&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;length &lt;span class=&quot;hl opt&quot;&gt;})&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwd&quot;&gt;println&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;masLargo&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;hl slc&quot;&gt;// cuatro&lt;/span&gt;
&lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt;&lt;/pre&gt;
&lt;br /&gt;
Además, hay funciones de suma avanzada o compleja que toman una función que opera sobre los elementos y devuelven la &lt;b&gt;suma total&lt;/b&gt; de los valores de retorno:&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;&lt;i&gt;sumBy()&lt;/i&gt; se aplica a funciones que devuelven valores de tipo Int en los elementos de la colección.&lt;/li&gt;
&lt;li&gt;&lt;i&gt;sumByDouble()&lt;/i&gt; funciona con funciones que devuelven valores de tipo Double.&lt;/li&gt;
&lt;/ul&gt;
&lt;pre class=&quot;hl&quot;&gt;&lt;span class=&quot;hl kwa&quot;&gt;val&lt;/span&gt; numeros &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;listOf&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl num&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;hl num&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;hl num&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;hl num&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;hl kwd&quot;&gt;println&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;numeros&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;sumBy &lt;span class=&quot;hl opt&quot;&gt;{&lt;/span&gt; it &lt;span class=&quot;hl opt&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;hl num&quot;&gt;2&lt;/span&gt; &lt;span class=&quot;hl opt&quot;&gt;})&lt;/span&gt; &lt;span class=&quot;hl slc&quot;&gt;// 20&lt;/span&gt;
&lt;span class=&quot;hl kwd&quot;&gt;println&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;numeros&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;sumByDouble &lt;span class=&quot;hl opt&quot;&gt;{&lt;/span&gt; it&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;toDouble&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;() /&lt;/span&gt; &lt;span class=&quot;hl num&quot;&gt;2&lt;/span&gt; &lt;span class=&quot;hl opt&quot;&gt;})&lt;/span&gt; &lt;span class=&quot;hl slc&quot;&gt;// 5.0&lt;/span&gt;&lt;/pre&gt;
&lt;br /&gt;
Por otro lado, existen las funciones &lt;i&gt;reduce()&lt;/i&gt; y &lt;i&gt;fold()&lt;/i&gt; que aplican la operación proporcionada a los elementos de la colección de forma secuencial y devuelven el &lt;b&gt;resultado acumulado&lt;/b&gt;. La operación toma dos argumentos: el valor acumulado previamente y el elemento de colección, con la diferencia de que &lt;i&gt;fold()&lt;/i&gt; toma un valor inicial y lo usa como el valor acumulado en el primer paso, mientras que &lt;i&gt;reduce()&lt;/i&gt; usa en el primer paso el primer y el segundo elementos como argumentos de la operación. Más claro en un ejemplo comentado:&lt;br /&gt;
&lt;pre class=&quot;hl&quot;&gt;&lt;span class=&quot;hl kwa&quot;&gt;fun&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;main&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;() {&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;val&lt;/span&gt; numeros &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;listOf&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl num&quot;&gt;5&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;hl num&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;hl num&quot;&gt;10&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;hl num&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;val&lt;/span&gt; acumulado &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; numeros&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;reduce &lt;span class=&quot;hl opt&quot;&gt;{&lt;/span&gt; sum&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; element &lt;span class=&quot;hl opt&quot;&gt;-&amp;gt;&lt;/span&gt; sum &lt;span class=&quot;hl opt&quot;&gt;+&lt;/span&gt; element &lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwd&quot;&gt;println&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;acumulado&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;hl slc&quot;&gt;// 5 -&amp;gt; (5 + 2) -&amp;gt; (7 + 10) -&amp;gt; (17 + 4) = 21&lt;/span&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;val&lt;/span&gt; desdeDiez &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; numeros&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;fold&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl num&quot;&gt;10&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;) {&lt;/span&gt; sum&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; element &lt;span class=&quot;hl opt&quot;&gt;-&amp;gt;&lt;/span&gt; sum &lt;span class=&quot;hl opt&quot;&gt;+&lt;/span&gt; element &lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwd&quot;&gt;println&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;desdeDiez&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;hl slc&quot;&gt;// 10 + 5 -&amp;gt; (15 + 2) -&amp;gt; (17 + 10) -&amp;gt; (27 + 4) = 31&lt;/span&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;val&lt;/span&gt; acumuladoDoble &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; numeros&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;fold&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl num&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;) {&lt;/span&gt; sum&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; element &lt;span class=&quot;hl opt&quot;&gt;-&amp;gt;&lt;/span&gt; sum &lt;span class=&quot;hl opt&quot;&gt;+&lt;/span&gt; element &lt;span class=&quot;hl opt&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;hl num&quot;&gt;2&lt;/span&gt; &lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwd&quot;&gt;println&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;acumuladoDoble&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;hl slc&quot;&gt;// 5x2 -&amp;gt; (10 + 2x2) -&amp;gt; (14 + 10x2) -&amp;gt; (34 + 4x2) = 42&lt;/span&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl slc&quot;&gt;// con reduce el primer elemento no se multiplica por 2:&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;val&lt;/span&gt; acumuladoDobleReduce &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; numeros&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;reduce &lt;span class=&quot;hl opt&quot;&gt;{&lt;/span&gt; sum&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; element &lt;span class=&quot;hl opt&quot;&gt;-&amp;gt;&lt;/span&gt; sum &lt;span class=&quot;hl opt&quot;&gt;+&lt;/span&gt; element &lt;span class=&quot;hl opt&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;hl num&quot;&gt;2&lt;/span&gt; &lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwd&quot;&gt;println&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;acumuladoDobleReduce&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;hl slc&quot;&gt;// 5 -&amp;gt; (5 + 2x2) -&amp;gt; (9 + 10x2) -&amp;gt; (29 + 4x2) = 37&lt;/span&gt;
&lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt;&lt;/pre&gt;
&lt;br /&gt;
Para aplicar estas funciones en el orden inverso, usamos las funciones &lt;i&gt;reduceRight()&lt;/i&gt; y &lt;i&gt;foldRight()&lt;/i&gt;, que operan de manera similar a &lt;i&gt;reduce()&lt;/i&gt; y &lt;i&gt;fold()&lt;/i&gt; pero comienzan desde el último elemento y avanzan hacia el anterior hasta el primero (además hay que tener en cuenta que en estas funciones los argumentos de la operación cambian su orden: primero va el elemento y luego el valor acumulado).&lt;br /&gt;
&lt;br /&gt;
También podemos realizar operaciones que toman los índices de los elementos como parámetros con las funciones &lt;i&gt;reduceIndexed()&lt;/i&gt; y &lt;i&gt;foldIndexed()&lt;/i&gt; pasando el índice del elemento como primer argumento de la operación (y las funciones inversas que aplican las operaciones a los elementos de la colección de derecha a izquierda: &lt;i&gt;reduceRightIndexed()&lt;/i&gt; y &lt;i&gt;foldRightIndexed()&lt;/i&gt;).&lt;br /&gt;
&lt;pre class=&quot;hl&quot;&gt;&lt;span class=&quot;hl kwa&quot;&gt;fun&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;main&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;() {&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;val&lt;/span&gt; numeros &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;listOf&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl num&quot;&gt;5&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;hl num&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;hl num&quot;&gt;10&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;hl num&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;val&lt;/span&gt; sumaPosicionesPares &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; numeros&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;foldIndexed&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl num&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;) {&lt;/span&gt; idx&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; suma&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; elemento &lt;span class=&quot;hl opt&quot;&gt;-&amp;gt;&lt;/span&gt; &lt;span class=&quot;hl kwa&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;idx &lt;span class=&quot;hl opt&quot;&gt;%&lt;/span&gt; &lt;span class=&quot;hl num&quot;&gt;2&lt;/span&gt; &lt;span class=&quot;hl opt&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;hl num&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt; suma &lt;span class=&quot;hl opt&quot;&gt;+&lt;/span&gt; elemento &lt;span class=&quot;hl kwa&quot;&gt;else&lt;/span&gt; suma &lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwd&quot;&gt;println&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;sumaPosicionesPares&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;hl slc&quot;&gt;// 5 -&amp;gt; 5 -&amp;gt; (5 + 10) -&amp;gt; 15 = 15&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl slc&quot;&gt;// idx = 0 -&amp;gt; 5 (suma + elemento)&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl slc&quot;&gt;// idx = 1 -&amp;gt; 5 (suma)&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl slc&quot;&gt;// idx = 2 -&amp;gt; 5 + 10 (suma + elemento)&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl slc&quot;&gt;// idx = 3 -&amp;gt; 15 (suma)&lt;/span&gt;
&lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt;&lt;/pre&gt;
</content><link rel='replies' type='application/atom+xml' href='https://kotlindoc.blogspot.com/feeds/3449447870730180342/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='https://kotlindoc.blogspot.com/2019/08/operaciones-con-colecciones-viii.html#comment-form' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='https://www.blogger.com/feeds/6895501055750567199/posts/default/3449447870730180342'/><link rel='self' type='application/atom+xml' href='https://www.blogger.com/feeds/6895501055750567199/posts/default/3449447870730180342'/><link rel='alternate' type='text/html' href='https://kotlindoc.blogspot.com/2019/08/operaciones-con-colecciones-viii.html' title='Operaciones con colecciones VIII: obtener valores de agrupación'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhjRMVD6tBl3uvztCPWxcCbxd9AYKmnL1GjxsD6QWOkzud80_ptiqvfI4VPXAoL_eZOp57VlvIjSQKkC49twPSYvmSS2mgbntBsm6Nom58fukaP32A2xQ2b8qlwty6XC3Bsks7QQmueOwY/s72-c/agrupacion.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6895501055750567199.post-8450405504249519438</id><published>2019-07-30T16:47:00.001+02:00</published><updated>2019-08-10T16:04:08.144+02:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="android básico"/><category scheme="http://www.blogger.com/atom/ns#" term="android studio"/><title type='text'>Fundamentos de Android: comunicación entre actividades</title><content type='html'>&lt;img alt=&quot;Fundamentos de Android: comunicación entre actividades&quot; border=&quot;0&quot; data-original-height=&quot;584&quot; data-original-width=&quot;891&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi8iXcVhBh2Qb7Zzkjtn6BJeXRrzfdmeKe4zW4k3JhV4bcwEhoBj3d82eIE4Zz_DTJ7mPvTxVH_Q6V9aywwcXwxnYlGKNJ35oSs1TPxgvWyqq8PerQhgUHFeCXuAoP5cZmL0gdBNaPtGFY/s1600/login.png&quot; title=&quot;Fundamentos de Android: comunicación entre actividades&quot; /&gt;&lt;br /&gt;
&lt;br /&gt;
Hasta ahora hemos visto aplicaciones sencillas con una sola actividad pero lo más común es que una aplicación tenga &lt;b&gt;varias actividades&lt;/b&gt;, y además que enviemos datos desde una a otra actividad. Vamos a verlo con un ejemplo.&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
Abrimos &lt;i&gt;Android Studio&lt;/i&gt; y creamos un nuevo proyecto llamado &#39;Control Acceso&#39; desde una actividad vacía (&lt;i&gt;Empty Activity&lt;/i&gt;):&lt;br /&gt;
&lt;br /&gt;
&lt;img border=&quot;0&quot; data-original-height=&quot;730&quot; data-original-width=&quot;904&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjDCeaYwqdNLGWuHiWRFRacWErWx33O4mwGgOcs2z08n7m49qzOoegxlSF3ef_8-7NLDfR5VqjXN1eOTA-uzy3dTPVlzIvwQnah8nVwYDTLQzN9CO6O-JxeqLZcVXkxpPh5K2qEKGOH3WE/s1600/newProject.png&quot; /&gt;&lt;br /&gt;
&lt;br /&gt;
Adaptamos el diseño de la actividad para que se muestre algo así:&lt;br /&gt;
&lt;br /&gt;
&lt;img border=&quot;0&quot; data-original-height=&quot;1600&quot; data-original-width=&quot;900&quot; height=&quot;640&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjqwKLA5iS43TpN6mWC12Lax8cBXyB5m4i0iUZl0xKhfFi8_3oDkXL82raZiJeqvlbcvwnoe1JXGlshjkZiW7z_Yjf4bFTbPcG4SX_ObFw-3rXG8lyC45mtpjtx9XfKYXFZgtiolr7QgI0/s640/dise%25C3%25B1o.png&quot; width=&quot;360&quot; /&gt;&lt;br /&gt;
&lt;br /&gt;
Para ello hemos utilizado elementos que ya conocemos, como &lt;i&gt;LinearLayout&lt;/i&gt; (vertical y horizontal) como contenedores para organizar el resto de elementos, elementos de texto (&lt;i&gt;TextView&lt;/i&gt; y &lt;i&gt;EditText&lt;/i&gt;) y un botón (que todavía no hace nada). El panel del árbol de componentes se ve así:&lt;br /&gt;
&lt;br /&gt;
&lt;img border=&quot;0&quot; data-original-height=&quot;302&quot; data-original-width=&quot;451&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhVTG8CmhcMGTsnN_Hk9VLIOnZTJNmjNsitsInamRkO1Z287AgWiv2OvBrNozjgBGEPRPDlOMSJL9UGC6p2c5jvJaQZ3GBUZ0XdnVyDAeP4jTvSq3bVyykvRuuRvZoR8yUe3iYKbNajbj8/s1600/arbol.png&quot; /&gt;&lt;br /&gt;
&lt;br /&gt;
También hemos utilizado recursos de texto (&lt;i&gt;values/strings.xml&lt;/i&gt;), de colores (&lt;i&gt;values/colors.xml&lt;/i&gt;), de dimensiones (&lt;i&gt;values/dimens.xml&lt;/i&gt;) y de estilos (&lt;i&gt;values/styles.xml&lt;/i&gt;). Ten en cuenta que cuando creamos estilos, &lt;i&gt;Android Studio&lt;/i&gt; nos pregunta en qué ámbito los vamos a usar, ya sea solo para ese archivo de diseño o para todo el proyecto; como después nos interesará aplicarlo también en otra actividad, hemos seleccionado que tengan alcance para todo el proyecto. Concretamente el archivo &lt;i&gt;layout/activity_main.xml&lt;/i&gt; es éste:&lt;br /&gt;
&lt;pre class=&quot;hl&quot;&gt;&lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;?xml&lt;/span&gt; &lt;span class=&quot;hl kwb&quot;&gt;version&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;1.0&quot;&lt;/span&gt; &lt;span class=&quot;hl kwb&quot;&gt;encoding&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;utf-8&quot;&lt;/span&gt;&lt;span class=&quot;hl kwa&quot;&gt;?&amp;gt;&lt;/span&gt;

&lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;LinearLayout&lt;/span&gt; xmlns:&lt;span class=&quot;hl kwb&quot;&gt;android&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;http://schemas.android.com/apk/res/android&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; xmlns:&lt;span class=&quot;hl kwb&quot;&gt;tools&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;http://schemas.android.com/tools&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_width&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;match_parent&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_height&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;match_parent&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;orientation&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;vertical&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; tools:&lt;span class=&quot;hl kwb&quot;&gt;context&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;.MainActivity&quot;&lt;/span&gt;&lt;span class=&quot;hl kwa&quot;&gt;&amp;gt;&lt;/span&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;LinearLayout&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;id&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@+id/linearLayout&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwb&quot;&gt;style&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@style/estilo_linear&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_width&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;match_parent&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_height&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;wrap_content&quot;&lt;/span&gt;&lt;span class=&quot;hl kwa&quot;&gt;&amp;gt;&lt;/span&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;TextView&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;id&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@+id/user_txt&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwb&quot;&gt;style&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@style/estilo_texto&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_width&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;wrap_content&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_height&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;wrap_content&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_marginEnd&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@dimen/margen_txt_end1&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;text&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@string/usuario&quot;&lt;/span&gt; &lt;span class=&quot;hl kwa&quot;&gt;/&amp;gt;&lt;/span&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;EditText&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;id&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@+id/user_input&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwb&quot;&gt;style&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@style/estilo_texto&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_width&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;wrap_content&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_height&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;wrap_content&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;ems&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;10&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;hint&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@string/usuario&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;inputType&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;textPersonName&quot;&lt;/span&gt; &lt;span class=&quot;hl kwa&quot;&gt;/&amp;gt;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;/LinearLayout&amp;gt;&lt;/span&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;LinearLayout&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;id&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@+id/linearLayout2&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwb&quot;&gt;style&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@style/estilo_linear&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_width&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;match_parent&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_height&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;wrap_content&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;gravity&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;center_horizontal&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;orientation&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;horizontal&quot;&lt;/span&gt;&lt;span class=&quot;hl kwa&quot;&gt;&amp;gt;&lt;/span&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;TextView&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;id&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@+id/pass_txt&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwb&quot;&gt;style&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@style/estilo_texto&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_width&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;wrap_content&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_height&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;wrap_content&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_marginEnd&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@dimen/margen_txt_end2&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;text&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@string/contraseña&quot;&lt;/span&gt; &lt;span class=&quot;hl kwa&quot;&gt;/&amp;gt;&lt;/span&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;EditText&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;id&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@+id/pass_input&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwb&quot;&gt;style&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@style/estilo_texto&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_width&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;wrap_content&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_height&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;wrap_content&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;ems&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;10&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;hint&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@string/contraseña&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;inputType&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;textPassword&quot;&lt;/span&gt; &lt;span class=&quot;hl kwa&quot;&gt;/&amp;gt;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;/LinearLayout&amp;gt;&lt;/span&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;Button&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;id&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@+id/entrar_btn&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwb&quot;&gt;style&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@style/Widget.AppCompat.Button.Colored&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_width&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;wrap_content&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_height&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;wrap_content&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_gravity&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;center_horizontal&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_marginTop&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@dimen/margen_linea&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;text&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@string/btn_entrar&quot;&lt;/span&gt; &lt;span class=&quot;hl kwa&quot;&gt;/&amp;gt;&lt;/span&gt;

&lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;/LinearLayout&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;br /&gt;
A partir de este diseño vamos a pretender que cuando el usuario introduzca un nombre de usuario y una contraseña pueda acceder a otra actividad, y desde esa nueva actividad pueda &#39;cerrar sesión&#39; y volver a la primera actividad.&lt;br /&gt;
&lt;br /&gt;
Para crear esta segunda actividad, desde el panel &lt;i&gt;Project&lt;/i&gt; (vista Android) &lt;i&gt;New&lt;/i&gt; -&amp;gt; &lt;i&gt;Activity&lt;/i&gt; -&amp;gt; &lt;i&gt;Empty Activity&lt;/i&gt; como se ve en la imagen:&lt;br /&gt;
&lt;br /&gt;
&lt;img border=&quot;0&quot; data-original-height=&quot;451&quot; data-original-width=&quot;850&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjp5R3YPllFGngOheJEQ6ym9oavbuZo9h0gAjn97ejt9BYxjnrqrI-_dqmyj02DCwIxI7TK0cMGfnFb6Hmcks3sxVQE4dLWkKZypN55mj-w3jT84e7yQ-MwUz8sbFUxX7f3o49tA6QnN80/s1600/newActivity.png&quot; /&gt;&lt;br /&gt;
&lt;br /&gt;
Y le asignamos un nombre a la nueva actividad:&lt;br /&gt;
&lt;br /&gt;
&lt;img border=&quot;0&quot; data-original-height=&quot;680&quot; data-original-width=&quot;804&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgPtETvLJV9dBnc1GQX0XYHTpNokDjaW1t9bTKWDNetRHuOlnHKKP0YaWboHKiYX_qtTzFU8nPtMi_zr8man0xHu0H-aB3KJpjlAKksAf61n4m17gnHPzjFoz9KPwAI0Dfl5TqjYL9mnVk/s1600/loginCheck.png&quot; /&gt;&lt;br /&gt;
&lt;br /&gt;
Ahora ya tenemos, además del archivo de la actividad &lt;i&gt;app/src/main/java/com/android/controlacceso/LoginCheck.kt&lt;/i&gt;, su correspondiente archivo de diseño &lt;i&gt;layout/activity_login_check.xml&lt;/i&gt;. Adaptamos el diseño de éste último para que se vea así:&lt;br /&gt;
&lt;br /&gt;
&lt;img border=&quot;0&quot; data-original-height=&quot;813&quot; data-original-width=&quot;1156&quot; height=&quot;450&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjzf6O3q6ArOQL6_akzxZK-8Idn0sNQ3BpYhmISNci1VMIBp5JWX9lxqgBEsF4A6kEjD8An630CaeiGMLbk-2Q8R2LaZqSHvMGTLd2-Hb8GFTFk6ypdRwfk_b9zi4khKlEAC4tNr4eiNko/s640/dise%25C3%25B1o2.png&quot; width=&quot;640&quot; /&gt;&lt;br /&gt;
&lt;br /&gt;
Y el archivo &lt;i&gt;layout/activity_login_check.xml&lt;/i&gt; es:&lt;br /&gt;
&lt;pre class=&quot;hl&quot;&gt;&lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;?xml&lt;/span&gt; &lt;span class=&quot;hl kwb&quot;&gt;version&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;1.0&quot;&lt;/span&gt; &lt;span class=&quot;hl kwb&quot;&gt;encoding&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;utf-8&quot;&lt;/span&gt;&lt;span class=&quot;hl kwa&quot;&gt;?&amp;gt;&lt;/span&gt;

&lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;LinearLayout&lt;/span&gt; xmlns:&lt;span class=&quot;hl kwb&quot;&gt;android&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;http://schemas.android.com/apk/res/android&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; xmlns:&lt;span class=&quot;hl kwb&quot;&gt;tools&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;http://schemas.android.com/tools&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwb&quot;&gt;style&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@style/estilo_linear&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_width&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;match_parent&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_height&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;match_parent&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;orientation&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;vertical&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; tools:&lt;span class=&quot;hl kwb&quot;&gt;context&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;.LoginCheck&quot;&lt;/span&gt;&lt;span class=&quot;hl kwa&quot;&gt;&amp;gt;&lt;/span&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;TextView&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;id&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@+id/acceso_txt&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwb&quot;&gt;style&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@style/estilo_texto&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_width&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;wrap_content&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_height&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;wrap_content&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_marginTop&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@dimen/margen_linea&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;text&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@string/login_check&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;textAlignment&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;center&quot;&lt;/span&gt; &lt;span class=&quot;hl kwa&quot;&gt;/&amp;gt;&lt;/span&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;TextView&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;id&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@+id/login_txt&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwb&quot;&gt;style&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@style/estilo_texto&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_width&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;wrap_content&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_height&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;wrap_content&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_marginTop&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@dimen/margen_linea&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;text&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@string/bienvenido&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;textAlignment&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;center&quot;&lt;/span&gt; &lt;span class=&quot;hl kwa&quot;&gt;/&amp;gt;&lt;/span&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;Button&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;id&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@+id/button_cerrar&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_width&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;wrap_content&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_height&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;wrap_content&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;layout_marginTop&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@dimen/margen_linea&quot;&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:&lt;span class=&quot;hl kwb&quot;&gt;text&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;@string/cerrar&quot;&lt;/span&gt; &lt;span class=&quot;hl kwa&quot;&gt;/&amp;gt;&lt;/span&gt;
&lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;/LinearLayout&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;br /&gt;
Ahora que ya tenemos dos actividades, en la actividad principal tenemos que implementar la funcionalidad para activar la segunda ventana. Para ello, como vimos en la entrada &lt;a href=&quot;https://kotlindoc.blogspot.com/2019/07/fundamentos-de-android-interaccion-del.html&quot;&gt;Fundamentos de Android: Interacción del usuario&lt;/a&gt;, utilizamos la llamada a &lt;i&gt;setOnClickListener&lt;/i&gt; para manejar el evento de clic sobre el botón:&lt;br /&gt;
&lt;pre class=&quot;hl&quot;&gt;entrar_btn&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;setOnClickListener &lt;span class=&quot;hl opt&quot;&gt;{ }&lt;/span&gt;&lt;/pre&gt;
Y como bloque de este controlador creamos un objeto de la clase &lt;i&gt;Intent&lt;/i&gt; con dos parámetros: la referencia a esta clase (&lt;i&gt;this&lt;/i&gt;) y la referencia a la otra actividad (&lt;i&gt;LoginCheck::class.java&lt;/i&gt;). Y después llamamos al método &lt;i&gt;startActivity&lt;/i&gt; pasándole ese objeto de la clase &lt;i&gt;Intent&lt;/i&gt;:&lt;br /&gt;
&lt;pre class=&quot;hl&quot;&gt;entrar_btn&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;setOnClickListener &lt;span class=&quot;hl opt&quot;&gt;{&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;val&lt;/span&gt; intento1 &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;Intent&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl kwa&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; LoginCheck&lt;span class=&quot;hl opt&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl kwa&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;java&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwd&quot;&gt;startActivity&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;intento1&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt;&lt;/pre&gt;
&lt;br /&gt;
Quedando el archivo &lt;i&gt;MainActivity.kt&lt;/i&gt; así:&lt;br /&gt;
&lt;pre class=&quot;hl&quot;&gt;&lt;span class=&quot;hl kwa&quot;&gt;package&lt;/span&gt; com&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;android&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;controlacceso

&lt;span class=&quot;hl kwa&quot;&gt;import&lt;/span&gt; android&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;content&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;Intent
&lt;span class=&quot;hl kwa&quot;&gt;import&lt;/span&gt; android&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;os&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;Bundle
&lt;span class=&quot;hl kwa&quot;&gt;import&lt;/span&gt; androidx&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;appcompat&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;app&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;AppCompatActivity
&lt;span class=&quot;hl kwa&quot;&gt;import&lt;/span&gt; kotlinx&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;android&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;synthetic&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;main&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;activity_main&lt;span class=&quot;hl opt&quot;&gt;.*&lt;/span&gt;

&lt;span class=&quot;hl kwa&quot;&gt;class&lt;/span&gt; MainActivity &lt;span class=&quot;hl opt&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;AppCompatActivity&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;() {&lt;/span&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;override fun&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;onCreate&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;savedInstanceState&lt;span class=&quot;hl opt&quot;&gt;:&lt;/span&gt; Bundle?&lt;span class=&quot;hl opt&quot;&gt;) {&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;super&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;onCreate&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;savedInstanceState&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwd&quot;&gt;setContentView&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;R&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;layout&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;activity_main&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; entrar_btn&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;setOnClickListener &lt;span class=&quot;hl opt&quot;&gt;{&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;val&lt;/span&gt; intento1 &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;Intent&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl kwa&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; LoginCheck&lt;span class=&quot;hl opt&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl kwa&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;java&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwd&quot;&gt;startActivity&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;intento1&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt;&lt;/pre&gt;
&lt;br /&gt;
Ejecutamos en un emulador de Android y comprobamos que al pulsar el botón &#39;ENTRAR&#39; de la actividad principal aparece la segunda ventana. Repetimos el mismo proceso en la segunda actividad para que al pulsar el botón &#39;CERRAR SESIÓN&#39; volvamos a la actividad anterior, pero aunque podríamos pensar en este código:
&lt;br /&gt;
&lt;pre class=&quot;hl&quot;&gt;button_cerrar&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;setOnClickListener &lt;span class=&quot;hl opt&quot;&gt;{&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;val&lt;/span&gt; intento2 &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;Intent&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl kwa&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; MainActivity&lt;span class=&quot;hl opt&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl kwa&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;java&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwd&quot;&gt;startActivity&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;intento2&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt;&lt;/pre&gt;
Y aunque parece funcionar, resulta mejor así:&lt;br /&gt;
&lt;pre class=&quot;hl&quot;&gt;button_cerrar&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;setOnClickListener &lt;span class=&quot;hl opt&quot;&gt;{&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwd&quot;&gt;finish&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;()&lt;/span&gt;
&lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt;&lt;/pre&gt;
El método &lt;i&gt;finish()&lt;/i&gt; tiene por objetivo liberar el espacio de memoria de esta actividad y pedir que se muestre la actividad anterior. El archivo &lt;i&gt;LoginCheck.kt&lt;/i&gt; queda así:&lt;br /&gt;
&lt;pre class=&quot;hl&quot;&gt;&lt;span class=&quot;hl kwa&quot;&gt;package&lt;/span&gt; com&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;android&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;controlacceso

&lt;span class=&quot;hl kwa&quot;&gt;import&lt;/span&gt; android&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;os&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;Bundle
&lt;span class=&quot;hl kwa&quot;&gt;import&lt;/span&gt; androidx&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;appcompat&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;app&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;AppCompatActivity
&lt;span class=&quot;hl kwa&quot;&gt;import&lt;/span&gt; kotlinx&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;android&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;synthetic&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;main&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;activity_login_check&lt;span class=&quot;hl opt&quot;&gt;.*&lt;/span&gt;

&lt;span class=&quot;hl kwa&quot;&gt;class&lt;/span&gt; LoginCheck &lt;span class=&quot;hl opt&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;AppCompatActivity&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;() {&lt;/span&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;override fun&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;onCreate&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;savedInstanceState&lt;span class=&quot;hl opt&quot;&gt;:&lt;/span&gt; Bundle?&lt;span class=&quot;hl opt&quot;&gt;) {&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;super&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;onCreate&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;savedInstanceState&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwd&quot;&gt;setContentView&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;R&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;layout&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;activity_login_check&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; button_cerrar&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;setOnClickListener &lt;span class=&quot;hl opt&quot;&gt;{&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwd&quot;&gt;finish&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;()&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt;&lt;/pre&gt;
&lt;br /&gt;
Pero la aplicación todavía no es funcional. En este momento le faltan, al menos, tres cosas importantes a la aplicación:&lt;br /&gt;
&lt;ol&gt;
&lt;li&gt;Comprobar que los campos de usuario y contraseña no están vacíos (en próximas entradas perfecionaremos la aplicación permitiendo el registro de usuarios y verificando los datos de acceso).&lt;/li&gt;
&lt;li&gt;Pasar el nombre de usuario a la segunda actividad.&lt;/li&gt;
&lt;li&gt;Después de cerrar sesión y volver a la primera actividad, limpiar los datos introducidos (medida elemental de seguridad para que después de cerrar sesión no permanezcan los datos en la primera actividad y alguién pueda acceder simplemente pulsando el botón de ENTRAR).&lt;/li&gt;
&lt;/ol&gt;
&lt;br /&gt;
Vamos con ellas. Para la primera tarea vamos a utilizar lo visto en la entrada &lt;a href=&quot;https://kotlindoc.blogspot.com/2019/04/programa-para-verificar-si-un-string.html&quot;&gt;Programa para verificar si un String está vacío o es nulo&lt;/a&gt;, de esta manera:&lt;br /&gt;
&lt;pre class=&quot;hl&quot;&gt;&lt;span class=&quot;hl kwa&quot;&gt;package&lt;/span&gt; com&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;android&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;controlacceso

&lt;span class=&quot;hl kwa&quot;&gt;import&lt;/span&gt; android&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;content&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;Intent
&lt;span class=&quot;hl kwa&quot;&gt;import&lt;/span&gt; android&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;os&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;Bundle
&lt;span class=&quot;hl kwa&quot;&gt;import&lt;/span&gt; android&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;widget&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;Toast
&lt;span class=&quot;hl kwa&quot;&gt;import&lt;/span&gt; androidx&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;appcompat&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;app&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;AppCompatActivity
&lt;span class=&quot;hl kwa&quot;&gt;import&lt;/span&gt; kotlinx&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;android&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;synthetic&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;main&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;activity_main&lt;span class=&quot;hl opt&quot;&gt;.*&lt;/span&gt;

&lt;span class=&quot;hl kwa&quot;&gt;class&lt;/span&gt; MainActivity &lt;span class=&quot;hl opt&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;AppCompatActivity&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;() {&lt;/span&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;override fun&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;onCreate&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;savedInstanceState&lt;span class=&quot;hl opt&quot;&gt;:&lt;/span&gt; Bundle?&lt;span class=&quot;hl opt&quot;&gt;) {&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;super&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;onCreate&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;savedInstanceState&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwd&quot;&gt;setContentView&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;R&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;layout&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;activity_main&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; entrar_btn&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;setOnClickListener &lt;span class=&quot;hl opt&quot;&gt;{&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;hl opt&quot;&gt;(!&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;esNuloVacio&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;user_input&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;text&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;toString&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;()) &amp;amp;&amp;amp; !&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;esNuloVacio&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;pass_input&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;text&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;toString&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;())) {&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;val&lt;/span&gt; intento1 &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;Intent&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl kwa&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; LoginCheck&lt;span class=&quot;hl opt&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl kwa&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;java&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwd&quot;&gt;startActivity&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;intento1&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;hl kwa&quot;&gt;else&lt;/span&gt; &lt;span class=&quot;hl opt&quot;&gt;{&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Toast&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;makeText&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;hl str&quot;&gt;&quot;ERROR: Usuario y contraseña requeridos.&quot;&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Toast&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;LENGTH_SHORT
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl opt&quot;&gt;).&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;show&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;()&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;private fun&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;esNuloVacio&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;str&lt;span class=&quot;hl opt&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;hl kwb&quot;&gt;String&lt;/span&gt;?&lt;span class=&quot;hl opt&quot;&gt;):&lt;/span&gt; &lt;span class=&quot;hl kwb&quot;&gt;Boolean&lt;/span&gt; &lt;span class=&quot;hl opt&quot;&gt;{&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;return if&lt;/span&gt; &lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;str &lt;span class=&quot;hl opt&quot;&gt;!=&lt;/span&gt; &lt;span class=&quot;hl kwa&quot;&gt;null&lt;/span&gt; &lt;span class=&quot;hl opt&quot;&gt;&amp;amp;&amp;amp; !&lt;/span&gt;str&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;trim&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;().&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;isEmpty&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;())&lt;/span&gt; &lt;span class=&quot;hl kwa&quot;&gt;false else true&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl slc&quot;&gt;// más elegante así:&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl slc&quot;&gt;// return !(str != null &amp;amp;&amp;amp; !str.trim().isEmpty())&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt;&lt;/pre&gt;
&lt;br /&gt;
Primer objetivo conseguido: si cualquiera de los campos de usuario o contraseña están vacíos (o solo contienen espacios en blanco) aparece un mensaje de advertencia del error y no pasa a la actividad de acceso.&lt;br /&gt;
&lt;br /&gt;
Segunda tarea: pasar el nombre del usuario a la segunda actividad. Esto lo podemos hacer llamando al método &lt;i&gt;putExtra&lt;/i&gt; de la clase &lt;i&gt;Intent&lt;/i&gt; con dos parámetros de tipo &lt;i&gt;String&lt;/i&gt;: el nombre del dato y el valor de ese dato:&lt;br /&gt;
&lt;pre class=&quot;hl&quot;&gt;&lt;span class=&quot;hl kwa&quot;&gt;val&lt;/span&gt; intento1 &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;Intent&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl kwa&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; LoginCheck&lt;span class=&quot;hl opt&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl kwa&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;java&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;
intento1&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;putExtra&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl str&quot;&gt;&quot;usuario&quot;&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; user_input&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;text&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;toString&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;())&lt;/span&gt;
&lt;span class=&quot;hl kwd&quot;&gt;startActivity&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;intento1&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;&lt;/pre&gt;
&lt;br /&gt;
Y para recuperar ese valor desde la otra actividad definimos una variable de tipo &lt;i&gt;Bundle&lt;/i&gt; que obtiene el &lt;i&gt;String&lt;/i&gt; a partir del nombre del dato que envió la primera actividad:&lt;br /&gt;
&lt;pre class=&quot;hl&quot;&gt;&lt;span class=&quot;hl kwa&quot;&gt;val&lt;/span&gt; bundle &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; intent&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;extras
&lt;span class=&quot;hl kwa&quot;&gt;val&lt;/span&gt; user &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; bundle?&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;getString&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl str&quot;&gt;&quot;usuario&quot;&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;&lt;/pre&gt;
Otra opción es:
&lt;br /&gt;
&lt;pre class=&quot;hl&quot;&gt;&lt;span class=&quot;hl kwa&quot;&gt;val&lt;/span&gt; user &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; intent&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;getStringExtra&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl str&quot;&gt;&quot;usuario&quot;&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;
&lt;/pre&gt;
Y después utilizamos el valor obtenido para mostrarlo en la actividad:&lt;br /&gt;
&lt;pre class=&quot;hl&quot;&gt;login_txt&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;text &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;getString&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;R&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;string&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;bienvenido&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; user&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;&lt;/pre&gt;
Para poder utilizar de esta manera el &lt;i&gt;TextView&lt;/i&gt; &#39;login_txt&#39; hemos creado el recurso de texto &#39;bienvenido&#39; en &lt;i&gt;values/strings.xml&lt;/i&gt; de esta manera:&lt;br /&gt;
&lt;pre class=&quot;hl&quot;&gt;&lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;string&lt;/span&gt; &lt;span class=&quot;hl kwb&quot;&gt;name&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;bienvenido&quot;&lt;/span&gt;&lt;span class=&quot;hl kwa&quot;&gt;&amp;gt;&lt;/span&gt;Bienvenido %&lt;span class=&quot;hl num&quot;&gt;1&lt;/span&gt;$s&lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;/string&amp;gt;&lt;/span&gt;&lt;/pre&gt;
Esta solución utiliza el formato %1$s y lo sustituye por el dato obtenido y guardado en la variable &lt;i&gt;user&lt;/i&gt;. Los especificadores de este formato se basan en la sintaxis &lt;i&gt;%[argument_index$]format_specifier&lt;/i&gt; donde &lt;i&gt;argument_index&lt;/i&gt; indica el orden del argumento especificado en la lista de argumentos y &lt;i&gt;format_specifier&lt;/i&gt; indica cómo debe formatearse según el tipo de dato (s: &lt;i&gt;String&lt;/i&gt;, d: &lt;i&gt;Int&lt;/i&gt;, f: &lt;i&gt;Float&lt;/i&gt;...). Como el primer argumento es opcional y solo usamos uno, en nuestro caso podemos escribir el recurso de texto así:&lt;br /&gt;
&lt;pre class=&quot;hl&quot;&gt;&lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;string&lt;/span&gt; &lt;span class=&quot;hl kwb&quot;&gt;name&lt;/span&gt;=&lt;span class=&quot;hl str&quot;&gt;&quot;bienvenido&quot;&lt;/span&gt;&lt;span class=&quot;hl kwa&quot;&gt;&amp;gt;&lt;/span&gt;Bienvenido %s&lt;span class=&quot;hl kwa&quot;&gt;&amp;lt;/string&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;br /&gt;
Objetivo conseguido: ahora cuando se entra a la segunda actividad ésta recupera el nombre de usuario que se ha enviado desde la primera actividad y lo muestra en el mensaje de bienvenida. En posteriores entradas veremos otras maneras para enviar varios datos a la vez con &lt;i&gt;Bundle&lt;/i&gt;.&lt;br /&gt;
&lt;br /&gt;
Siguiente tarea: limpiar datos al cerrar sesión. Para ello, después de obtener el valor de los campos, los vaciamos:&lt;br /&gt;
&lt;pre class=&quot;hl&quot;&gt;&lt;span class=&quot;hl kwa&quot;&gt;val&lt;/span&gt; intento1 &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;Intent&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl kwa&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; LoginCheck&lt;span class=&quot;hl opt&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl kwa&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;java&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;
intento1&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;putExtra&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl str&quot;&gt;&quot;usuario&quot;&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; user_input&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;text&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;toString&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;())&lt;/span&gt;
user_input&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;setText&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl str&quot;&gt;&quot;&quot;&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;
pass_input&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;setText&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl str&quot;&gt;&quot;&quot;&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;hl kwd&quot;&gt;startActivity&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;intento1&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;&lt;/pre&gt;
&lt;br /&gt;
&lt;img border=&quot;0&quot; data-original-height=&quot;579&quot; data-original-width=&quot;347&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhy9E40iIRVjHOE338XpMCVvWVSHXCrX9Gcu9knzXqS2koTOuGHFhDr4tgyjzmj3aIGAiPFuO3JmMLtPADuYol9_lJ7Xu_sn-zReRgotHl817A3bNlHjmdPHhDnBsM79RAWiZAN4N8BvgY/s1600/app.gif&quot; /&gt;&lt;br /&gt;
&lt;br /&gt;
A continuación los códigos de ambas actividades:&lt;br /&gt;
&lt;pre class=&quot;hl&quot;&gt;&lt;span class=&quot;hl kwa&quot;&gt;package&lt;/span&gt; com&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;android&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;controlacceso

&lt;span class=&quot;hl kwa&quot;&gt;import&lt;/span&gt; android&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;content&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;Intent
&lt;span class=&quot;hl kwa&quot;&gt;import&lt;/span&gt; android&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;os&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;Bundle
&lt;span class=&quot;hl kwa&quot;&gt;import&lt;/span&gt; android&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;widget&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;Toast
&lt;span class=&quot;hl kwa&quot;&gt;import&lt;/span&gt; androidx&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;appcompat&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;app&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;AppCompatActivity
&lt;span class=&quot;hl kwa&quot;&gt;import&lt;/span&gt; kotlinx&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;android&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;synthetic&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;main&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;activity_main&lt;span class=&quot;hl opt&quot;&gt;.*&lt;/span&gt;

&lt;span class=&quot;hl kwa&quot;&gt;class&lt;/span&gt; MainActivity &lt;span class=&quot;hl opt&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;AppCompatActivity&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;() {&lt;/span&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;override fun&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;onCreate&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;savedInstanceState&lt;span class=&quot;hl opt&quot;&gt;:&lt;/span&gt; Bundle?&lt;span class=&quot;hl opt&quot;&gt;) {&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;super&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;onCreate&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;savedInstanceState&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwd&quot;&gt;setContentView&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;R&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;layout&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;activity_main&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; entrar_btn&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;setOnClickListener &lt;span class=&quot;hl opt&quot;&gt;{&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;hl opt&quot;&gt;(!&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;esNuloVacio&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;user_input&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;text&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;toString&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;()) &amp;amp;&amp;amp; !&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;esNuloVacio&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;pass_input&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;text&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;toString&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;())) {&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;val&lt;/span&gt; intento1 &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;Intent&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl kwa&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; LoginCheck&lt;span class=&quot;hl opt&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;hl kwa&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;java&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; intento1&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;putExtra&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl str&quot;&gt;&quot;usuario&quot;&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; user_input&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;text&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;toString&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;())&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; user_input&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;setText&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl str&quot;&gt;&quot;&quot;&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; pass_input&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;setText&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl str&quot;&gt;&quot;&quot;&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwd&quot;&gt;startActivity&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;intento1&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;hl kwa&quot;&gt;else&lt;/span&gt; &lt;span class=&quot;hl opt&quot;&gt;{&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Toast&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;makeText&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;hl str&quot;&gt;&quot;ERROR: Usuario y contraseña requeridos.&quot;&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Toast&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;LENGTH_SHORT
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl opt&quot;&gt;).&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;show&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;()&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;private fun&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;esNuloVacio&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;str&lt;span class=&quot;hl opt&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;hl kwb&quot;&gt;String&lt;/span&gt;?&lt;span class=&quot;hl opt&quot;&gt;):&lt;/span&gt; &lt;span class=&quot;hl kwb&quot;&gt;Boolean&lt;/span&gt; &lt;span class=&quot;hl opt&quot;&gt;{&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;hl opt&quot;&gt;!(&lt;/span&gt;str &lt;span class=&quot;hl opt&quot;&gt;!=&lt;/span&gt; &lt;span class=&quot;hl kwa&quot;&gt;null&lt;/span&gt; &lt;span class=&quot;hl opt&quot;&gt;&amp;amp;&amp;amp; !&lt;/span&gt;str&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;trim&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;().&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;isEmpty&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;())&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt;&lt;/pre&gt;
&lt;pre class=&quot;hl&quot;&gt;&lt;span class=&quot;hl kwa&quot;&gt;package&lt;/span&gt; com&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;android&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;controlacceso

&lt;span class=&quot;hl kwa&quot;&gt;import&lt;/span&gt; android&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;os&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;Bundle
&lt;span class=&quot;hl kwa&quot;&gt;import&lt;/span&gt; androidx&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;appcompat&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;app&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;AppCompatActivity
&lt;span class=&quot;hl kwa&quot;&gt;import&lt;/span&gt; kotlinx&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;android&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;synthetic&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;main&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;activity_login_check&lt;span class=&quot;hl opt&quot;&gt;.*&lt;/span&gt;

&lt;span class=&quot;hl kwa&quot;&gt;class&lt;/span&gt; LoginCheck &lt;span class=&quot;hl opt&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;AppCompatActivity&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;() {&lt;/span&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;override fun&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;onCreate&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;savedInstanceState&lt;span class=&quot;hl opt&quot;&gt;:&lt;/span&gt; Bundle?&lt;span class=&quot;hl opt&quot;&gt;) {&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;super&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;onCreate&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;savedInstanceState&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwd&quot;&gt;setContentView&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;R&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;layout&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;activity_login_check&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;val&lt;/span&gt; bundle &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; intent&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;extras
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwa&quot;&gt;val&lt;/span&gt; user &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; bundle?&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl kwd&quot;&gt;getString&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl str&quot;&gt;&quot;usuario&quot;&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; login_txt&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;text &lt;span class=&quot;hl opt&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;hl kwd&quot;&gt;getString&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;(&lt;/span&gt;R&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;string&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;bienvenido&lt;span class=&quot;hl opt&quot;&gt;,&lt;/span&gt; user&lt;span class=&quot;hl opt&quot;&gt;)&lt;/span&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; button_cerrar&lt;span class=&quot;hl opt&quot;&gt;.&lt;/span&gt;setOnClickListener &lt;span class=&quot;hl opt&quot;&gt;{&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl kwd&quot;&gt;finish&lt;/span&gt;&lt;span class=&quot;hl opt&quot;&gt;()&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;hl opt&quot;&gt;}&lt;/span&gt;&lt;/pre&gt;
</content><link rel='replies' type='application/atom+xml' href='https://kotlindoc.blogspot.com/feeds/8450405504249519438/comments/default' title='Enviar comentarios'/><link rel='replies' type='text/html' href='https://kotlindoc.blogspot.com/2019/07/fundamentos-de-android-comunicacion.html#comment-form' title='0 comentarios'/><link rel='edit' type='application/atom+xml' href='https://www.blogger.com/feeds/6895501055750567199/posts/default/8450405504249519438'/><link rel='self' type='application/atom+xml' href='https://www.blogger.com/feeds/6895501055750567199/posts/default/8450405504249519438'/><link rel='alternate' type='text/html' href='https://kotlindoc.blogspot.com/2019/07/fundamentos-de-android-comunicacion.html' title='Fundamentos de Android: comunicación entre actividades'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi8iXcVhBh2Qb7Zzkjtn6BJeXRrzfdmeKe4zW4k3JhV4bcwEhoBj3d82eIE4Zz_DTJ7mPvTxVH_Q6V9aywwcXwxnYlGKNJ35oSs1TPxgvWyqq8PerQhgUHFeCXuAoP5cZmL0gdBNaPtGFY/s72-c/login.png" height="72" width="72"/><thr:total>0</thr:total></entry></feed>