<?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-921091465317807586</id><updated>2024-08-29T00:19:51.972-07:00</updated><category term="Android 4"/><category term="Codice"/><category term="esempio"/><category term="Android SDK"/><category term="Aggiornamento"/><category term="Android TextView"/><category term="Face Unlock"/><category term="News"/><category term="TextView"/><category term="installazione"/><title type='text'>Android</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://bluedreamsandroid.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/921091465317807586/posts/default?redirect=false'/><link rel='alternate' type='text/html' href='http://bluedreamsandroid.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>BlueDremas</name><uri>http://www.blogger.com/profile/02561736174885737185</uri><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>15</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-921091465317807586.post-3753919548147003720</id><published>2011-11-18T05:08:00.001-08:00</published><updated>2011-11-18T05:09:12.294-08:00</updated><title type='text'>HTC Zeta</title><content type='html'>In base alle ultime indiscrezioni provenienti dal web, &lt;strong&gt;HTC&lt;/strong&gt; starebbe progettando  un nuovo &lt;strong&gt;smartphone Android&lt;/strong&gt; il cui nome in codice è &lt;strong&gt;HTC Zeta.&lt;/strong&gt;&lt;br /&gt;
&lt;br /&gt;
Il nuovo smartphone sarà basato sul sistema operativo Android 4.0 Ice Cream Sandwich, e sarà dotato di un display da 4,5 pollici.&lt;br /&gt;
&lt;br /&gt;
HTC Zeta dovrebbe montare un processore quad core APQ8064 da 2,5 GHz, sarà dotato di 1 GB di RAM, 32 GB di memoria interna, ed inoltre equipaggiato con due fotocamere, una frontale per le videochiamate da 1,3 megapixel, e una posteriore da 8 megapixel con doppio flash LED e Full HD a 1080p.&lt;br /&gt;
&lt;br /&gt;
Per quanto riguarda la connettività, il nuovo HTC Zeta sarà dotato di modulo WiFi e Bluetooth 3.0.&lt;br /&gt;
Ancora non si è avuta nessuna anticipazione in merito al prezzo del nuovo dispositivo dell’azienda taiwanese, né è trapelata alcuna notizia relativa ai tempi di immissione sul mercato, quindi non ci resta che attendere comunicazioni ufficiali in merito.&lt;br /&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;</content><link rel='replies' type='application/atom+xml' href='http://bluedreamsandroid.blogspot.com/feeds/3753919548147003720/comments/default' title='Commenti sul post'/><link rel='replies' type='text/html' href='http://bluedreamsandroid.blogspot.com/2011/11/htc-zeta.html#comment-form' title='0 Commenti'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/921091465317807586/posts/default/3753919548147003720'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/921091465317807586/posts/default/3753919548147003720'/><link rel='alternate' type='text/html' href='http://bluedreamsandroid.blogspot.com/2011/11/htc-zeta.html' title='HTC Zeta'/><author><name>BlueDremas</name><uri>http://www.blogger.com/profile/02561736174885737185</uri><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><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-921091465317807586.post-2965456550128740892</id><published>2011-11-16T15:03:00.001-08:00</published><updated>2011-11-16T15:04:29.958-08:00</updated><title type='text'>MIUI rom basata su Android 4</title><content type='html'>Sono stati rilasciati i sorgenti di &lt;strong&gt;Android 4.0 Ice Cream Sandwich&lt;/strong&gt;, gli sviluppatori più famosi hanno iniziato a pensare e a stimare quando potrebbero riuscire a rilasciare le proprie custom roms.&lt;br /&gt;
E dopo Cyanogen che ha annunciato la sua &lt;span style=&quot;color: #76ae40;&quot;&gt;CyanogenMod 9.0&lt;/span&gt; fra 2 mesi, anche il team &lt;strong&gt;MIUI&lt;/strong&gt; fa sentire la propria voce assicurando che all’&lt;strong&gt;inizio di Dicembre&lt;/strong&gt; vedremo probabilmente i primi firmware basati su &lt;strong&gt;Android 4.0&lt;/strong&gt;.&lt;br /&gt;
Il primo smartphone a ricevere la &lt;strong&gt;MIUI&lt;/strong&gt; con Android 4.0, secondo un recente twitter sarà proprio il &lt;strong&gt;Nexus S&lt;/strong&gt; e probabilmente il &lt;strong&gt;MIUI Phone&lt;/strong&gt;.</content><link rel='replies' type='application/atom+xml' href='http://bluedreamsandroid.blogspot.com/feeds/2965456550128740892/comments/default' title='Commenti sul post'/><link rel='replies' type='text/html' href='http://bluedreamsandroid.blogspot.com/2011/11/miui-rom-basata-su-android-4.html#comment-form' title='0 Commenti'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/921091465317807586/posts/default/2965456550128740892'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/921091465317807586/posts/default/2965456550128740892'/><link rel='alternate' type='text/html' href='http://bluedreamsandroid.blogspot.com/2011/11/miui-rom-basata-su-android-4.html' title='MIUI rom basata su Android 4'/><author><name>BlueDremas</name><uri>http://www.blogger.com/profile/02561736174885737185</uri><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><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-921091465317807586.post-8956168079814173203</id><published>2011-11-15T05:09:00.001-08:00</published><updated>2011-11-15T05:10:33.232-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Android 4"/><category scheme="http://www.blogger.com/atom/ns#" term="Android SDK"/><title type='text'>SDK 4.0</title><content type='html'>E&#39; disponibile la nuova versione dell&#39;sdk per gli sviluppatori. Tantissime le novità e le api utilizzabili.&lt;br /&gt;
Il tutto lo trovate al seguente indirizzo &lt;a href=&quot;http://developer.android.com/sdk/android-4.0.html&quot;&gt;http://developer.android.com/sdk/android-4.0.html&lt;/a&gt;</content><link rel='replies' type='application/atom+xml' href='http://bluedreamsandroid.blogspot.com/feeds/8956168079814173203/comments/default' title='Commenti sul post'/><link rel='replies' type='text/html' href='http://bluedreamsandroid.blogspot.com/2011/11/sdk-40.html#comment-form' title='0 Commenti'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/921091465317807586/posts/default/8956168079814173203'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/921091465317807586/posts/default/8956168079814173203'/><link rel='alternate' type='text/html' href='http://bluedreamsandroid.blogspot.com/2011/11/sdk-40.html' title='SDK 4.0'/><author><name>BlueDremas</name><uri>http://www.blogger.com/profile/02561736174885737185</uri><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><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-921091465317807586.post-6429574018837618194</id><published>2011-11-14T09:10:00.001-08:00</published><updated>2011-11-14T09:11:16.046-08:00</updated><title type='text'>Google : Conversation Mode</title><content type='html'>&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Google sta &lt;span style=&quot;color: black;&quot;&gt;provando ad innovare il mondo dei traduttori online grazie ad un app per smartphone &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Verdana, sans-serif;&quot;&gt;Android &lt;/span&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;in grado ascoltare, trascrivere e tradurre oralmente, le frasi pronunciati dagli utente. L’applicazione&lt;/span&gt; si chiama &lt;/span&gt;&lt;a href=&quot;http://googlesystem.blogspot.com/2011/01/conversation-mode-in-google-translate.html&quot;&gt;&lt;span style=&quot;color: #f82b0c; font-family: Verdana, sans-serif;&quot;&gt;Conversation Mode&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt; ed è stata lanciata in occasione del primo anniversario del lancio di Google Traslate, uno dei servizi mobile di Big G più utilizzati e meglio riusciti, che permette di tradurre frasi e testi in 50 linguaggi. Funzionamento dell’app:&lt;/span&gt;&lt;br /&gt;
&lt;blockquote&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Si preme un pulsante sul touchscreen del dispositivo quando si vuole parlare. Dopo aver pronunciato una frase, che sarà “catturata” dal microfono dello smartphone, l’applicazione la tradurrà nel giro di pochi secondi nella lingua scelta e la riprodurrà ad alto volume. In questo modo si può tradurre un’intera conversazione. Basta tenere aperta l’app. Certo è che “la modalità di conversazione è ancora nelle sue prime fasi”, ha spiegato Awaneesh Verma, Product Manager di Google: la funzionalità non è sempre corretta al 100%, come qualsiasi metodo attuale di traduzione automatica, ma Google stessa spiega come i problemi nello sviluppo di un servizio simile siano tipici della natura del linguaggio: “Cangiante, vario e pieno di deviazioni basate su infiniti dialetti, accenti, slang o semplicemente discorsi rapidi”.&lt;/span&gt;&lt;/blockquote&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Attualmente le lingue disponibili nell’app sono solo tre: inglese, spagnolo e tedesco, ma da Mountain View promettono che il numero di idiomi aumenterà molto presto. Infine secondo Hugo Barra, Product Management Director di Google, Conversation Mode cambierà il modo di comunicare in futuro e diventerà il più grande traduttore simultaneo di sempre.&lt;/span&gt;</content><link rel='replies' type='application/atom+xml' href='http://bluedreamsandroid.blogspot.com/feeds/6429574018837618194/comments/default' title='Commenti sul post'/><link rel='replies' type='text/html' href='http://bluedreamsandroid.blogspot.com/2011/11/google-conversation-mode.html#comment-form' title='0 Commenti'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/921091465317807586/posts/default/6429574018837618194'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/921091465317807586/posts/default/6429574018837618194'/><link rel='alternate' type='text/html' href='http://bluedreamsandroid.blogspot.com/2011/11/google-conversation-mode.html' title='Google : Conversation Mode'/><author><name>BlueDremas</name><uri>http://www.blogger.com/profile/02561736174885737185</uri><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><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-921091465317807586.post-5246494015328425065</id><published>2011-11-11T09:03:00.000-08:00</published><updated>2011-11-14T14:43:47.699-08:00</updated><title type='text'>Google Music</title><content type='html'>&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Google ha indetto una conferenza stampa per mercoledì 16 novembre e sui siti già si vocifera che quella sarà la data di lancio di &lt;/span&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Google Music&lt;/span&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;. Google Music è un’applicazione in cloud che è già attiva in versione Beta, quindi solo per invito, negli Stati Uniti. L’&lt;/span&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;applicazione&lt;/span&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt; consente di ascoltare, comprare, scaricare e condividere musica.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Ad accettare l’&lt;/span&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;idea&lt;/span&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt; di Google sono state molte case discografiche indipendenti assieme a EMI e alla Vivendi SA’s Universal Music Group, le altre 2 grandi, Warner e Sony, stanno prendendo tempo e faranno sapere in futuro se accettarono o meno la sfida.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;L’accordo con &lt;/span&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;le 4 majior&lt;/span&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt; è molo importante perchè  servirà a dare ossigeno al neonato servizio di Google che con l’assenso anche della Warner e della Sony riuscirebbe a coprire l’87% della musica che si vende negli States.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black; font-family: Verdana, sans-serif;&quot;&gt;Google Music non farebbe altro che rincorrere la Apple con il suo iTunes, ma considerando l’alto numero di dispositivi con Android si aprirebbe una bella sfida all’ultimo download.&lt;/span&gt;</content><link rel='replies' type='application/atom+xml' href='http://bluedreamsandroid.blogspot.com/feeds/5246494015328425065/comments/default' title='Commenti sul post'/><link rel='replies' type='text/html' href='http://bluedreamsandroid.blogspot.com/2011/11/google-music.html#comment-form' title='0 Commenti'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/921091465317807586/posts/default/5246494015328425065'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/921091465317807586/posts/default/5246494015328425065'/><link rel='alternate' type='text/html' href='http://bluedreamsandroid.blogspot.com/2011/11/google-music.html' title='Google Music'/><author><name>BlueDremas</name><uri>http://www.blogger.com/profile/02561736174885737185</uri><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><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-921091465317807586.post-6941798813315326695</id><published>2011-11-10T08:50:00.000-08:00</published><updated>2011-11-14T14:43:14.051-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Android 4"/><category scheme="http://www.blogger.com/atom/ns#" term="Face Unlock"/><title type='text'>Android 4 : Face Unlock</title><content type='html'>&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;L’aggiornamento software &lt;strong&gt;Ice Cream Sandwich 4.0 di Android&lt;/strong&gt; non è ancora stato rilasciato ufficialmente ma si discute già da settimane sui suoi punti di forza e sulle debolezze. Per quanto riguarda i “difetti” della nuova versione della piattaforma, si parla in questi giorni dell&lt;strong&gt;a funzionalità Face Unlock, che consente lo sblocco dello smartphone sfruttando la camera anteriore, attraverso lo “scan” del volto del possessore&lt;/strong&gt;.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;Secondo i primi utilizzatori che stanno sperimentando la piattaforma, &lt;strong&gt;questo nuovo metodo di unlock non è poi così infallibile&lt;/strong&gt;, e a dimostrarlo c’è un&lt;strong&gt; video postato su YouTube&lt;/strong&gt; che mostra con chiarezza i limiti della feature.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;In pratica il Samsung Galaxy Nexus &lt;strong&gt;viene sbloccato non effettuando lo scan del volto, ma semplicemente mostrando alla camera frontale una fotografia del proprietario&lt;/strong&gt; (in questo caso attraverso un altro device, avvicinando il display all’obbiettivo del Galaxy Nexus). Insomma, chi si aspettava metodi da hacker per poter ingannare il Face Unlock resterà sorpreso dell’estrema semplicità con cui, invece, è possibile farlo. &lt;/span&gt;</content><link rel='replies' type='application/atom+xml' href='http://bluedreamsandroid.blogspot.com/feeds/6941798813315326695/comments/default' title='Commenti sul post'/><link rel='replies' type='text/html' href='http://bluedreamsandroid.blogspot.com/2011/11/android-4-face-unlock.html#comment-form' title='0 Commenti'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/921091465317807586/posts/default/6941798813315326695'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/921091465317807586/posts/default/6941798813315326695'/><link rel='alternate' type='text/html' href='http://bluedreamsandroid.blogspot.com/2011/11/android-4-face-unlock.html' title='Android 4 : Face Unlock'/><author><name>BlueDremas</name><uri>http://www.blogger.com/profile/02561736174885737185</uri><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><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-921091465317807586.post-1745077955435412977</id><published>2011-11-09T08:54:00.000-08:00</published><updated>2011-11-14T14:42:01.295-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Aggiornamento"/><category scheme="http://www.blogger.com/atom/ns#" term="Android 4"/><title type='text'>Android 4 : Aggiornamenti</title><content type='html'>&lt;span style=&quot;font-family: Arial;&quot;&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;ASUS con un comunicato ufficiale ha annunciato che aggiornerà la famiglia di prodotti Eee Pad alla nuova release dell’OS. Questo vuol dire che Padfone, &lt;/span&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;Transformer Prime&lt;/span&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt; e Eee Pad Transformer riceveranno l’update. Quando? Come tutti gli altri produttori non ha potuto fornire una data precisa. Anche la famiglia di tablet Motorola passerà ad Android 4: confermati Xoom e gli imminenti &lt;/span&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;Xoom 2 e Xoom 2 Media Edition&lt;/span&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;. I tablet-fonini di Samsung che verranno rinfrescati saranno invece il Galaxy Note e Galaxy Tab.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: Arial;&quot;&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;La lista degli smartphone a cui è stato promesso il &lt;em&gt;sandwich al gelato&lt;/em&gt; è decisamente più ricca. HTC ha confermato che ci sarà del lavoro da fare per bilanciare il nuovo sistema operativo sull’hardware dei vari smartphone, ma per ora conferma un update solo per i suoi Rezound e Vivid. Non si esclude che l’update potrebbe arrivare su altri telefoni. Cattive notizie per i possessori di Nexus One, che non verrà aggiornato.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
LG smentisce i rumors circolati sulla rete e conferma che Android 4 arriverà sia sull’Optimus 2X che su altri telefoni di fascia alta. Date più precise verranno annunciate quando Google rilascerà pubblicamente il nuovo sistema operativo. Anche la cinese Meizu ha pianificato aggiornamenti per i suoi telefoni. Il CEO fa sapere che MX e M9 verranno presto aggiornati.&lt;br /&gt;
&lt;br /&gt;
Al momento non c’è nessuna dichiarazione da Samsung, ma sembra che Galaxy Nexus, Galaxy S II Skyrocket e Nexus S riceveranno l’update. Per quanto riguarda Sony Ericsson, è ormai ufficiale l’aggiornamento per l’Xperia 2011. Notizie positive anche per Motorola: nella lista ci sono Droid RAZR/Motorola RAZR e Droid Bionic. Per quanto riguarda Samsung: ok ufficiale per Galaxy S II e Nexus S.&lt;/span&gt;</content><link rel='replies' type='application/atom+xml' href='http://bluedreamsandroid.blogspot.com/feeds/1745077955435412977/comments/default' title='Commenti sul post'/><link rel='replies' type='text/html' href='http://bluedreamsandroid.blogspot.com/2011/11/android-4-aggiornamenti.html#comment-form' title='0 Commenti'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/921091465317807586/posts/default/1745077955435412977'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/921091465317807586/posts/default/1745077955435412977'/><link rel='alternate' type='text/html' href='http://bluedreamsandroid.blogspot.com/2011/11/android-4-aggiornamenti.html' title='Android 4 : Aggiornamenti'/><author><name>BlueDremas</name><uri>http://www.blogger.com/profile/02561736174885737185</uri><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><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-921091465317807586.post-3170804964372321842</id><published>2011-11-09T06:52:00.000-08:00</published><updated>2011-11-14T14:43:34.693-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Android 4"/><title type='text'>Android 4</title><content type='html'>E&#39; arrivata la nuova versione di Android &quot;&lt;strong&gt;Ice Cream Sandwich&lt;/strong&gt;&quot;. &lt;br /&gt;
&lt;br /&gt;
Novità principali per l&#39;utente finale :&lt;br /&gt;
- evoluta l&#39;interfaccia utente&lt;br /&gt;
- nuove cartelle sulla home&lt;br /&gt;
- widgets ridimensionabili&lt;br /&gt;
- nuovo lock&lt;br /&gt;
- risposte rapide per le chiamate in arrivo&lt;br /&gt;
- migliorato inserimento del testo&lt;br /&gt;
- migliorato il controllo ortografico&lt;br /&gt;
- motore per il riconoscimento vocale&lt;br /&gt;
&lt;br /&gt;
Novità anche per gli sviluppatori :&lt;br /&gt;
- social api&lt;br /&gt;
- calendar api&lt;br /&gt;
- visual voiceman api&lt;br /&gt;
- android beam&lt;br /&gt;
- modular sharing widget</content><link rel='replies' type='application/atom+xml' href='http://bluedreamsandroid.blogspot.com/feeds/3170804964372321842/comments/default' title='Commenti sul post'/><link rel='replies' type='text/html' href='http://bluedreamsandroid.blogspot.com/2011/11/android-4.html#comment-form' title='0 Commenti'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/921091465317807586/posts/default/3170804964372321842'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/921091465317807586/posts/default/3170804964372321842'/><link rel='alternate' type='text/html' href='http://bluedreamsandroid.blogspot.com/2011/11/android-4.html' title='Android 4'/><author><name>BlueDremas</name><uri>http://www.blogger.com/profile/02561736174885737185</uri><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><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-921091465317807586.post-5742429921441058072</id><published>2011-09-30T00:11:00.000-07:00</published><updated>2011-11-16T15:13:54.818-08:00</updated><title type='text'>IPhone vs Galaxy S II vs Bionic vs Titan</title><content type='html'>&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEimV7xgdhqQ8vv6PdeHbsF9ZLNF5VXtQqO8w1lchWalxa_0Q_sB7EIuwV8w-QerKUmZ5lSHh1XeyFBVkoY0PAtpS7m2EmjueATM-zKonv-VwD9iDwaIKvrAwfMdA-Ows6kdQYiqxlqQm8TD/s1600/iPhone4S_vs_top.jpg&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEimV7xgdhqQ8vv6PdeHbsF9ZLNF5VXtQqO8w1lchWalxa_0Q_sB7EIuwV8w-QerKUmZ5lSHh1XeyFBVkoY0PAtpS7m2EmjueATM-zKonv-VwD9iDwaIKvrAwfMdA-Ows6kdQYiqxlqQm8TD/s1600/iPhone4S_vs_top.jpg&quot; /&gt;&lt;/a&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://bluedreamsandroid.blogspot.com/feeds/5742429921441058072/comments/default' title='Commenti sul post'/><link rel='replies' type='text/html' href='http://bluedreamsandroid.blogspot.com/2011/09/iphone-vs-galaxy-s-ii-vs-bionic-vs.html#comment-form' title='0 Commenti'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/921091465317807586/posts/default/5742429921441058072'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/921091465317807586/posts/default/5742429921441058072'/><link rel='alternate' type='text/html' href='http://bluedreamsandroid.blogspot.com/2011/09/iphone-vs-galaxy-s-ii-vs-bionic-vs.html' title='IPhone vs Galaxy S II vs Bionic vs Titan'/><author><name>BlueDremas</name><uri>http://www.blogger.com/profile/02561736174885737185</uri><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/AVvXsEimV7xgdhqQ8vv6PdeHbsF9ZLNF5VXtQqO8w1lchWalxa_0Q_sB7EIuwV8w-QerKUmZ5lSHh1XeyFBVkoY0PAtpS7m2EmjueATM-zKonv-VwD9iDwaIKvrAwfMdA-Ows6kdQYiqxlqQm8TD/s72-c/iPhone4S_vs_top.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-921091465317807586.post-9202373785691767660</id><published>2011-09-13T15:13:00.000-07:00</published><updated>2011-11-14T14:42:27.181-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Android TextView"/><category scheme="http://www.blogger.com/atom/ns#" term="TextView"/><title type='text'>TextView</title><content type='html'>In questo breve tutorial vediamo come &lt;strong&gt;&lt;span style=&quot;color: #222222;&quot;&gt;integrare&lt;/span&gt;&lt;/strong&gt; 
&lt;strong&gt;&lt;span style=&quot;color: #222222;&quot;&gt;immagini&lt;/span&gt;&lt;/strong&gt; e &lt;strong&gt;&lt;span style=&quot;color: #222222;&quot;&gt;testo formattato&lt;/span&gt;&lt;/strong&gt; in 
&lt;strong&gt;&lt;span style=&quot;color: #222222;&quot;&gt;HTML&lt;/span&gt;&lt;/strong&gt; all&#39;interno di una &lt;a href=&quot;http://developer.android.com/reference/android/widget/TextView.html&quot; target=&quot;_blank&quot;&gt;&lt;span style=&quot;color: #2b2bd4;&quot;&gt;TextView&lt;/span&gt;&lt;/a&gt; La piattaforma Android infatti, senza particolari 
difficoltà, ci permette di inserire questa tipologia di contenuto all&#39;interno 
dei diversi controlli grafici. Vediamo nel dettaglio l&#39;implementazione ed il 
meccanismo di integrazione. &lt;br /&gt;
&lt;br /&gt;
&lt;h2&gt;


La classe HTML&lt;/h2&gt;
&lt;br /&gt;
La classe &lt;a href=&quot;http://developer.android.com/reference/android/text/Html.html&quot; target=&quot;_blank&quot;&gt;&lt;span style=&quot;color: #2b2bd4;&quot;&gt;android.text.Html&lt;/span&gt;&lt;/a&gt; ci consente di trasformare una stringa 
formattata in HTML in un particolare oggetto &lt;a href=&quot;http://developer.android.com/reference/android/text/Spanned.html&quot; target=&quot;_blank&quot;&gt;&lt;span style=&quot;color: #2b2bd4;&quot;&gt;Spanned&lt;/span&gt;&lt;/a&gt; che a sua volta viene opportunamente interpretata e 
visualizzata - in questa caso - in una &lt;strong&gt;&lt;span style=&quot;color: #222222;&quot;&gt;TextView&lt;/span&gt;&lt;/strong&gt; tramite il 
metodo &lt;em&gt;setText()&lt;/em&gt;. Questa classe implementa i seguenti metodi statici: 
&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;&lt;em&gt;Html.fromHtml(String source)&lt;/em&gt;: trasforma una stringa formattata in 
HTML in un oggetto di tipo &lt;strong&gt;&lt;span style=&quot;color: #222222;&quot;&gt;Spanned&lt;/span&gt;&lt;/strong&gt; 
&lt;/li&gt;
&lt;li&gt;&lt;em&gt;Html.fromHtml(String source, ImageGetter imageGetter, TagHandler 
handler)&lt;/em&gt;: la medesima funzione, solo che nel caso del tag 
&lt;strong&gt;&lt;span style=&quot;color: #222222;&quot;&gt;&amp;lt;img&amp;gt;&lt;/span&gt;&lt;/strong&gt; richiama un&#39;implementazione dell&#39;interfaccia 
ImageGetter (vedremo di cosa si tratta). Mentre per l&#39;altro argomento quando il 
parser incontra un tag che non riesce ad interpretare invoca il metodo 
dell&#39;interfaccia &lt;a href=&quot;http://developer.android.com/reference/android/text/Html.TagHandler.html&quot; target=&quot;_blank&quot;&gt;&lt;span style=&quot;color: #2b2bd4;&quot;&gt;TagHandler&lt;/span&gt;&lt;/a&gt; 
&lt;/li&gt;
&lt;li&gt;&lt;em&gt;Html.toHtml(Spanned spanned)&lt;/em&gt;: questo metodo invece effettua 
l&#39;inverso, cioè da un oggetto Spanned ne ritorna una rappresentazione HTML in 
formato stringa &lt;/li&gt;
&lt;/ul&gt;
Vediamo qualche esempio di implementazione. Partiamo 
con qualcosa di semplice, un testo HTML che contiene grassetto, corsivo e 
sottolineato: &lt;br /&gt;
&lt;pre&gt;&lt;span class=&quot;kwd&quot;&gt;&lt;span style=&quot;color: #000088;&quot;&gt;import&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; android&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;.&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;.&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;typ&quot;&gt;&lt;span style=&quot;color: #660066;&quot;&gt;Html&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;&lt;span style=&quot;color: #000088;&quot;&gt;import&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; android&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;.&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;.&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;typ&quot;&gt;&lt;span style=&quot;color: #660066;&quot;&gt;Spanned&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;...&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;typ&quot;&gt;&lt;span style=&quot;color: #660066;&quot;&gt;TextView&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; textView &lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;....&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;typ&quot;&gt;&lt;span style=&quot;color: #660066;&quot;&gt;String&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; source &lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;=&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;str&quot;&gt;&lt;span style=&quot;color: #008800;&quot;&gt;&quot;Esempio &amp;lt;b&amp;gt;grassetto&amp;lt;/b&amp;gt;, &amp;lt;i&amp;gt;corsivo&amp;lt;/i&amp;gt;, &amp;lt;u&amp;gt;sottolineato&amp;lt;/u&amp;gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;typ&quot;&gt;&lt;span style=&quot;color: #660066;&quot;&gt;Spanned&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; text &lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;=&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;typ&quot;&gt;&lt;span style=&quot;color: #660066;&quot;&gt;Html&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;.&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;fromHtml&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;source&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
textView&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;.&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;setText&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;
Non 
tutti i tag HTML sono supportati, ma diciamo quelli più semplici ma 
fondamentali. Ad esempio è possibile combinare diversi colori in un testo 
utilizzando il tag &lt;strong&gt;&lt;span style=&quot;color: #222222;&quot;&gt;font&lt;/span&gt;&lt;/strong&gt; combinato con l&#39;attributo 
&lt;em&gt;color&lt;/em&gt;: &lt;br /&gt;
&lt;pre&gt;&lt;span class=&quot;kwd&quot;&gt;&lt;span style=&quot;color: #000088;&quot;&gt;import&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; android&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;.&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;.&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;typ&quot;&gt;&lt;span style=&quot;color: #660066;&quot;&gt;Html&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;&lt;span style=&quot;color: #000088;&quot;&gt;import&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; android&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;.&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;.&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;typ&quot;&gt;&lt;span style=&quot;color: #660066;&quot;&gt;Spanned&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;....&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;typ&quot;&gt;&lt;span style=&quot;color: #660066;&quot;&gt;TextView&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; viewTextColor &lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;....&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;typ&quot;&gt;&lt;span style=&quot;color: #660066;&quot;&gt;String&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; textColorRed &lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;=&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;str&quot;&gt;&lt;span style=&quot;color: #008800;&quot;&gt;&quot;&amp;lt;font color=&#39;#FF0000&#39;&amp;gt;&amp;lt;b&amp;gt;Red&amp;lt;/b&amp;gt;&amp;lt;/font&amp;gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;typ&quot;&gt;&lt;span style=&quot;color: #660066;&quot;&gt;String&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; textColorGreen &lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;=&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;str&quot;&gt;&lt;span style=&quot;color: #008800;&quot;&gt;&quot;&amp;lt;font color=&#39;#00FF00&#39;&amp;gt;&amp;lt;b&amp;gt;Green&amp;lt;/b&amp;gt;&amp;lt;/font&amp;gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;typ&quot;&gt;&lt;span style=&quot;color: #660066;&quot;&gt;String&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; textColorBlue &lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;=&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;str&quot;&gt;&lt;span style=&quot;color: #008800;&quot;&gt;&quot;&amp;lt;font color=&#39;#0000FF&#39;&amp;gt;&amp;lt;b&amp;gt;Blue&amp;lt;/b&amp;gt;&amp;lt;/font&amp;gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;typ&quot;&gt;&lt;span style=&quot;color: #660066;&quot;&gt;Spanned&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; textColor &lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;=&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;typ&quot;&gt;&lt;span style=&quot;color: #660066;&quot;&gt;Html&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;.&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;fromHtml&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;textColorRed&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;+&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;str&quot;&gt;&lt;span style=&quot;color: #008800;&quot;&gt;&quot;,&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;+&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;textColorGreen&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;+&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;str&quot;&gt;&lt;span style=&quot;color: #008800;&quot;&gt;&quot;,&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;+&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;textColorBlue&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
viewTextColor&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;.&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;setText&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;textColor&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;
Ho inserito anche il grassetto per dare più risalto al testo. &lt;br /&gt;
&lt;br /&gt;
E&#39; evidente che questo meccanismo semplifica molto le cose. Infatti in altri 
contesti GUI ciò può diventare un&#39;operazione abbastanza complessa. &lt;br /&gt;
&lt;br /&gt;
&lt;h2&gt;


Gestire il tag img&lt;/h2&gt;
&lt;br /&gt;
Altra funzionalità molto interessante è riuscire ad integrare anche le 
immagini insieme al testo, cosa che non è possibile effettuare con le modalità 
che abbiamo visto negli esempi sopra, in quanto il tag &lt;em&gt;&amp;lt;img&amp;gt;&lt;/em&gt; 
viene completamente ignorato dal parser. Quindi per visualizzare anche le 
immagini bisogna utilizzare l&#39;interfaccia &lt;a href=&quot;http://developer.android.com/reference/android/text/Html.ImageGetter.html&quot; target=&quot;_blank&quot;&gt;&lt;span style=&quot;color: #2b2bd4;&quot;&gt;ImageGetter&lt;/span&gt;&lt;/a&gt; che contiene questo metodo: &lt;br /&gt;
&lt;pre&gt;&lt;span class=&quot;kwd&quot;&gt;&lt;span style=&quot;color: #000088;&quot;&gt;abstract&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;typ&quot;&gt;&lt;span style=&quot;color: #660066;&quot;&gt;Drawable&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; getDrawable&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;typ&quot;&gt;&lt;span style=&quot;color: #660066;&quot;&gt;String&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; source&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;
Questo 
metodo viene invocato quando il parser incontra un tag HTML 
&lt;em&gt;&amp;lt;img&amp;gt;&lt;/em&gt;. L&#39;argomento &lt;strong&gt;&lt;span style=&quot;color: #222222;&quot;&gt;source&lt;/span&gt;&lt;/strong&gt; è la stringa 
dell&#39;attributo &lt;em&gt;src&lt;/em&gt; del tag &lt;strong&gt;&lt;span style=&quot;color: #222222;&quot;&gt;img&lt;/span&gt;&lt;/strong&gt;, il valore di ritorno 
dovrebbe essere una rappresentazione &lt;a href=&quot;http://developer.android.com/reference/android/graphics/drawable/Drawable.html&quot; target=&quot;_blank&quot;&gt;&lt;span style=&quot;color: #2b2bd4;&quot;&gt;Drawable&lt;/span&gt;&lt;/a&gt; dell&#39;immagine oppure &lt;strong&gt;&lt;span style=&quot;color: #222222;&quot;&gt;null&lt;/span&gt;&lt;/strong&gt; per una 
immagine di sostituzione generica. 
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Quindi bisogna distinguere diversi casi per quanto riguarda la locazione 
delle immagini che intendiamo visualizzare. Infatti se le immagini si trovano su 
un server web bisogna scaricare l&#39;immagine dal server e trasformarla in un 
oggetto &lt;strong&gt;&lt;span style=&quot;color: #222222;&quot;&gt;Drawable&lt;/span&gt;&lt;/strong&gt;. In questo caso la stringa 
&lt;strong&gt;&lt;span style=&quot;color: #222222;&quot;&gt;source&lt;/span&gt;&lt;/strong&gt; rappresenta una risorsa http. Vediamo un&#39;implementazione 
per scaricare un&#39;immagine residente su un server web: &lt;br /&gt;
&lt;pre&gt;&lt;span class=&quot;kwd&quot;&gt;&lt;span style=&quot;color: #000088;&quot;&gt;class&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;typ&quot;&gt;&lt;span style=&quot;color: #660066;&quot;&gt;HttpImageGetter&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;&lt;span style=&quot;color: #000088;&quot;&gt;implements&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;typ&quot;&gt;&lt;span style=&quot;color: #660066;&quot;&gt;ImageGetter&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;{&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;

  &lt;/span&gt;&lt;span class=&quot;lit&quot;&gt;&lt;span style=&quot;color: #006666;&quot;&gt;@Override&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;&lt;span style=&quot;color: #000088;&quot;&gt;public&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;typ&quot;&gt;&lt;span style=&quot;color: #660066;&quot;&gt;Drawable&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; getDrawable&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;typ&quot;&gt;&lt;span style=&quot;color: #660066;&quot;&gt;String&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; source&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;{&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;&lt;span style=&quot;color: #000088;&quot;&gt;try&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;{&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
      URL url &lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;=&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;&lt;span style=&quot;color: #000088;&quot;&gt;new&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; URL&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;source&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
      &lt;/span&gt;&lt;span class=&quot;typ&quot;&gt;&lt;span style=&quot;color: #660066;&quot;&gt;HttpURLConnection&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; conn &lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;=&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;typ&quot;&gt;&lt;span style=&quot;color: #660066;&quot;&gt;HttpURLConnection&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;url&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;.&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;openConnection&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;();&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
      conn&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;.&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;setDoInput&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;&lt;span style=&quot;color: #000088;&quot;&gt;true&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
      conn&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;.&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;connect&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;();&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
      &lt;/span&gt;&lt;span class=&quot;typ&quot;&gt;&lt;span style=&quot;color: #660066;&quot;&gt;InputStream&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;&lt;span style=&quot;color: #000088;&quot;&gt;is&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;=&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; conn&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;.&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;getInputStream&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;();&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
      &lt;/span&gt;&lt;span class=&quot;typ&quot;&gt;&lt;span style=&quot;color: #660066;&quot;&gt;BitmapDrawable&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; dr &lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;=&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;&lt;span style=&quot;color: #000088;&quot;&gt;new&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;typ&quot;&gt;&lt;span style=&quot;color: #660066;&quot;&gt;BitmapDrawable&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;typ&quot;&gt;&lt;span style=&quot;color: #660066;&quot;&gt;BitmapFactory&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;.&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;decodeStream&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;&lt;span style=&quot;color: #000088;&quot;&gt;is&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;));&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
      dr&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;.&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;setBounds&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;lit&quot;&gt;&lt;span style=&quot;color: #006666;&quot;&gt;0&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;lit&quot;&gt;&lt;span style=&quot;color: #006666;&quot;&gt;0&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; dr&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;.&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;getIntrinsicWidth&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;(),&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; dr&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;.&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;getIntrinsicHeight&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;());&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
      &lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;&lt;span style=&quot;color: #000088;&quot;&gt;return&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; dr&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
   &lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;&lt;span style=&quot;color: #000088;&quot;&gt;catch&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;typ&quot;&gt;&lt;span style=&quot;color: #660066;&quot;&gt;IOException&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; e&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;{&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
    e&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;.&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;printStackTrace&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;();&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;&lt;span style=&quot;color: #000088;&quot;&gt;return&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;&lt;span style=&quot;color: #000088;&quot;&gt;null&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;
In 
poche parole abbiamo utilizzato &lt;a href=&quot;http://www.simplesoft.it/connessioni-http-in-java.html&quot;&gt;&lt;span style=&quot;color: #2b2bd4;&quot;&gt;la connessione 
Http&lt;/span&gt;&lt;/a&gt; definita nel package &lt;em&gt;java.net&lt;/em&gt; combinata con il 
&lt;strong&gt;&lt;span style=&quot;color: #222222;&quot;&gt;BitmapFactory&lt;/span&gt;&lt;/strong&gt; (per creare l&#39;oggetto Drawable) che contiene 
diversi metodi che trasformano array di byte in oggetti Bitmap oppure in 
BitmapDrawable nel nostro caso. L&#39;operazione &lt;em&gt;setBounds()&lt;/em&gt; sull&#39;oggetto 
Drawable serve per specificare la dimensione dell&#39;immagine altrimenti 
risulterebbe nulla e l&#39;immagine non verrebbe visualizzata. Mettiamo il caso che 
siamo all&#39;interno di un&#39;Activity, facciamo un esempio che utilizza questo 
meccanismo: &lt;br /&gt;
&lt;pre&gt;&lt;span class=&quot;typ&quot;&gt;&lt;span style=&quot;color: #660066;&quot;&gt;TextView&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; imgTextView &lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;=&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;....&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;typ&quot;&gt;&lt;span style=&quot;color: #660066;&quot;&gt;String&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; source &lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;=&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;str&quot;&gt;&lt;span style=&quot;color: #008800;&quot;&gt;&quot;&amp;lt;img src=&#39;http://www.example.com/image.png&#39; /&amp;gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
imgTextView&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;.&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;setText&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;typ&quot;&gt;&lt;span style=&quot;color: #660066;&quot;&gt;Html&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;.&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;fromHtml&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;source&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;&lt;span style=&quot;color: #000088;&quot;&gt;new&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;typ&quot;&gt;&lt;span style=&quot;color: #660066;&quot;&gt;HttpImageGetter&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;(),&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;&lt;span style=&quot;color: #000088;&quot;&gt;null&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Adesso invece vediamo di implementare un meccanismo per reperire le immagini 
che si trovano in locale. Quindi possono essere o nelle risorse oppure nella 
sdcard. Se ad esempio abbiamo delle immagini che sono posizionate nelle risorse, 
cioè nella cartella &lt;em&gt;drawable-xxxx/&lt;/em&gt; del nostro progetto allora bisogna 
semplicemnte utilizzare questa implementazione: &lt;br /&gt;
&lt;pre&gt;&lt;span class=&quot;kwd&quot;&gt;&lt;span style=&quot;color: #000088;&quot;&gt;private&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;&lt;span style=&quot;color: #000088;&quot;&gt;class&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;typ&quot;&gt;&lt;span style=&quot;color: #660066;&quot;&gt;LocaImageGetter&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;&lt;span style=&quot;color: #000088;&quot;&gt;implements&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;typ&quot;&gt;&lt;span style=&quot;color: #660066;&quot;&gt;Html&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;.&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;typ&quot;&gt;&lt;span style=&quot;color: #660066;&quot;&gt;ImageGetter&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;{&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;

  &lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;&lt;span style=&quot;color: #000088;&quot;&gt;private&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;typ&quot;&gt;&lt;span style=&quot;color: #660066;&quot;&gt;Context&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; context&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;

  &lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;&lt;span style=&quot;color: #000088;&quot;&gt;public&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;typ&quot;&gt;&lt;span style=&quot;color: #660066;&quot;&gt;ImageGetterSmile&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;typ&quot;&gt;&lt;span style=&quot;color: #660066;&quot;&gt;Context&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; context&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;{&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;&lt;span style=&quot;color: #000088;&quot;&gt;this&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;.&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;context &lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;=&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; context&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;

  &lt;/span&gt;&lt;span class=&quot;lit&quot;&gt;&lt;span style=&quot;color: #006666;&quot;&gt;@Override&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;&lt;span style=&quot;color: #000088;&quot;&gt;public&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;typ&quot;&gt;&lt;span style=&quot;color: #660066;&quot;&gt;Drawable&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; getDrawable&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;typ&quot;&gt;&lt;span style=&quot;color: #660066;&quot;&gt;String&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; source&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;{&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;typ&quot;&gt;&lt;span style=&quot;color: #660066;&quot;&gt;Drawable&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; d &lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;=&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;&lt;span style=&quot;color: #000088;&quot;&gt;null&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;&lt;span style=&quot;color: #000088;&quot;&gt;int&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; resID &lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;=&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; context&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;.&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;getResources&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;().&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;getIdentifier&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;source&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
      &lt;/span&gt;&lt;span class=&quot;str&quot;&gt;&lt;span style=&quot;color: #008800;&quot;&gt;&quot;drawable&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; context&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;.&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;getPackageName&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;());&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
    d &lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;=&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; context&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;.&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;getApplicationContext&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;().&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;getResources&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;().&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;getDrawable&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
    resID&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
    d&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;.&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;setBounds&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;lit&quot;&gt;&lt;span style=&quot;color: #006666;&quot;&gt;0&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;lit&quot;&gt;&lt;span style=&quot;color: #006666;&quot;&gt;0&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; d&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;.&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;getIntrinsicWidth&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;(),&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; d&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;.&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;getIntrinsicHeight&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;());&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;&lt;span style=&quot;color: #000088;&quot;&gt;return&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; d&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;
La 
stringa &lt;strong&gt;&lt;span style=&quot;color: #222222;&quot;&gt;source&lt;/span&gt;&lt;/strong&gt; deve contenere il nome della risorsa. Se ad 
esempio nelle cartelle &lt;em&gt;drawable-xxxx/&lt;/em&gt; abbiamo un&#39;immagine 
&lt;strong&gt;&lt;span style=&quot;color: #222222;&quot;&gt;logo.png&lt;/span&gt;&lt;/strong&gt; e vogliamo visualizzarla in codice HTML dobbiamo 
procedere in questo modo: &lt;br /&gt;
&lt;pre&gt;&lt;span class=&quot;typ&quot;&gt;&lt;span style=&quot;color: #660066;&quot;&gt;TextView&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; textView&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;...&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;typ&quot;&gt;&lt;span style=&quot;color: #660066;&quot;&gt;String&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; sourceHtml &lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;=&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;str&quot;&gt;&lt;span style=&quot;color: #008800;&quot;&gt;&quot;&amp;lt;img src=&#39;logo&#39; /&amp;gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;typ&quot;&gt;&lt;span style=&quot;color: #660066;&quot;&gt;Spanned&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; spanned &lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;=&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;typ&quot;&gt;&lt;span style=&quot;color: #660066;&quot;&gt;Html&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;.&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;fromHtml&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;sourceHtml&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;&lt;span style=&quot;color: #000088;&quot;&gt;new&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;typ&quot;&gt;&lt;span style=&quot;color: #660066;&quot;&gt;LocalImageGetter&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;&lt;span style=&quot;color: #000088;&quot;&gt;this&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;),&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;&lt;span style=&quot;color: #000088;&quot;&gt;null&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
textView&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;.&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;setText&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;spanned&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;h2&gt;


Applicazione di esempio con le emoticons&lt;/h2&gt;
&lt;br /&gt;
Come esempio propongo di realizzare una semplice applicazione che visualizza 
in una &lt;strong&gt;&lt;span style=&quot;color: #222222;&quot;&gt;TextView&lt;/span&gt;&lt;/strong&gt; un testo inserito da noi in una 
&lt;strong&gt;&lt;span style=&quot;color: #222222;&quot;&gt;EditText&lt;/span&gt;&lt;/strong&gt; trasformando le stringhe &#39;:-) :-( :-D&#39; etc.. in 
immagini. Ecco il codice dell&#39;Activity: &lt;br /&gt;
&lt;pre&gt;&lt;span class=&quot;kwd&quot;&gt;&lt;span style=&quot;color: #000088;&quot;&gt;import&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; android&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;.&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;app&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;.&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;typ&quot;&gt;&lt;span style=&quot;color: #660066;&quot;&gt;Activity&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;&lt;span style=&quot;color: #000088;&quot;&gt;import&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; android&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;.&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;graphics&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;.&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;drawable&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;.&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;typ&quot;&gt;&lt;span style=&quot;color: #660066;&quot;&gt;Drawable&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;&lt;span style=&quot;color: #000088;&quot;&gt;import&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; android&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;.&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;os&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;.&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;typ&quot;&gt;&lt;span style=&quot;color: #660066;&quot;&gt;Bundle&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;&lt;span style=&quot;color: #000088;&quot;&gt;import&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; android&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;.&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;.&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;typ&quot;&gt;&lt;span style=&quot;color: #660066;&quot;&gt;Html&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;&lt;span style=&quot;color: #000088;&quot;&gt;import&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; android&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;.&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;.&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;typ&quot;&gt;&lt;span style=&quot;color: #660066;&quot;&gt;Spanned&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;&lt;span style=&quot;color: #000088;&quot;&gt;import&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; android&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;.&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;.&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;typ&quot;&gt;&lt;span style=&quot;color: #660066;&quot;&gt;Html&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;.&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;typ&quot;&gt;&lt;span style=&quot;color: #660066;&quot;&gt;ImageGetter&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;&lt;span style=&quot;color: #000088;&quot;&gt;import&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; android&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;.&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;view&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;.&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;typ&quot;&gt;&lt;span style=&quot;color: #660066;&quot;&gt;View&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;&lt;span style=&quot;color: #000088;&quot;&gt;import&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; android&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;.&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;view&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;.&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;typ&quot;&gt;&lt;span style=&quot;color: #660066;&quot;&gt;View&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;.&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;typ&quot;&gt;&lt;span style=&quot;color: #660066;&quot;&gt;OnClickListener&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;&lt;span style=&quot;color: #000088;&quot;&gt;import&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; android&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;.&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;widget&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;.&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;typ&quot;&gt;&lt;span style=&quot;color: #660066;&quot;&gt;Button&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;&lt;span style=&quot;color: #000088;&quot;&gt;import&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; android&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;.&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;widget&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;.&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;typ&quot;&gt;&lt;span style=&quot;color: #660066;&quot;&gt;EditText&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;&lt;span style=&quot;color: #000088;&quot;&gt;import&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; android&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;.&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;widget&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;.&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;typ&quot;&gt;&lt;span style=&quot;color: #660066;&quot;&gt;TableLayout&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;&lt;span style=&quot;color: #000088;&quot;&gt;import&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; android&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;.&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;widget&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;.&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;typ&quot;&gt;&lt;span style=&quot;color: #660066;&quot;&gt;TextView&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;&lt;span style=&quot;color: #000088;&quot;&gt;public&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;&lt;span style=&quot;color: #000088;&quot;&gt;class&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;typ&quot;&gt;&lt;span style=&quot;color: #660066;&quot;&gt;ActivityEmoticons&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;&lt;span style=&quot;color: #000088;&quot;&gt;extends&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;typ&quot;&gt;&lt;span style=&quot;color: #660066;&quot;&gt;Activity&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;&lt;span style=&quot;color: #000088;&quot;&gt;implements&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;typ&quot;&gt;&lt;span style=&quot;color: #660066;&quot;&gt;OnClickListener&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;typ&quot;&gt;&lt;span style=&quot;color: #660066;&quot;&gt;ImageGetter&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;{&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;

  &lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;&lt;span style=&quot;color: #000088;&quot;&gt;private&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;typ&quot;&gt;&lt;span style=&quot;color: #660066;&quot;&gt;EditText&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; editText&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;&lt;span style=&quot;color: #000088;&quot;&gt;private&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;typ&quot;&gt;&lt;span style=&quot;color: #660066;&quot;&gt;TextView&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; textView&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;


  &lt;/span&gt;&lt;span class=&quot;lit&quot;&gt;&lt;span style=&quot;color: #006666;&quot;&gt;@Override&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;&lt;span style=&quot;color: #000088;&quot;&gt;public&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;&lt;span style=&quot;color: #000088;&quot;&gt;void&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; onCreate&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;typ&quot;&gt;&lt;span style=&quot;color: #660066;&quot;&gt;Bundle&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; savedInstanceState&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;{&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;&lt;span style=&quot;color: #000088;&quot;&gt;super&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;.&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;onCreate&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;savedInstanceState&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;typ&quot;&gt;&lt;span style=&quot;color: #660066;&quot;&gt;TableLayout&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; layout &lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;=&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;&lt;span style=&quot;color: #000088;&quot;&gt;new&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;typ&quot;&gt;&lt;span style=&quot;color: #660066;&quot;&gt;TableLayout&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;&lt;span style=&quot;color: #000088;&quot;&gt;this&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
    layout&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;.&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;setPadding&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;lit&quot;&gt;&lt;span style=&quot;color: #006666;&quot;&gt;5&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;lit&quot;&gt;&lt;span style=&quot;color: #006666;&quot;&gt;5&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;lit&quot;&gt;&lt;span style=&quot;color: #006666;&quot;&gt;5&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;lit&quot;&gt;&lt;span style=&quot;color: #006666;&quot;&gt;5&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;&lt;span style=&quot;color: #000088;&quot;&gt;super&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;.&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;setContentView&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;layout&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
    editText &lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;=&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;&lt;span style=&quot;color: #000088;&quot;&gt;new&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;typ&quot;&gt;&lt;span style=&quot;color: #660066;&quot;&gt;EditText&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;&lt;span style=&quot;color: #000088;&quot;&gt;this&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
    textView &lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;=&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;&lt;span style=&quot;color: #000088;&quot;&gt;new&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;typ&quot;&gt;&lt;span style=&quot;color: #660066;&quot;&gt;TextView&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;&lt;span style=&quot;color: #000088;&quot;&gt;this&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;typ&quot;&gt;&lt;span style=&quot;color: #660066;&quot;&gt;Button&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; convertButton &lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;=&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;&lt;span style=&quot;color: #000088;&quot;&gt;new&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;typ&quot;&gt;&lt;span style=&quot;color: #660066;&quot;&gt;Button&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;&lt;span style=&quot;color: #000088;&quot;&gt;this&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
    convertButton&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;.&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;setText&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;str&quot;&gt;&lt;span style=&quot;color: #008800;&quot;&gt;&quot;Converti&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
    convertButton&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;.&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;setOnClickListener&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;&lt;span style=&quot;color: #000088;&quot;&gt;this&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
    layout&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;.&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;addView&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;editText&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
    layout&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;.&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;addView&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;convertButton&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
    layout&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;.&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;addView&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;textView&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;

  &lt;/span&gt;&lt;span class=&quot;lit&quot;&gt;&lt;span style=&quot;color: #006666;&quot;&gt;@Override&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;&lt;span style=&quot;color: #000088;&quot;&gt;public&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;typ&quot;&gt;&lt;span style=&quot;color: #660066;&quot;&gt;Drawable&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; getDrawable&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;typ&quot;&gt;&lt;span style=&quot;color: #660066;&quot;&gt;String&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; source&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;{&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;typ&quot;&gt;&lt;span style=&quot;color: #660066;&quot;&gt;Drawable&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; d &lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;=&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;&lt;span style=&quot;color: #000088;&quot;&gt;null&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;&lt;span style=&quot;color: #000088;&quot;&gt;int&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; resID &lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;=&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;&lt;span style=&quot;color: #000088;&quot;&gt;this&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;.&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;getResources&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;().&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;getIdentifier&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;source&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
      &lt;/span&gt;&lt;span class=&quot;str&quot;&gt;&lt;span style=&quot;color: #008800;&quot;&gt;&quot;drawable&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;&lt;span style=&quot;color: #000088;&quot;&gt;this&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;.&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;getPackageName&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;());&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
    d &lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;=&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;&lt;span style=&quot;color: #000088;&quot;&gt;this&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;.&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;getApplicationContext&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;().&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;getResources&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;().&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;getDrawable&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;resID&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
    d&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;.&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;setBounds&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;lit&quot;&gt;&lt;span style=&quot;color: #006666;&quot;&gt;0&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;lit&quot;&gt;&lt;span style=&quot;color: #006666;&quot;&gt;0&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; d&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;.&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;getIntrinsicWidth&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;(),&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; d&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;.&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;getIntrinsicHeight&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;());&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;&lt;span style=&quot;color: #000088;&quot;&gt;return&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; d&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;

  &lt;/span&gt;&lt;span class=&quot;lit&quot;&gt;&lt;span style=&quot;color: #006666;&quot;&gt;@Override&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;&lt;span style=&quot;color: #000088;&quot;&gt;public&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;&lt;span style=&quot;color: #000088;&quot;&gt;void&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; onClick&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;typ&quot;&gt;&lt;span style=&quot;color: #660066;&quot;&gt;View&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; arg0&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;{&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;typ&quot;&gt;&lt;span style=&quot;color: #660066;&quot;&gt;String&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; source &lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;=&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; replaceEmoticons&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;editText&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;.&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;getText&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;().&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;toString&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;());&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;typ&quot;&gt;&lt;span style=&quot;color: #660066;&quot;&gt;Spanned&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; spanned &lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;=&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;typ&quot;&gt;&lt;span style=&quot;color: #660066;&quot;&gt;Html&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;.&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;fromHtml&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;source&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;&lt;span style=&quot;color: #000088;&quot;&gt;this&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;&lt;span style=&quot;color: #000088;&quot;&gt;null&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
    textView&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;.&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;setText&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;spanned&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;

  &lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;&lt;span style=&quot;color: #000088;&quot;&gt;protected&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;typ&quot;&gt;&lt;span style=&quot;color: #660066;&quot;&gt;String&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; replaceEmoticons&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;typ&quot;&gt;&lt;span style=&quot;color: #660066;&quot;&gt;String&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; source&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;{&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
    source &lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;=&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; source&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;.&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;replace&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;str&quot;&gt;&lt;span style=&quot;color: #008800;&quot;&gt;&quot;:-)&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;str&quot;&gt;&lt;span style=&quot;color: #008800;&quot;&gt;&quot;&amp;lt;img src=&#39;happy&#39; /&amp;gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
    source &lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;=&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; source&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;.&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;replace&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;str&quot;&gt;&lt;span style=&quot;color: #008800;&quot;&gt;&quot;:-(&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;str&quot;&gt;&lt;span style=&quot;color: #008800;&quot;&gt;&quot;&amp;lt;img src=&#39;sad&#39; /&amp;gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
    source &lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;=&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; source&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;.&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;replace&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;str&quot;&gt;&lt;span style=&quot;color: #008800;&quot;&gt;&quot;:-O&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;str&quot;&gt;&lt;span style=&quot;color: #008800;&quot;&gt;&quot;&amp;lt;img src=&#39;surprised&#39; /&amp;gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
    source &lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;=&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; source&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;.&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;replace&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;str&quot;&gt;&lt;span style=&quot;color: #008800;&quot;&gt;&quot;:-D&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;str&quot;&gt;&lt;span style=&quot;color: #008800;&quot;&gt;&quot;&amp;lt;img src=&#39;laughing&#39; /&amp;gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
    source &lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;=&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; source&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;.&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;replace&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;str&quot;&gt;&lt;span style=&quot;color: #008800;&quot;&gt;&quot;;-)&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;,&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;str&quot;&gt;&lt;span style=&quot;color: #008800;&quot;&gt;&quot;&amp;lt;img src=&#39;winking&#39; /&amp;gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;kwd&quot;&gt;&lt;span style=&quot;color: #000088;&quot;&gt;return&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; source&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;
Il 
codice è abbastanza chiaro, abbiamo utilizzato il meccanismo per reperire le 
immagini in locale. Mentre il metodo &lt;em&gt;replaceEmoticons()&lt;/em&gt; sostiutisce 
alle smile in formato stringa il tag img che punta (attributo src) al nome delle 
immagini che si trovano nella cartella drawable/ del progetto.</content><link rel='replies' type='application/atom+xml' href='http://bluedreamsandroid.blogspot.com/feeds/9202373785691767660/comments/default' title='Commenti sul post'/><link rel='replies' type='text/html' href='http://bluedreamsandroid.blogspot.com/2011/11/textview.html#comment-form' title='0 Commenti'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/921091465317807586/posts/default/9202373785691767660'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/921091465317807586/posts/default/9202373785691767660'/><link rel='alternate' type='text/html' href='http://bluedreamsandroid.blogspot.com/2011/11/textview.html' title='TextView'/><author><name>BlueDremas</name><uri>http://www.blogger.com/profile/02561736174885737185</uri><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><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-921091465317807586.post-1693923215692633766</id><published>2011-08-10T05:17:00.000-07:00</published><updated>2011-11-18T05:20:54.279-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="News"/><title type='text'>Google Maps 5.7</title><content type='html'>&lt;span style=&quot;color: black; font-size: 100%;&quot;&gt;E&#39; uscita&amp;nbsp;&lt;a href=&quot;https://market.android.com/details?id=com.google.android.apps.maps&amp;amp;hl=en&quot;&gt;Google 
Maps 5.7 per Android&lt;/a&gt;&amp;nbsp;con&amp;nbsp; l’integrazione di Transit 
Navigation in versione beta, migliori suggerimenti per i risultati di ricerca e 
un aggiornamento della funzione per ottenere indicazioni stradali, utile quando 
ci si trova in zone sconosciute della città o in località del tutto 
nuove.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Transit Navigation (Beta)&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;Oggi Google Maps 
Navigatore (Beta) permette di ricevere indicazioni stradali tramite GPS, a piedi 
o in auto, tali da percorrere oltre 19 miliardi di chilometri di strade. Da 
oggi, questa navigazione satellitare GPS diventa ancora più utile, offrendo 
indicazioni relative al trasporto pubblico in oltre &lt;a href=&quot;http://www.google.it/intl/it/landing/transit/text.html#_blank&quot;&gt;400 città 
del mondo&lt;/a&gt; (comprese alcune città italiane).&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: black; font-size: 100%;&quot;&gt;L&#39;articolo completo e&#39; al seguente &lt;a href=&quot;http://googleitalia.blogspot.com/2011/07/con-google-maps-57-per-android-arriva.html&quot;&gt;link&lt;/a&gt;.&lt;span class=&quot;byline-author&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://bluedreamsandroid.blogspot.com/feeds/1693923215692633766/comments/default' title='Commenti sul post'/><link rel='replies' type='text/html' href='http://bluedreamsandroid.blogspot.com/2011/08/google-maps-57.html#comment-form' title='0 Commenti'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/921091465317807586/posts/default/1693923215692633766'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/921091465317807586/posts/default/1693923215692633766'/><link rel='alternate' type='text/html' href='http://bluedreamsandroid.blogspot.com/2011/08/google-maps-57.html' title='Google Maps 5.7'/><author><name>BlueDremas</name><uri>http://www.blogger.com/profile/02561736174885737185</uri><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><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-921091465317807586.post-781302615898981932</id><published>2011-07-13T04:52:00.000-07:00</published><updated>2011-11-22T04:53:39.699-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Codice"/><category scheme="http://www.blogger.com/atom/ns#" term="esempio"/><title type='text'>Menu con le ViewStub</title><content type='html'>Prima di tutto creiamo un nuovo progetto con Eclipse.&lt;br /&gt;
Il Manifest non subirà cambiamenti particolari quindi tralasciamo la sua visualizzazione e analizziamo invece il layout dell’Activity principale.&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;Sorgenti:&lt;/strong&gt;&lt;br /&gt;
stubs.xml&lt;br /&gt;
&lt;div class=&quot;codeheader&quot;&gt;
Codice (XML): &lt;a class=&quot;codeoperation&quot; href=&quot;javascript:void(0);&quot;&gt;&lt;span style=&quot;color: #334466;&quot;&gt;[Seleziona]&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;
&lt;code class=&quot;bbc_code&quot;&gt;&lt;span style=&quot;color: #1a1a1a;&quot;&gt;&lt;span style=&quot;color: #3f7f7f; font-weight: bold;&quot;&gt;&amp;lt;?xml&lt;/span&gt; &lt;span style=&quot;color: #7f007f;&quot;&gt;version&lt;/span&gt;=&lt;span style=&quot;color: #2a00ff;&quot;&gt;&quot;1.0&quot;&lt;/span&gt; &lt;span style=&quot;color: #7f007f;&quot;&gt;encoding&lt;/span&gt;=&lt;span style=&quot;color: #2a00ff;&quot;&gt;&quot;utf-8&quot;&lt;/span&gt;&lt;span style=&quot;color: #3f7f7f; font-weight: bold;&quot;&gt;?&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #1a1a1a;&quot;&gt;&lt;span style=&quot;color: #3f7f7f; font-weight: bold;&quot;&gt;&amp;lt;merge&lt;/span&gt; &lt;span style=&quot;color: #7f007f;&quot;&gt;xmlns:android&lt;/span&gt;=&lt;span style=&quot;color: #2a00ff;&quot;&gt;&quot;http://schemas.android.com/apk/res/android&quot;&lt;/span&gt;&lt;span style=&quot;color: #3f7f7f; font-weight: bold;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;        &lt;span style=&quot;color: #1a1a1a;&quot;&gt;&lt;span style=&quot;color: #3f7f7f; font-weight: bold;&quot;&gt;&amp;lt;LinearLayout&lt;/span&gt; &lt;span style=&quot;color: #7f007f;&quot;&gt;android:layout_width&lt;/span&gt;=&lt;span style=&quot;color: #2a00ff;&quot;&gt;&quot;fill_parent&quot;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #1a1a1a;&quot;&gt;                &lt;span style=&quot;color: #7f007f;&quot;&gt;android:layout_height&lt;/span&gt;=&lt;span style=&quot;color: #2a00ff;&quot;&gt;&quot;fill_parent&quot;&lt;/span&gt; &lt;span style=&quot;color: #7f007f;&quot;&gt;android:orientation&lt;/span&gt;=&lt;span style=&quot;color: #2a00ff;&quot;&gt;&quot;vertical&quot;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #1a1a1a;&quot;&gt;                &lt;span style=&quot;color: #7f007f;&quot;&gt;android:gravity&lt;/span&gt;=&lt;span style=&quot;color: #2a00ff;&quot;&gt;&quot;center&quot;&lt;/span&gt;&lt;span style=&quot;color: #3f7f7f; font-weight: bold;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;                &lt;span style=&quot;color: #1a1a1a;&quot;&gt;&lt;span style=&quot;color: #3f7f7f; font-weight: bold;&quot;&gt;&amp;lt;EditText&lt;/span&gt; &lt;span style=&quot;color: #7f007f;&quot;&gt;android:layout_width&lt;/span&gt;=&lt;span style=&quot;color: #2a00ff;&quot;&gt;&quot;fill_parent&quot;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #1a1a1a;&quot;&gt;                        &lt;span style=&quot;color: #7f007f;&quot;&gt;android:layout_height&lt;/span&gt;=&lt;span style=&quot;color: #2a00ff;&quot;&gt;&quot;wrap_content&quot;&lt;/span&gt; &lt;span style=&quot;color: #3f7f7f; font-weight: bold;&quot;&gt;/&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;                &lt;span style=&quot;color: #1a1a1a;&quot;&gt;&lt;span style=&quot;color: #3f7f7f; font-weight: bold;&quot;&gt;&amp;lt;Button&lt;/span&gt; &lt;span style=&quot;color: #7f007f;&quot;&gt;android:layout_width&lt;/span&gt;=&lt;span style=&quot;color: #2a00ff;&quot;&gt;&quot;wrap_content&quot;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #1a1a1a;&quot;&gt;                        &lt;span style=&quot;color: #7f007f;&quot;&gt;android:layout_height&lt;/span&gt;=&lt;span style=&quot;color: #2a00ff;&quot;&gt;&quot;wrap_content&quot;&lt;/span&gt; &lt;span style=&quot;color: #7f007f;&quot;&gt;android:text&lt;/span&gt;=&lt;span style=&quot;color: #2a00ff;&quot;&gt;&quot;Click...but do nothing&quot;&lt;/span&gt; &lt;span style=&quot;color: #3f7f7f; font-weight: bold;&quot;&gt;/&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;        &lt;span style=&quot;color: #1a1a1a;&quot;&gt;&lt;span style=&quot;color: #3f7f7f; font-weight: bold;&quot;&gt;&amp;lt;/LinearLayout&lt;span style=&quot;color: #3f7f7f; font-weight: bold;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;        &lt;span style=&quot;color: #1a1a1a;&quot;&gt;&lt;span style=&quot;color: #3f7f7f; font-weight: bold;&quot;&gt;&amp;lt;ViewStub&lt;/span&gt; &lt;span style=&quot;color: #7f007f;&quot;&gt;android:id&lt;/span&gt;=&lt;span style=&quot;color: #2a00ff;&quot;&gt;&quot;@+id/stub_menu&quot;&lt;/span&gt; &lt;span style=&quot;color: #7f007f;&quot;&gt;android:inflatedId&lt;/span&gt;=&lt;span style=&quot;color: #2a00ff;&quot;&gt;&quot;@+id/panel_menu&quot;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #1a1a1a;&quot;&gt;                &lt;span style=&quot;color: #7f007f;&quot;&gt;android:layout&lt;/span&gt;=&lt;span style=&quot;color: #2a00ff;&quot;&gt;&quot;@layout/menu&quot;&lt;/span&gt; &lt;span style=&quot;color: #7f007f;&quot;&gt;android:layout_width&lt;/span&gt;=&lt;span style=&quot;color: #2a00ff;&quot;&gt;&quot;fill_parent&quot;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #1a1a1a;&quot;&gt;                &lt;span style=&quot;color: #7f007f;&quot;&gt;android:layout_height&lt;/span&gt;=&lt;span style=&quot;color: #2a00ff;&quot;&gt;&quot;fill_parent&quot;&lt;/span&gt; &lt;span style=&quot;color: #7f007f;&quot;&gt;android:layout_gravity&lt;/span&gt;=&lt;span style=&quot;color: #2a00ff;&quot;&gt;&quot;top&quot;&lt;/span&gt; &lt;span style=&quot;color: #3f7f7f; font-weight: bold;&quot;&gt;/&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color: #1a1a1a;&quot;&gt;&lt;span style=&quot;color: #3f7f7f; font-weight: bold;&quot;&gt;&amp;lt;/merge&lt;span style=&quot;color: #3f7f7f; font-weight: bold;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;
La prima cosa che salta all’occhio direi è l’utilizzo del tag &lt;span class=&quot;bbc_color&quot; style=&quot;color: green;&quot;&gt;&amp;lt;merge&amp;gt;&lt;/span&gt;&lt;br /&gt;
Cos’è ? A cosa serve ? Il tag &lt;span class=&quot;bbc_color&quot; style=&quot;color: green;&quot;&gt;&amp;lt;merge&amp;gt;&lt;/span&gt; è stato creato per ridurre il numero di livelli nella gerarchia delle Views, sembra un po’ ostica da capire come cosa, ma vedendolo in azione si intuisce meglio il suo scopo. In altre parole, basta pensare che ogni View, e quindi ogni Layout, è figlio di un’altra View (o Layout) e difatti quando si crea un XML layout bisogna specifare un root Layout, che verrà istanziato poi al momento di generare il codice Java corrispondente dalla classe &lt;span class=&quot;bbc_color&quot; style=&quot;color: navy;&quot;&gt;LayoutInflater&lt;/span&gt;. In questo caso però, quando il &lt;span class=&quot;bbc_color&quot; style=&quot;color: navy;&quot;&gt;LayoutInflater&lt;/span&gt; incontrerà il tag &lt;span class=&quot;bbc_color&quot; style=&quot;color: green;&quot;&gt;&amp;lt;merge&amp;gt;&lt;/span&gt; non creerà una nuova istanza di un Layout ma non farà altro che unire la nostra View alla top-level View, cioè alla View di alto livello già istanziata. Comunque per altri chiarimenti vi rimando alla bibliografia in fondo al tutorial. Un altro motivo per cui ho utilizzato il tag &lt;span class=&quot;bbc_color&quot; style=&quot;color: green;&quot;&gt;&amp;lt;merge&amp;gt;&lt;/span&gt; è per poter sovrapporre le due View del layout, che sono il &lt;span class=&quot;bbc_color&quot; style=&quot;color: green;&quot;&gt;LinearLayout&lt;/span&gt; e, per l’appunto, la nostra &lt;span class=&quot;bbc_color&quot; style=&quot;color: green;&quot;&gt;ViewStub&lt;/span&gt; !&lt;br /&gt;
Il &lt;span class=&quot;bbc_color&quot; style=&quot;color: green;&quot;&gt;LinearLayout&lt;/span&gt; comprende una &lt;span class=&quot;bbc_color&quot; style=&quot;color: green;&quot;&gt;EditText&lt;/span&gt; e un &lt;span class=&quot;bbc_color&quot; style=&quot;color: green;&quot;&gt;Button&lt;/span&gt;, che ho messo a puro scopo indicativo, mentre vorrei soffermarmi un po’ sulla &lt;span class=&quot;bbc_color&quot; style=&quot;color: green;&quot;&gt;ViewStub&lt;/span&gt;, anche perché è il motivo di questo tutorial !&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;Analizzando la ViewStub&lt;/strong&gt;&lt;br /&gt;
&lt;br /&gt;
La &lt;span class=&quot;bbc_color&quot; style=&quot;color: green;&quot;&gt;ViewStub&lt;/span&gt; è una View che non ha dimensioni, non viene disegnata e che quindi non viene considerata in nessun modo all’interno del nostro layout. In pratica l’unica cosa che facciamo è dichiarare la sua esistenza per poterla poi usare in seguito quando ne avremo bisogno ! Il beneficio di usare una &lt;span class=&quot;bbc_color&quot; style=&quot;color: green;&quot;&gt;ViewStub&lt;/span&gt; è quello di non appesantire il sistema nella creazione di nuovi elementi a runtime, un po’ come la tecnica del lazy loading delle immagini,che spopola nel progettazione Web 2.0&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;Gli attributi della ViewStub&lt;/strong&gt;&lt;br /&gt;
&lt;br /&gt;
Quello che ci serve per dichiarare una ViewStub è un &lt;span class=&quot;bbc_color&quot; style=&quot;color: maroon;&quot;&gt;android:id&lt;/span&gt;, cioè l’identificativo della &lt;span class=&quot;bbc_color&quot; style=&quot;color: green;&quot;&gt;ViewStub&lt;/span&gt; stessa, e un &lt;span class=&quot;bbc_color&quot; style=&quot;color: maroon;&quot;&gt;android:layout&lt;/span&gt;, che non è altro che il riferimento al file XML contenente il layout che andrà a “popolare” la &lt;span class=&quot;bbc_color&quot; style=&quot;color: green;&quot;&gt;ViewStub&lt;/span&gt;. Un terzo attributo è l’&lt;span class=&quot;bbc_color&quot; style=&quot;color: maroon;&quot;&gt;android:inflateId&lt;/span&gt;, cioè l’identificativo del file XML contenente il layout (quello specificato prima). Per il resto, larghezza e altezza ecc.. sono i classici attributi che ritroviamo nella creazione dei layout. Nel caso specifico, ho settato come &lt;span class=&quot;bbc_color&quot; style=&quot;color: maroon;&quot;&gt;android:layout_gravity&lt;/span&gt; il valore top, in modo da posizionare la &lt;span class=&quot;bbc_color&quot; style=&quot;color: green;&quot;&gt;ViewStub&lt;/span&gt; in alto nello schermo.&lt;br /&gt;
Ok direi che per ora può bastare, vedremo successivamente come gestire la ViewStub all’interno dell’Activity. Per ulteriori informazioni vi rimando alla bibliografia in fondo a questo tutorial.&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;Il layout del menu&lt;/strong&gt;&lt;br /&gt;
&lt;br /&gt;
Quello di seguito altro non è che il layout XML del menu vero e proprio, quello che sarà dichiarato nell’attributo &lt;span class=&quot;bbc_color&quot; style=&quot;color: maroon;&quot;&gt;android:layout&lt;/span&gt; della ViewStub&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;Sorgenti:&lt;/strong&gt;&lt;br /&gt;
menu.xml&lt;br /&gt;
&lt;div class=&quot;codeheader&quot;&gt;
Codice (XML): &lt;a class=&quot;codeoperation&quot; href=&quot;javascript:void(0);&quot;&gt;&lt;span style=&quot;color: #334466;&quot;&gt;[Seleziona]&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;
&lt;code class=&quot;bbc_code&quot;&gt;&lt;span style=&quot;color: #1a1a1a;&quot;&gt;&lt;span style=&quot;color: #3f7f7f; font-weight: bold;&quot;&gt;&amp;lt;?xml&lt;/span&gt; &lt;span style=&quot;color: #7f007f;&quot;&gt;version&lt;/span&gt;=&lt;span style=&quot;color: #2a00ff;&quot;&gt;&quot;1.0&quot;&lt;/span&gt; &lt;span style=&quot;color: #7f007f;&quot;&gt;encoding&lt;/span&gt;=&lt;span style=&quot;color: #2a00ff;&quot;&gt;&quot;utf-8&quot;&lt;/span&gt;&lt;span style=&quot;color: #3f7f7f; font-weight: bold;&quot;&gt;?&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #1a1a1a;&quot;&gt;&lt;span style=&quot;color: #3f7f7f; font-weight: bold;&quot;&gt;&amp;lt;LinearLayout&lt;/span&gt; &lt;span style=&quot;color: #7f007f;&quot;&gt;xmlns:android&lt;/span&gt;=&lt;span style=&quot;color: #2a00ff;&quot;&gt;&quot;http://schemas.android.com/apk/res/android&quot;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #1a1a1a;&quot;&gt;        &lt;span style=&quot;color: #7f007f;&quot;&gt;android:layout_width&lt;/span&gt;=&lt;span style=&quot;color: #2a00ff;&quot;&gt;&quot;fill_parent&quot;&lt;/span&gt; &lt;span style=&quot;color: #7f007f;&quot;&gt;android:layout_height&lt;/span&gt;=&lt;span style=&quot;color: #2a00ff;&quot;&gt;&quot;fill_parent&quot;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #1a1a1a;&quot;&gt;        &lt;span style=&quot;color: #7f007f;&quot;&gt;android:background&lt;/span&gt;=&lt;span style=&quot;color: #2a00ff;&quot;&gt;&quot;#99000000&quot;&lt;/span&gt;&lt;span style=&quot;color: #3f7f7f; font-weight: bold;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;        &lt;span style=&quot;color: #1a1a1a;&quot;&gt;&lt;span style=&quot;color: #3f7f7f; font-weight: bold;&quot;&gt;&amp;lt;LinearLayout&lt;/span&gt; &lt;span style=&quot;color: #7f007f;&quot;&gt;android:layout_width&lt;/span&gt;=&lt;span style=&quot;color: #2a00ff;&quot;&gt;&quot;fill_parent&quot;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #1a1a1a;&quot;&gt;                &lt;span style=&quot;color: #7f007f;&quot;&gt;android:layout_height&lt;/span&gt;=&lt;span style=&quot;color: #2a00ff;&quot;&gt;&quot;wrap_content&quot;&lt;/span&gt; &lt;span style=&quot;color: #7f007f;&quot;&gt;android:padding&lt;/span&gt;=&lt;span style=&quot;color: #2a00ff;&quot;&gt;&quot;20dp&quot;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #1a1a1a;&quot;&gt;                &lt;span style=&quot;color: #7f007f;&quot;&gt;android:orientation&lt;/span&gt;=&lt;span style=&quot;color: #2a00ff;&quot;&gt;&quot;horizontal&quot;&lt;/span&gt; &lt;span style=&quot;color: #7f007f;&quot;&gt;android:gravity&lt;/span&gt;=&lt;span style=&quot;color: #2a00ff;&quot;&gt;&quot;center&quot;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #1a1a1a;&quot;&gt;                &lt;span style=&quot;color: #7f007f;&quot;&gt;android:background&lt;/span&gt;=&lt;span style=&quot;color: #2a00ff;&quot;&gt;&quot;#888&quot;&lt;/span&gt;&lt;span style=&quot;color: #3f7f7f; font-weight: bold;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;                &lt;span style=&quot;color: #1a1a1a;&quot;&gt;&lt;span style=&quot;color: #3f7f7f; font-weight: bold;&quot;&gt;&amp;lt;Button&lt;/span&gt; &lt;span style=&quot;color: #7f007f;&quot;&gt;android:id&lt;/span&gt;=&lt;span style=&quot;color: #2a00ff;&quot;&gt;&quot;@+id/button_1&quot;&lt;/span&gt; &lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #1a1a1a;&quot;&gt;                        &lt;span style=&quot;color: #7f007f;&quot;&gt;android:layout_width&lt;/span&gt;=&lt;span style=&quot;color: #2a00ff;&quot;&gt;&quot;wrap_content&quot;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #1a1a1a;&quot;&gt;                        &lt;span style=&quot;color: #7f007f;&quot;&gt;android:layout_height&lt;/span&gt;=&lt;span style=&quot;color: #2a00ff;&quot;&gt;&quot;wrap_content&quot;&lt;/span&gt; &lt;span style=&quot;color: #7f007f;&quot;&gt;android:text&lt;/span&gt;=&lt;span style=&quot;color: #2a00ff;&quot;&gt;&quot;Button 1&quot;&lt;/span&gt; &lt;span style=&quot;color: #3f7f7f; font-weight: bold;&quot;&gt;/&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;                &lt;span style=&quot;color: #1a1a1a;&quot;&gt;&lt;span style=&quot;color: #3f7f7f; font-weight: bold;&quot;&gt;&amp;lt;Button&lt;/span&gt; &lt;span style=&quot;color: #7f007f;&quot;&gt;android:id&lt;/span&gt;=&lt;span style=&quot;color: #2a00ff;&quot;&gt;&quot;@+id/button_2&quot;&lt;/span&gt; &lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #1a1a1a;&quot;&gt;                        &lt;span style=&quot;color: #7f007f;&quot;&gt;android:layout_width&lt;/span&gt;=&lt;span style=&quot;color: #2a00ff;&quot;&gt;&quot;wrap_content&quot;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #1a1a1a;&quot;&gt;                        &lt;span style=&quot;color: #7f007f;&quot;&gt;android:layout_height&lt;/span&gt;=&lt;span style=&quot;color: #2a00ff;&quot;&gt;&quot;wrap_content&quot;&lt;/span&gt; &lt;span style=&quot;color: #7f007f;&quot;&gt;android:text&lt;/span&gt;=&lt;span style=&quot;color: #2a00ff;&quot;&gt;&quot;Button 2&quot;&lt;/span&gt; &lt;span style=&quot;color: #3f7f7f; font-weight: bold;&quot;&gt;/&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;                &lt;span style=&quot;color: #1a1a1a;&quot;&gt;&lt;span style=&quot;color: #3f7f7f; font-weight: bold;&quot;&gt;&amp;lt;Button&lt;/span&gt; &lt;span style=&quot;color: #7f007f;&quot;&gt;android:id&lt;/span&gt;=&lt;span style=&quot;color: #2a00ff;&quot;&gt;&quot;@+id/button_3&quot;&lt;/span&gt; &lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #1a1a1a;&quot;&gt;                        &lt;span style=&quot;color: #7f007f;&quot;&gt;android:layout_width&lt;/span&gt;=&lt;span style=&quot;color: #2a00ff;&quot;&gt;&quot;wrap_content&quot;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #1a1a1a;&quot;&gt;                        &lt;span style=&quot;color: #7f007f;&quot;&gt;android:layout_height&lt;/span&gt;=&lt;span style=&quot;color: #2a00ff;&quot;&gt;&quot;wrap_content&quot;&lt;/span&gt; &lt;span style=&quot;color: #7f007f;&quot;&gt;android:text&lt;/span&gt;=&lt;span style=&quot;color: #2a00ff;&quot;&gt;&quot;Button 3&quot;&lt;/span&gt; &lt;span style=&quot;color: #3f7f7f; font-weight: bold;&quot;&gt;/&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;        &lt;span style=&quot;color: #1a1a1a;&quot;&gt;&lt;span style=&quot;color: #3f7f7f; font-weight: bold;&quot;&gt;&amp;lt;/LinearLayout&lt;span style=&quot;color: #3f7f7f; font-weight: bold;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #1a1a1a;&quot;&gt;&lt;span style=&quot;color: #3f7f7f; font-weight: bold;&quot;&gt;&amp;lt;/LinearLayout&lt;span style=&quot;color: #3f7f7f; font-weight: bold;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;
Molto semplice, due LinearLayout, uno dentro l’altro. Il secondo è quello che contiene i 3 pulsanti di esempio, mentre il primo è il nostro root Layout !&lt;br /&gt;
Ed ecco il trick  . Nel primo LinearLayout ho settato come attributo &lt;span class=&quot;bbc_color&quot; style=&quot;color: maroon;&quot;&gt;android:background&lt;/span&gt; il valore &lt;span class=&quot;bbc_color&quot; style=&quot;color: blue;&quot;&gt;“#99000000”&lt;/span&gt; , il quale darà il nostro tocco di stile al menu, rendendo lo sfondo trasparente (o traslucente). Ma cosa sono quei numeri ? Non è altro che il riferimento ad un colore del tipo &lt;strong&gt;rgb&lt;/strong&gt; con una componente &lt;strong&gt;alpha-transparency&lt;/strong&gt;, in pratica i primi due numeri -99- definiscono la alpha-transparency (a), i seguenti 2 numeri -00- la componente red (r), i successivi -00- il green (g) e infine gli ultimi due -00- il blue (b). Tradotto, ho settato lo sfondo del LinearLayout con il colore nero e un grado di trasparenza pari a 99. Provate a variare i primi due numeri (da 00 a 99) per vedere le varie differenze di trasparenza.&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;L’Activity principale&lt;/strong&gt;&lt;br /&gt;
&lt;br /&gt;
Ed eccoci finalmente al codice dell’Activity principale (nonché l’unica del tutorial).&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;Sorgenti:&lt;/strong&gt;&lt;br /&gt;
StubActivity.java&lt;br /&gt;
&lt;div class=&quot;codeheader&quot;&gt;
Codice (Java): &lt;a class=&quot;codeoperation&quot; href=&quot;javascript:void(0);&quot;&gt;&lt;span style=&quot;color: #334466;&quot;&gt;[Seleziona]&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;
&lt;code class=&quot;bbc_code&quot;&gt;&lt;span style=&quot;color: #7f0055; font-weight: bold;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #7f0055; font-weight: bold;&quot;&gt;class&lt;/span&gt; StubActivity &lt;span style=&quot;color: #7f0055; font-weight: bold;&quot;&gt;extends&lt;/span&gt; Activity &lt;span style=&quot;color: black;&quot;&gt;{&lt;/span&gt;&lt;br /&gt;        &lt;span style=&quot;color: #7f9fbf; font-weight: bold;&quot;&gt;/** Called when the activity is first created. */&lt;/span&gt;&lt;br /&gt;        &lt;span style=&quot;color: #7f0055; font-weight: bold;&quot;&gt;private&lt;/span&gt; &lt;a href=&quot;http://www.google.com/search?hl=en&amp;amp;q=allinurl%3Aview+java.sun.com&amp;amp;btnI=I%27m%20Feeling%20Lucky&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;View&lt;/span&gt;&lt;/a&gt; menu&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;        @Override&lt;br /&gt;        &lt;span style=&quot;color: #7f0055; font-weight: bold;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #7f0055; font-weight: bold;&quot;&gt;void&lt;/span&gt; onCreate&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;Bundle savedInstanceState&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt; &lt;span style=&quot;color: black;&quot;&gt;{&lt;/span&gt;&lt;br /&gt;                &lt;span style=&quot;color: #7f0055; font-weight: bold;&quot;&gt;super&lt;/span&gt;.&lt;span style=&quot;color: black;&quot;&gt;onCreate&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;savedInstanceState&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;                setContentView&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;R.&lt;span style=&quot;color: black;&quot;&gt;layout&lt;/span&gt;.&lt;span style=&quot;color: black;&quot;&gt;stubs&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;                menuInit&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;        &lt;span style=&quot;color: black;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;        &lt;span style=&quot;color: #7f0055; font-weight: bold;&quot;&gt;private&lt;/span&gt; &lt;span style=&quot;color: #7f0055; font-weight: bold;&quot;&gt;void&lt;/span&gt; menuInit&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt; &lt;span style=&quot;color: black;&quot;&gt;{&lt;/span&gt;&lt;br /&gt;                menu &lt;span style=&quot;color: black;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;ViewStub&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt; findViewById&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;R.&lt;span style=&quot;color: black;&quot;&gt;id&lt;/span&gt;.&lt;span style=&quot;color: black;&quot;&gt;stub_menu&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;.&lt;span style=&quot;color: black;&quot;&gt;inflate&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;                menu.&lt;span style=&quot;color: black;&quot;&gt;setVisibility&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;a href=&quot;http://www.google.com/search?hl=en&amp;amp;q=allinurl%3Aview+java.sun.com&amp;amp;btnI=I%27m%20Feeling%20Lucky&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;View&lt;/span&gt;&lt;/a&gt;.&lt;span style=&quot;color: black;&quot;&gt;GONE&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;                &lt;a href=&quot;http://www.google.com/search?hl=en&amp;amp;q=allinurl%3Abutton+java.sun.com&amp;amp;btnI=I%27m%20Feeling%20Lucky&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;Button&lt;/span&gt;&lt;/a&gt; b1 &lt;span style=&quot;color: black;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;a href=&quot;http://www.google.com/search?hl=en&amp;amp;q=allinurl%3Abutton+java.sun.com&amp;amp;btnI=I%27m%20Feeling%20Lucky&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;Button&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt; menu.&lt;span style=&quot;color: black;&quot;&gt;findViewById&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;R.&lt;span style=&quot;color: black;&quot;&gt;id&lt;/span&gt;.&lt;span style=&quot;color: black;&quot;&gt;button_1&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;                b1.&lt;span style=&quot;color: black;&quot;&gt;setOnClickListener&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #7f0055; font-weight: bold;&quot;&gt;new&lt;/span&gt; OnClickListener&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt; &lt;span style=&quot;color: black;&quot;&gt;{&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;                        @Override&lt;br /&gt;                        &lt;span style=&quot;color: #7f0055; font-weight: bold;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #7f0055; font-weight: bold;&quot;&gt;void&lt;/span&gt; onClick&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;a href=&quot;http://www.google.com/search?hl=en&amp;amp;q=allinurl%3Aview+java.sun.com&amp;amp;btnI=I%27m%20Feeling%20Lucky&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;View&lt;/span&gt;&lt;/a&gt; arg0&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt; &lt;span style=&quot;color: black;&quot;&gt;{&lt;/span&gt;&lt;br /&gt;                                Toast.&lt;span style=&quot;color: black;&quot;&gt;makeText&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;getApplicationContext&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;,&lt;br /&gt;                                                &lt;span style=&quot;color: #2a00ff;&quot;&gt;&quot;Click on Button 1&quot;&lt;/span&gt;,&lt;br /&gt;                                                Toast.&lt;span style=&quot;color: black;&quot;&gt;LENGTH_SHORT&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;.&lt;span style=&quot;color: black;&quot;&gt;show&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;                        &lt;span style=&quot;color: black;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;                &lt;span style=&quot;color: black;&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;                &lt;a href=&quot;http://www.google.com/search?hl=en&amp;amp;q=allinurl%3Abutton+java.sun.com&amp;amp;btnI=I%27m%20Feeling%20Lucky&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;Button&lt;/span&gt;&lt;/a&gt; b2 &lt;span style=&quot;color: black;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;a href=&quot;http://www.google.com/search?hl=en&amp;amp;q=allinurl%3Abutton+java.sun.com&amp;amp;btnI=I%27m%20Feeling%20Lucky&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;Button&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt; menu.&lt;span style=&quot;color: black;&quot;&gt;findViewById&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;R.&lt;span style=&quot;color: black;&quot;&gt;id&lt;/span&gt;.&lt;span style=&quot;color: black;&quot;&gt;button_2&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;                b2.&lt;span style=&quot;color: black;&quot;&gt;setOnClickListener&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #7f0055; font-weight: bold;&quot;&gt;new&lt;/span&gt; OnClickListener&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt; &lt;span style=&quot;color: black;&quot;&gt;{&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;                        @Override&lt;br /&gt;                        &lt;span style=&quot;color: #7f0055; font-weight: bold;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #7f0055; font-weight: bold;&quot;&gt;void&lt;/span&gt; onClick&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;a href=&quot;http://www.google.com/search?hl=en&amp;amp;q=allinurl%3Aview+java.sun.com&amp;amp;btnI=I%27m%20Feeling%20Lucky&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;View&lt;/span&gt;&lt;/a&gt; arg0&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt; &lt;span style=&quot;color: black;&quot;&gt;{&lt;/span&gt;&lt;br /&gt;                                Toast.&lt;span style=&quot;color: black;&quot;&gt;makeText&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;getApplicationContext&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;,&lt;br /&gt;                                                &lt;span style=&quot;color: #2a00ff;&quot;&gt;&quot;Click on Button 2&quot;&lt;/span&gt;,&lt;br /&gt;                                                Toast.&lt;span style=&quot;color: black;&quot;&gt;LENGTH_SHORT&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;.&lt;span style=&quot;color: black;&quot;&gt;show&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;                        &lt;span style=&quot;color: black;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;                &lt;span style=&quot;color: black;&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;                &lt;a href=&quot;http://www.google.com/search?hl=en&amp;amp;q=allinurl%3Abutton+java.sun.com&amp;amp;btnI=I%27m%20Feeling%20Lucky&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;Button&lt;/span&gt;&lt;/a&gt; b3 &lt;span style=&quot;color: black;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;a href=&quot;http://www.google.com/search?hl=en&amp;amp;q=allinurl%3Abutton+java.sun.com&amp;amp;btnI=I%27m%20Feeling%20Lucky&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;Button&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt; menu.&lt;span style=&quot;color: black;&quot;&gt;findViewById&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;R.&lt;span style=&quot;color: black;&quot;&gt;id&lt;/span&gt;.&lt;span style=&quot;color: black;&quot;&gt;button_3&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;                b3.&lt;span style=&quot;color: black;&quot;&gt;setOnClickListener&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #7f0055; font-weight: bold;&quot;&gt;new&lt;/span&gt; OnClickListener&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt; &lt;span style=&quot;color: black;&quot;&gt;{&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;                        @Override&lt;br /&gt;                        &lt;span style=&quot;color: #7f0055; font-weight: bold;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #7f0055; font-weight: bold;&quot;&gt;void&lt;/span&gt; onClick&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;a href=&quot;http://www.google.com/search?hl=en&amp;amp;q=allinurl%3Aview+java.sun.com&amp;amp;btnI=I%27m%20Feeling%20Lucky&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;View&lt;/span&gt;&lt;/a&gt; arg0&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt; &lt;span style=&quot;color: black;&quot;&gt;{&lt;/span&gt;&lt;br /&gt;                                Toast.&lt;span style=&quot;color: black;&quot;&gt;makeText&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;getApplicationContext&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;,&lt;br /&gt;                                                &lt;span style=&quot;color: #2a00ff;&quot;&gt;&quot;Click on Button 3&quot;&lt;/span&gt;,&lt;br /&gt;                                                Toast.&lt;span style=&quot;color: black;&quot;&gt;LENGTH_SHORT&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;.&lt;span style=&quot;color: black;&quot;&gt;show&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;                        &lt;span style=&quot;color: black;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;                &lt;span style=&quot;color: black;&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;        &lt;span style=&quot;color: black;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;        @Override&lt;br /&gt;        &lt;span style=&quot;color: #7f0055; font-weight: bold;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #7f0055; font-weight: bold;&quot;&gt;boolean&lt;/span&gt; onKeyDown&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #7f0055; font-weight: bold;&quot;&gt;int&lt;/span&gt; keyCode, &lt;a href=&quot;http://www.google.com/search?hl=en&amp;amp;q=allinurl%3Akeyevent+java.sun.com&amp;amp;btnI=I%27m%20Feeling%20Lucky&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;KeyEvent&lt;/span&gt;&lt;/a&gt; event&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt; &lt;span style=&quot;color: black;&quot;&gt;{&lt;/span&gt;&lt;br /&gt;                &lt;span style=&quot;color: #7f0055; font-weight: bold;&quot;&gt;switch&lt;/span&gt; &lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;keyCode&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt; &lt;span style=&quot;color: black;&quot;&gt;{&lt;/span&gt;&lt;br /&gt;                &lt;span style=&quot;color: #7f0055; font-weight: bold;&quot;&gt;case&lt;/span&gt; &lt;a href=&quot;http://www.google.com/search?hl=en&amp;amp;q=allinurl%3Akeyevent+java.sun.com&amp;amp;btnI=I%27m%20Feeling%20Lucky&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;KeyEvent&lt;/span&gt;&lt;/a&gt;.&lt;span style=&quot;color: black;&quot;&gt;KEYCODE_MENU&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;:&lt;/span&gt;&lt;br /&gt;                        &lt;span style=&quot;color: #7f0055; font-weight: bold;&quot;&gt;int&lt;/span&gt; visibility &lt;span style=&quot;color: black;&quot;&gt;=&lt;/span&gt; menu.&lt;span style=&quot;color: black;&quot;&gt;getVisibility&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt; &lt;span style=&quot;color: black;&quot;&gt;==&lt;/span&gt; &lt;a href=&quot;http://www.google.com/search?hl=en&amp;amp;q=allinurl%3Aview+java.sun.com&amp;amp;btnI=I%27m%20Feeling%20Lucky&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;View&lt;/span&gt;&lt;/a&gt;.&lt;span style=&quot;color: black;&quot;&gt;VISIBLE&lt;/span&gt; &lt;span style=&quot;color: black;&quot;&gt;?&lt;/span&gt; &lt;a href=&quot;http://www.google.com/search?hl=en&amp;amp;q=allinurl%3Aview+java.sun.com&amp;amp;btnI=I%27m%20Feeling%20Lucky&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;View&lt;/span&gt;&lt;/a&gt;.&lt;span style=&quot;color: black;&quot;&gt;GONE&lt;/span&gt; &lt;span style=&quot;color: black;&quot;&gt;:&lt;/span&gt; &lt;a href=&quot;http://www.google.com/search?hl=en&amp;amp;q=allinurl%3Aview+java.sun.com&amp;amp;btnI=I%27m%20Feeling%20Lucky&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;View&lt;/span&gt;&lt;/a&gt;.&lt;span style=&quot;color: black;&quot;&gt;VISIBLE&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;                        menu.&lt;span style=&quot;color: black;&quot;&gt;setVisibility&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;visibility&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;                        &lt;span style=&quot;color: #7f0055; font-weight: bold;&quot;&gt;break&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;                &lt;span style=&quot;color: #7f0055; font-weight: bold;&quot;&gt;case&lt;/span&gt; &lt;a href=&quot;http://www.google.com/search?hl=en&amp;amp;q=allinurl%3Akeyevent+java.sun.com&amp;amp;btnI=I%27m%20Feeling%20Lucky&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;KeyEvent&lt;/span&gt;&lt;/a&gt;.&lt;span style=&quot;color: black;&quot;&gt;KEYCODE_BACK&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;:&lt;/span&gt;&lt;br /&gt;                        &lt;span style=&quot;color: #7f0055; font-weight: bold;&quot;&gt;if&lt;/span&gt; &lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;menu.&lt;span style=&quot;color: black;&quot;&gt;getVisibility&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt; &lt;span style=&quot;color: black;&quot;&gt;==&lt;/span&gt; &lt;a href=&quot;http://www.google.com/search?hl=en&amp;amp;q=allinurl%3Aview+java.sun.com&amp;amp;btnI=I%27m%20Feeling%20Lucky&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;View&lt;/span&gt;&lt;/a&gt;.&lt;span style=&quot;color: black;&quot;&gt;VISIBLE&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt; &lt;span style=&quot;color: black;&quot;&gt;{&lt;/span&gt;&lt;br /&gt;                                menu.&lt;span style=&quot;color: black;&quot;&gt;setVisibility&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;a href=&quot;http://www.google.com/search?hl=en&amp;amp;q=allinurl%3Aview+java.sun.com&amp;amp;btnI=I%27m%20Feeling%20Lucky&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;View&lt;/span&gt;&lt;/a&gt;.&lt;span style=&quot;color: black;&quot;&gt;GONE&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;                        &lt;span style=&quot;color: black;&quot;&gt;}&lt;/span&gt; &lt;span style=&quot;color: #7f0055; font-weight: bold;&quot;&gt;else&lt;/span&gt;&lt;br /&gt;                                &lt;span style=&quot;color: #7f0055; font-weight: bold;&quot;&gt;this&lt;/span&gt;.&lt;span style=&quot;color: black;&quot;&gt;finish&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;                        &lt;span style=&quot;color: #7f0055; font-weight: bold;&quot;&gt;break&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;                &lt;span style=&quot;color: #7f0055; font-weight: bold;&quot;&gt;default&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;:&lt;/span&gt;&lt;br /&gt;                        &lt;span style=&quot;color: #7f0055; font-weight: bold;&quot;&gt;break&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;                &lt;span style=&quot;color: black;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;                &lt;span style=&quot;color: #7f0055; font-weight: bold;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #7f0055; font-weight: bold;&quot;&gt;false&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;        &lt;span style=&quot;color: black;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color: black;&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;
Come sempre, creiamo una classe che estende Activity e settiamo la View principale con il file stubs.xml, dopodiché inizializziamo il menu.&lt;br /&gt;
Ho creato il metodo &lt;em&gt;menuInit()&lt;/em&gt; proprio per fare questo, vediamo cosa fa.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;codeheader&quot;&gt;
Codice (Java): &lt;a class=&quot;codeoperation&quot; href=&quot;javascript:void(0);&quot;&gt;&lt;span style=&quot;color: #334466;&quot;&gt;[Seleziona]&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;
&lt;code class=&quot;bbc_code&quot;&gt;menu &lt;span style=&quot;color: black;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;ViewStub&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt; findViewById&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;R.&lt;span style=&quot;color: black;&quot;&gt;id&lt;/span&gt;.&lt;span style=&quot;color: black;&quot;&gt;stub_menu&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;.&lt;span style=&quot;color: black;&quot;&gt;inflate&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;
Ecco il tassello mancante per l’utilizzo delle ViewStub. Il metodo &lt;span class=&quot;bbc_color&quot; style=&quot;color: navy;&quot;&gt;inflate()&lt;/span&gt; inserisce di fatto la ViewStub all’interno del nostro layout, restituendo il riferimento alla View che contiene il layout del menu. Da questo momento la View diventa visibile a tutti gli effetti, ecco perché con la successiva riga di codice&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;codeheader&quot;&gt;
Codice (Java): &lt;a class=&quot;codeoperation&quot; href=&quot;javascript:void(0);&quot;&gt;&lt;span style=&quot;color: #334466;&quot;&gt;[Seleziona]&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;
&lt;code class=&quot;bbc_code&quot;&gt;menu.&lt;span style=&quot;color: black;&quot;&gt;setVisibility&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;a href=&quot;http://www.google.com/search?hl=en&amp;amp;q=allinurl%3Aview+java.sun.com&amp;amp;btnI=I%27m%20Feeling%20Lucky&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;View&lt;/span&gt;&lt;/a&gt;.&lt;span style=&quot;color: black;&quot;&gt;GONE&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;
Rimuovo la View da flusso delle View visibili a schermo, perché per il momento il menu non deve essere visibile.&lt;br /&gt;
Ora che abbiamo il riferimento alla View del menu, possiamo interagire con i componenti che la popolano. Nello specifico, è stato assegnato un OnClickListener ai 3 pulsanti del menu, i quali al loro click faranno apparire a video un messaggio.&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;Gestire il menu sull’onKeyDown&lt;/strong&gt;&lt;br /&gt;
&lt;br /&gt;
Ora che il menu è inizializzato possiamo mostrarlo e renderlo fruibile. In questo tutorial ho deciso di farlo apparire alla pressione del tasto menu del device (ma guarda il caso… ) ma nulla vieta di gestirlo diversamente. Il codice non è ottimizzato al massimo, ma d’altronde è solo un esempio.&lt;br /&gt;
Con queste righe di codice&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;codeheader&quot;&gt;
Codice (Java): &lt;a class=&quot;codeoperation&quot; href=&quot;javascript:void(0);&quot;&gt;&lt;span style=&quot;color: #334466;&quot;&gt;[Seleziona]&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;
&lt;code class=&quot;bbc_code&quot;&gt;&lt;span style=&quot;color: #7f0055; font-weight: bold;&quot;&gt;int&lt;/span&gt; visibility &lt;span style=&quot;color: black;&quot;&gt;=&lt;/span&gt; menu.&lt;span style=&quot;color: black;&quot;&gt;getVisibility&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt; &lt;span style=&quot;color: black;&quot;&gt;==&lt;/span&gt; &lt;a href=&quot;http://www.google.com/search?hl=en&amp;amp;q=allinurl%3Aview+java.sun.com&amp;amp;btnI=I%27m%20Feeling%20Lucky&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;View&lt;/span&gt;&lt;/a&gt;.&lt;span style=&quot;color: black;&quot;&gt;VISIBLE&lt;/span&gt; &lt;span style=&quot;color: black;&quot;&gt;?&lt;/span&gt; &lt;a href=&quot;http://www.google.com/search?hl=en&amp;amp;q=allinurl%3Aview+java.sun.com&amp;amp;btnI=I%27m%20Feeling%20Lucky&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;View&lt;/span&gt;&lt;/a&gt;.&lt;span style=&quot;color: black;&quot;&gt;GONE&lt;/span&gt; &lt;span style=&quot;color: black;&quot;&gt;:&lt;/span&gt; &lt;a href=&quot;http://www.google.com/search?hl=en&amp;amp;q=allinurl%3Aview+java.sun.com&amp;amp;btnI=I%27m%20Feeling%20Lucky&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;View&lt;/span&gt;&lt;/a&gt;.&lt;span style=&quot;color: black;&quot;&gt;VISIBLE&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;menu.&lt;span style=&quot;color: black;&quot;&gt;setVisibility&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;visibility&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;
Rendo visibile o meno il menu alla pressione del tasto menu.&lt;br /&gt;
Dato che stiamo facendo l’override del metodo onKeyDown dell’Activity, il tasto “indietro” del device sarà ora inutilizzabile, quindi andiamo a gestire anche questo, per poter permettere l’uscita dall’applicazione nel modo tradizionale, e già che ci siamo aggiungiamo un altro tocco di stile al nostro menu, nascondendolo anche alla pressione del suddetto tasto&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;codeheader&quot;&gt;
Codice (Java): &lt;a class=&quot;codeoperation&quot; href=&quot;javascript:void(0);&quot;&gt;&lt;span style=&quot;color: #334466;&quot;&gt;[Seleziona]&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;
&lt;code class=&quot;bbc_code&quot;&gt;&lt;span style=&quot;color: #7f0055; font-weight: bold;&quot;&gt;if&lt;/span&gt; &lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;menu.&lt;span style=&quot;color: black;&quot;&gt;getVisibility&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt; &lt;span style=&quot;color: black;&quot;&gt;==&lt;/span&gt; &lt;a href=&quot;http://www.google.com/search?hl=en&amp;amp;q=allinurl%3Aview+java.sun.com&amp;amp;btnI=I%27m%20Feeling%20Lucky&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;View&lt;/span&gt;&lt;/a&gt;.&lt;span style=&quot;color: black;&quot;&gt;VISIBLE&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt; &lt;span style=&quot;color: black;&quot;&gt;{&lt;/span&gt;&lt;br /&gt;menu.&lt;span style=&quot;color: black;&quot;&gt;setVisibility&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;a href=&quot;http://www.google.com/search?hl=en&amp;amp;q=allinurl%3Aview+java.sun.com&amp;amp;btnI=I%27m%20Feeling%20Lucky&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;View&lt;/span&gt;&lt;/a&gt;.&lt;span style=&quot;color: black;&quot;&gt;GONE&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: black;&quot;&gt;}&lt;/span&gt; &lt;span style=&quot;color: #7f0055; font-weight: bold;&quot;&gt;else&lt;/span&gt; &lt;span style=&quot;color: #7f0055; font-weight: bold;&quot;&gt;this&lt;/span&gt;.&lt;span style=&quot;color: black;&quot;&gt;finish&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;
E con questo è tutto, abbiamo realizzato un menu con sfondo trasparente con il solo ausilio delle ViewStub. In questo modo l’app risulta notevolmente meno appesantita, il nostro codice è modulare e la nostra ViewStub è riusabile per altri progetti.&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;Bibliografia:&lt;/strong&gt;&lt;br /&gt;
&lt;ul class=&quot;bbc_list&quot;&gt;
&lt;li&gt;&lt;a class=&quot;bbc_link&quot; href=&quot;http://developer.android.com/resources/articles/layout-tricks-stubs.html&quot; target=&quot;_blank&quot;&gt;&lt;span style=&quot;color: #334466;&quot;&gt;Layout-Tricks | ViewStubs&lt;/span&gt;&lt;/a&gt; - Android official documentation&lt;/li&gt;
&lt;li&gt;&lt;a class=&quot;bbc_link&quot; href=&quot;http://developer.android.com/resources/articles/layout-tricks-merge.html&quot; target=&quot;_blank&quot;&gt;&lt;span style=&quot;color: #334466;&quot;&gt;Layout-Tricks | Merge&lt;/span&gt;&lt;/a&gt; - Android official documentation&lt;/li&gt;
&lt;/ul&gt;</content><link rel='replies' type='application/atom+xml' href='http://bluedreamsandroid.blogspot.com/feeds/781302615898981932/comments/default' title='Commenti sul post'/><link rel='replies' type='text/html' href='http://bluedreamsandroid.blogspot.com/2011/11/menu-con-le-viewstub.html#comment-form' title='0 Commenti'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/921091465317807586/posts/default/781302615898981932'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/921091465317807586/posts/default/781302615898981932'/><link rel='alternate' type='text/html' href='http://bluedreamsandroid.blogspot.com/2011/11/menu-con-le-viewstub.html' title='Menu con le ViewStub'/><author><name>BlueDremas</name><uri>http://www.blogger.com/profile/02561736174885737185</uri><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><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-921091465317807586.post-4933971661965529535</id><published>2011-04-07T23:58:00.000-07:00</published><updated>2011-11-16T14:59:51.967-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Codice"/><category scheme="http://www.blogger.com/atom/ns#" term="esempio"/><title type='text'>Length-prefix message framing for streams</title><content type='html'>&lt;div class=&quot;container&quot;&gt;
&lt;div class=&quot;line number1 index0 alt2&quot;&gt;
&lt;code class=&quot;csharp comments&quot;&gt;// Original source: &lt;a href=&quot;http://nitoprograms.blogspot.com/2009/04/sample-code-length-prefix-message.html&quot;&gt;&lt;span style=&quot;color: #336699;&quot;&gt;http://nitoprograms.blogspot.com/2009/04/sample-code-length-prefix-message.html&lt;/span&gt;&lt;/a&gt; &lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number2 index1 alt1&quot;&gt;
&lt;code class=&quot;csharp color1&quot;&gt;/// &amp;lt;summary&amp;gt; &lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number3 index2 alt2&quot;&gt;
&lt;code class=&quot;csharp color1&quot;&gt;/// Maintains the necessary buffers for applying a length-prefix message framing protocol over a stream. &lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number4 index3 alt1&quot;&gt;
&lt;code class=&quot;csharp color1&quot;&gt;/// &amp;lt;/summary&amp;gt; &lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number5 index4 alt2&quot;&gt;
&lt;code class=&quot;csharp color1&quot;&gt;/// &amp;lt;remarks&amp;gt; &lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number6 index5 alt1&quot;&gt;
&lt;code class=&quot;csharp color1&quot;&gt;/// &amp;lt;para&amp;gt;Create one instance of this class for each incoming stream, and assign a handler to &amp;lt;see cref=&quot;MessageArrived&quot;/&amp;gt;. As bytes arrive at the stream, pass them to &amp;lt;see cref=&quot;DataReceived&quot;/&amp;gt;, which will invoke &amp;lt;see cref=&quot;MessageArrived&quot;/&amp;gt; as necessary.&amp;lt;/para&amp;gt; &lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number7 index6 alt2&quot;&gt;
&lt;code class=&quot;csharp color1&quot;&gt;/// &amp;lt;para&amp;gt;If &amp;lt;see cref=&quot;DataReceived&quot;/&amp;gt; raises &amp;lt;see cref=&quot;System.Net.ProtocolViolationException&quot;/&amp;gt;, then the stream data should be considered invalid. After that point, no methods should be called on that &amp;lt;see cref=&quot;PacketProtocol&quot;/&amp;gt; instance.&amp;lt;/para&amp;gt; &lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number8 index7 alt1&quot;&gt;
&lt;code class=&quot;csharp color1&quot;&gt;/// &amp;lt;para&amp;gt;This class uses a 4-byte signed integer length prefix, which allows for message sizes up to 2 GB. Keepalive messages are supported as messages with a length prefix of 0 and no message data.&amp;lt;/para&amp;gt; &lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number9 index8 alt2&quot;&gt;
&lt;code class=&quot;csharp color1&quot;&gt;/// &amp;lt;para&amp;gt;This is EXAMPLE CODE! It is not particularly efficient; in particular, if this class is rewritten so that a particular interface is used (e.g., Socket&#39;s IAsyncResult methods), some buffer copies become unnecessary and may be removed.&amp;lt;/para&amp;gt; &lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number10 index9 alt1&quot;&gt;
&lt;code class=&quot;csharp color1&quot;&gt;/// &amp;lt;/remarks&amp;gt; &lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number11 index10 alt2&quot;&gt;
&lt;code class=&quot;csharp keyword&quot;&gt;public&lt;/code&gt; &lt;code class=&quot;csharp keyword&quot;&gt;class&lt;/code&gt; &lt;code class=&quot;csharp plain&quot;&gt;PacketProtocol &lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number12 index11 alt1&quot;&gt;
&lt;code class=&quot;csharp plain&quot;&gt;{ &lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number13 index12 alt2&quot;&gt;
&lt;code class=&quot;csharp spaces&quot;&gt;    &lt;/code&gt;&lt;code class=&quot;csharp color1&quot;&gt;/// &amp;lt;summary&amp;gt; &lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number14 index13 alt1&quot;&gt;
&lt;code class=&quot;csharp spaces&quot;&gt;    &lt;/code&gt;&lt;code class=&quot;csharp color1&quot;&gt;/// Wraps a message. The wrapped message is ready to send to a stream. &lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number15 index14 alt2&quot;&gt;
&lt;code class=&quot;csharp spaces&quot;&gt;    &lt;/code&gt;&lt;code class=&quot;csharp color1&quot;&gt;/// &amp;lt;/summary&amp;gt; &lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number16 index15 alt1&quot;&gt;
&lt;code class=&quot;csharp spaces&quot;&gt;    &lt;/code&gt;&lt;code class=&quot;csharp color1&quot;&gt;/// &amp;lt;remarks&amp;gt; &lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number17 index16 alt2&quot;&gt;
&lt;code class=&quot;csharp spaces&quot;&gt;    &lt;/code&gt;&lt;code class=&quot;csharp color1&quot;&gt;/// &amp;lt;para&amp;gt;Generates a length prefix for the message and returns the combined length prefix and message.&amp;lt;/para&amp;gt; &lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number18 index17 alt1&quot;&gt;
&lt;code class=&quot;csharp spaces&quot;&gt;    &lt;/code&gt;&lt;code class=&quot;csharp color1&quot;&gt;/// &amp;lt;/remarks&amp;gt; &lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number19 index18 alt2&quot;&gt;
&lt;code class=&quot;csharp spaces&quot;&gt;    &lt;/code&gt;&lt;code class=&quot;csharp color1&quot;&gt;/// &amp;lt;param name=&quot;message&quot;&amp;gt;The message to send.&amp;lt;/param&amp;gt; &lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number20 index19 alt1&quot;&gt;
&lt;code class=&quot;csharp spaces&quot;&gt;    &lt;/code&gt;&lt;code class=&quot;csharp keyword&quot;&gt;public&lt;/code&gt; &lt;code class=&quot;csharp keyword&quot;&gt;static&lt;/code&gt; &lt;code class=&quot;csharp keyword&quot;&gt;byte&lt;/code&gt;&lt;code class=&quot;csharp plain&quot;&gt;[] WrapMessage(&lt;/code&gt;&lt;code class=&quot;csharp keyword&quot;&gt;byte&lt;/code&gt;&lt;code class=&quot;csharp plain&quot;&gt;[] message) &lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number21 index20 alt2&quot;&gt;
&lt;code class=&quot;csharp spaces&quot;&gt;    &lt;/code&gt;&lt;code class=&quot;csharp plain&quot;&gt;{ &lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number22 index21 alt1&quot;&gt;
&lt;code class=&quot;csharp spaces&quot;&gt;        &lt;/code&gt;&lt;code class=&quot;csharp comments&quot;&gt;// Get the length prefix for the message &lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number23 index22 alt2&quot;&gt;
&lt;code class=&quot;csharp spaces&quot;&gt;        &lt;/code&gt;&lt;code class=&quot;csharp keyword&quot;&gt;byte&lt;/code&gt;&lt;code class=&quot;csharp plain&quot;&gt;[] lengthPrefix = BitConverter.GetBytes(message.Length); &lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number24 index23 alt1&quot;&gt;
&lt;code class=&quot;csharp spaces&quot;&gt;  &lt;/code&gt; &lt;/div&gt;
&lt;div class=&quot;line number25 index24 alt2&quot;&gt;
&lt;code class=&quot;csharp spaces&quot;&gt;        &lt;/code&gt;&lt;code class=&quot;csharp comments&quot;&gt;// Concatenate the length prefix and the message &lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number26 index25 alt1&quot;&gt;
&lt;code class=&quot;csharp spaces&quot;&gt;        &lt;/code&gt;&lt;code class=&quot;csharp keyword&quot;&gt;byte&lt;/code&gt;&lt;code class=&quot;csharp plain&quot;&gt;[] ret = &lt;/code&gt;&lt;code class=&quot;csharp keyword&quot;&gt;new&lt;/code&gt; &lt;code class=&quot;csharp keyword&quot;&gt;byte&lt;/code&gt;&lt;code class=&quot;csharp plain&quot;&gt;[lengthPrefix.Length + message.Length]; &lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number27 index26 alt2&quot;&gt;
&lt;code class=&quot;csharp spaces&quot;&gt;        &lt;/code&gt;&lt;code class=&quot;csharp plain&quot;&gt;lengthPrefix.CopyTo(ret, 0); &lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number28 index27 alt1&quot;&gt;
&lt;code class=&quot;csharp spaces&quot;&gt;        &lt;/code&gt;&lt;code class=&quot;csharp plain&quot;&gt;message.CopyTo(ret, lengthPrefix.Length); &lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number29 index28 alt2&quot;&gt;
&lt;code class=&quot;csharp spaces&quot;&gt;  &lt;/code&gt; &lt;/div&gt;
&lt;div class=&quot;line number30 index29 alt1&quot;&gt;
&lt;code class=&quot;csharp spaces&quot;&gt;        &lt;/code&gt;&lt;code class=&quot;csharp keyword&quot;&gt;return&lt;/code&gt; &lt;code class=&quot;csharp plain&quot;&gt;ret; &lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number31 index30 alt2&quot;&gt;
&lt;code class=&quot;csharp spaces&quot;&gt;    &lt;/code&gt;&lt;code class=&quot;csharp plain&quot;&gt;} &lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number32 index31 alt1&quot;&gt;
&lt;code class=&quot;csharp spaces&quot;&gt;  &lt;/code&gt; &lt;/div&gt;
&lt;div class=&quot;line number33 index32 alt2&quot;&gt;
&lt;code class=&quot;csharp spaces&quot;&gt;    &lt;/code&gt;&lt;code class=&quot;csharp color1&quot;&gt;/// &amp;lt;summary&amp;gt; &lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number34 index33 alt1&quot;&gt;
&lt;code class=&quot;csharp spaces&quot;&gt;    &lt;/code&gt;&lt;code class=&quot;csharp color1&quot;&gt;/// Wraps a keepalive (0-length) message. The wrapped message is ready to send to a stream. &lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number35 index34 alt2&quot;&gt;
&lt;code class=&quot;csharp spaces&quot;&gt;    &lt;/code&gt;&lt;code class=&quot;csharp color1&quot;&gt;/// &amp;lt;/summary&amp;gt; &lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number36 index35 alt1&quot;&gt;
&lt;code class=&quot;csharp spaces&quot;&gt;    &lt;/code&gt;&lt;code class=&quot;csharp keyword&quot;&gt;public&lt;/code&gt; &lt;code class=&quot;csharp keyword&quot;&gt;static&lt;/code&gt; &lt;code class=&quot;csharp keyword&quot;&gt;byte&lt;/code&gt;&lt;code class=&quot;csharp plain&quot;&gt;[] WrapKeepaliveMessage() &lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number37 index36 alt2&quot;&gt;
&lt;code class=&quot;csharp spaces&quot;&gt;    &lt;/code&gt;&lt;code class=&quot;csharp plain&quot;&gt;{ &lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number38 index37 alt1&quot;&gt;
&lt;code class=&quot;csharp spaces&quot;&gt;        &lt;/code&gt;&lt;code class=&quot;csharp keyword&quot;&gt;return&lt;/code&gt; &lt;code class=&quot;csharp plain&quot;&gt;BitConverter.GetBytes((&lt;/code&gt;&lt;code class=&quot;csharp keyword&quot;&gt;int&lt;/code&gt;&lt;code class=&quot;csharp plain&quot;&gt;)0); &lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number39 index38 alt2&quot;&gt;
&lt;code class=&quot;csharp spaces&quot;&gt;    &lt;/code&gt;&lt;code class=&quot;csharp plain&quot;&gt;} &lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number40 index39 alt1&quot;&gt;
&lt;code class=&quot;csharp spaces&quot;&gt;  &lt;/code&gt; &lt;/div&gt;
&lt;div class=&quot;line number41 index40 alt2&quot;&gt;
&lt;code class=&quot;csharp spaces&quot;&gt;    &lt;/code&gt;&lt;code class=&quot;csharp color1&quot;&gt;/// &amp;lt;summary&amp;gt; &lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number42 index41 alt1&quot;&gt;
&lt;code class=&quot;csharp spaces&quot;&gt;    &lt;/code&gt;&lt;code class=&quot;csharp color1&quot;&gt;/// Initializes a new &amp;lt;see cref=&quot;PacketProtocol&quot;/&amp;gt;, limiting message sizes to the given maximum size. &lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number43 index42 alt2&quot;&gt;
&lt;code class=&quot;csharp spaces&quot;&gt;    &lt;/code&gt;&lt;code class=&quot;csharp color1&quot;&gt;/// &amp;lt;/summary&amp;gt; &lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number44 index43 alt1&quot;&gt;
&lt;code class=&quot;csharp spaces&quot;&gt;    &lt;/code&gt;&lt;code class=&quot;csharp color1&quot;&gt;/// &amp;lt;param name=&quot;maxMessageSize&quot;&amp;gt;The maximum message size supported by this protocol. This may be less than or equal to zero to indicate no maximum message size.&amp;lt;/param&amp;gt; &lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number45 index44 alt2&quot;&gt;
&lt;code class=&quot;csharp spaces&quot;&gt;    &lt;/code&gt;&lt;code class=&quot;csharp keyword&quot;&gt;public&lt;/code&gt; &lt;code class=&quot;csharp plain&quot;&gt;PacketProtocol(&lt;/code&gt;&lt;code class=&quot;csharp keyword&quot;&gt;int&lt;/code&gt; &lt;code class=&quot;csharp plain&quot;&gt;maxMessageSize) &lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number46 index45 alt1&quot;&gt;
&lt;code class=&quot;csharp spaces&quot;&gt;    &lt;/code&gt;&lt;code class=&quot;csharp plain&quot;&gt;{ &lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number47 index46 alt2&quot;&gt;
&lt;code class=&quot;csharp spaces&quot;&gt;        &lt;/code&gt;&lt;code class=&quot;csharp comments&quot;&gt;// We allocate the buffer for receiving message lengths immediately &lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number48 index47 alt1&quot;&gt;
&lt;code class=&quot;csharp spaces&quot;&gt;        &lt;/code&gt;&lt;code class=&quot;csharp keyword&quot;&gt;this&lt;/code&gt;&lt;code class=&quot;csharp plain&quot;&gt;.lengthBuffer = &lt;/code&gt;&lt;code class=&quot;csharp keyword&quot;&gt;new&lt;/code&gt; &lt;code class=&quot;csharp keyword&quot;&gt;byte&lt;/code&gt;&lt;code class=&quot;csharp plain&quot;&gt;[&lt;/code&gt;&lt;code class=&quot;csharp keyword&quot;&gt;sizeof&lt;/code&gt;&lt;code class=&quot;csharp plain&quot;&gt;(&lt;/code&gt;&lt;code class=&quot;csharp keyword&quot;&gt;int&lt;/code&gt;&lt;code class=&quot;csharp plain&quot;&gt;)]; &lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number49 index48 alt2&quot;&gt;
&lt;code class=&quot;csharp spaces&quot;&gt;        &lt;/code&gt;&lt;code class=&quot;csharp keyword&quot;&gt;this&lt;/code&gt;&lt;code class=&quot;csharp plain&quot;&gt;.maxMessageSize = maxMessageSize; &lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number50 index49 alt1&quot;&gt;
&lt;code class=&quot;csharp spaces&quot;&gt;    &lt;/code&gt;&lt;code class=&quot;csharp plain&quot;&gt;} &lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number51 index50 alt2&quot;&gt;
&lt;code class=&quot;csharp spaces&quot;&gt;  &lt;/code&gt; &lt;/div&gt;
&lt;div class=&quot;line number52 index51 alt1&quot;&gt;
&lt;code class=&quot;csharp spaces&quot;&gt;    &lt;/code&gt;&lt;code class=&quot;csharp color1&quot;&gt;/// &amp;lt;summary&amp;gt; &lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number53 index52 alt2&quot;&gt;
&lt;code class=&quot;csharp spaces&quot;&gt;    &lt;/code&gt;&lt;code class=&quot;csharp color1&quot;&gt;/// The buffer for the length prefix; this is always 4 bytes long. &lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number54 index53 alt1&quot;&gt;
&lt;code class=&quot;csharp spaces&quot;&gt;    &lt;/code&gt;&lt;code class=&quot;csharp color1&quot;&gt;/// &amp;lt;/summary&amp;gt; &lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number55 index54 alt2&quot;&gt;
&lt;code class=&quot;csharp spaces&quot;&gt;    &lt;/code&gt;&lt;code class=&quot;csharp keyword&quot;&gt;private&lt;/code&gt; &lt;code class=&quot;csharp keyword&quot;&gt;byte&lt;/code&gt;&lt;code class=&quot;csharp plain&quot;&gt;[] lengthBuffer; &lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number56 index55 alt1&quot;&gt;
&lt;code class=&quot;csharp spaces&quot;&gt;  &lt;/code&gt; &lt;/div&gt;
&lt;div class=&quot;line number57 index56 alt2&quot;&gt;
&lt;code class=&quot;csharp spaces&quot;&gt;    &lt;/code&gt;&lt;code class=&quot;csharp color1&quot;&gt;/// &amp;lt;summary&amp;gt; &lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number58 index57 alt1&quot;&gt;
&lt;code class=&quot;csharp spaces&quot;&gt;    &lt;/code&gt;&lt;code class=&quot;csharp color1&quot;&gt;/// The buffer for the data; this is null if we are receiving the length prefix buffer. &lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number59 index58 alt2&quot;&gt;
&lt;code class=&quot;csharp spaces&quot;&gt;    &lt;/code&gt;&lt;code class=&quot;csharp color1&quot;&gt;/// &amp;lt;/summary&amp;gt; &lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number60 index59 alt1&quot;&gt;
&lt;code class=&quot;csharp spaces&quot;&gt;    &lt;/code&gt;&lt;code class=&quot;csharp keyword&quot;&gt;private&lt;/code&gt; &lt;code class=&quot;csharp keyword&quot;&gt;byte&lt;/code&gt;&lt;code class=&quot;csharp plain&quot;&gt;[] dataBuffer; &lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number61 index60 alt2&quot;&gt;
&lt;code class=&quot;csharp spaces&quot;&gt;  &lt;/code&gt; &lt;/div&gt;
&lt;div class=&quot;line number62 index61 alt1&quot;&gt;
&lt;code class=&quot;csharp spaces&quot;&gt;    &lt;/code&gt;&lt;code class=&quot;csharp color1&quot;&gt;/// &amp;lt;summary&amp;gt; &lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number63 index62 alt2&quot;&gt;
&lt;code class=&quot;csharp spaces&quot;&gt;    &lt;/code&gt;&lt;code class=&quot;csharp color1&quot;&gt;/// The number of bytes already read into the buffer (the length buffer if &amp;lt;see cref=&quot;dataBuffer&quot;/&amp;gt; is null, otherwise the data buffer). &lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number64 index63 alt1&quot;&gt;
&lt;code class=&quot;csharp spaces&quot;&gt;    &lt;/code&gt;&lt;code class=&quot;csharp color1&quot;&gt;/// &amp;lt;/summary&amp;gt; &lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number65 index64 alt2&quot;&gt;
&lt;code class=&quot;csharp spaces&quot;&gt;    &lt;/code&gt;&lt;code class=&quot;csharp keyword&quot;&gt;private&lt;/code&gt; &lt;code class=&quot;csharp keyword&quot;&gt;int&lt;/code&gt; &lt;code class=&quot;csharp plain&quot;&gt;bytesReceived; &lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number66 index65 alt1&quot;&gt;
&lt;code class=&quot;csharp spaces&quot;&gt;  &lt;/code&gt; &lt;/div&gt;
&lt;div class=&quot;line number67 index66 alt2&quot;&gt;
&lt;code class=&quot;csharp spaces&quot;&gt;    &lt;/code&gt;&lt;code class=&quot;csharp color1&quot;&gt;/// &amp;lt;summary&amp;gt; &lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number68 index67 alt1&quot;&gt;
&lt;code class=&quot;csharp spaces&quot;&gt;    &lt;/code&gt;&lt;code class=&quot;csharp color1&quot;&gt;/// The maximum size of messages allowed. &lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number69 index68 alt2&quot;&gt;
&lt;code class=&quot;csharp spaces&quot;&gt;    &lt;/code&gt;&lt;code class=&quot;csharp color1&quot;&gt;/// &amp;lt;/summary&amp;gt; &lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number70 index69 alt1&quot;&gt;
&lt;code class=&quot;csharp spaces&quot;&gt;    &lt;/code&gt;&lt;code class=&quot;csharp keyword&quot;&gt;private&lt;/code&gt; &lt;code class=&quot;csharp keyword&quot;&gt;int&lt;/code&gt; &lt;code class=&quot;csharp plain&quot;&gt;maxMessageSize; &lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number71 index70 alt2&quot;&gt;
&lt;code class=&quot;csharp spaces&quot;&gt;  &lt;/code&gt; &lt;/div&gt;
&lt;div class=&quot;line number72 index71 alt1&quot;&gt;
&lt;code class=&quot;csharp spaces&quot;&gt;    &lt;/code&gt;&lt;code class=&quot;csharp color1&quot;&gt;/// &amp;lt;summary&amp;gt; &lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number73 index72 alt2&quot;&gt;
&lt;code class=&quot;csharp spaces&quot;&gt;    &lt;/code&gt;&lt;code class=&quot;csharp color1&quot;&gt;/// Indicates the completion of a message read from the stream. &lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number74 index73 alt1&quot;&gt;
&lt;code class=&quot;csharp spaces&quot;&gt;    &lt;/code&gt;&lt;code class=&quot;csharp color1&quot;&gt;/// &amp;lt;/summary&amp;gt; &lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number75 index74 alt2&quot;&gt;
&lt;code class=&quot;csharp spaces&quot;&gt;    &lt;/code&gt;&lt;code class=&quot;csharp color1&quot;&gt;/// &amp;lt;remarks&amp;gt; &lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number76 index75 alt1&quot;&gt;
&lt;code class=&quot;csharp spaces&quot;&gt;    &lt;/code&gt;&lt;code class=&quot;csharp color1&quot;&gt;/// &amp;lt;para&amp;gt;This may be called with an empty message, indicating that the other end had sent a keepalive message. This will never be called with a null message.&amp;lt;/para&amp;gt; &lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number77 index76 alt2&quot;&gt;
&lt;code class=&quot;csharp spaces&quot;&gt;    &lt;/code&gt;&lt;code class=&quot;csharp color1&quot;&gt;/// &amp;lt;para&amp;gt;This event is invoked from within a call to &amp;lt;see cref=&quot;DataReceived&quot;/&amp;gt;. Handlers for this event should not call &amp;lt;see cref=&quot;DataReceived&quot;/&amp;gt;.&amp;lt;/para&amp;gt; &lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number78 index77 alt1&quot;&gt;
&lt;code class=&quot;csharp spaces&quot;&gt;    &lt;/code&gt;&lt;code class=&quot;csharp color1&quot;&gt;/// &amp;lt;/remarks&amp;gt; &lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number79 index78 alt2&quot;&gt;
&lt;code class=&quot;csharp spaces&quot;&gt;    &lt;/code&gt;&lt;code class=&quot;csharp keyword&quot;&gt;public&lt;/code&gt; &lt;code class=&quot;csharp plain&quot;&gt;Action&amp;lt;&lt;/code&gt;&lt;code class=&quot;csharp keyword&quot;&gt;byte&lt;/code&gt;&lt;code class=&quot;csharp plain&quot;&gt;[]&amp;gt; MessageArrived { &lt;/code&gt;&lt;code class=&quot;csharp keyword&quot;&gt;get&lt;/code&gt;&lt;code class=&quot;csharp plain&quot;&gt;; &lt;/code&gt;&lt;code class=&quot;csharp keyword&quot;&gt;set&lt;/code&gt;&lt;code class=&quot;csharp plain&quot;&gt;; } &lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number80 index79 alt1&quot;&gt;
&lt;code class=&quot;csharp spaces&quot;&gt;  &lt;/code&gt; &lt;/div&gt;
&lt;div class=&quot;line number81 index80 alt2&quot;&gt;
&lt;code class=&quot;csharp spaces&quot;&gt;    &lt;/code&gt;&lt;code class=&quot;csharp color1&quot;&gt;/// &amp;lt;summary&amp;gt; &lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number82 index81 alt1&quot;&gt;
&lt;code class=&quot;csharp spaces&quot;&gt;    &lt;/code&gt;&lt;code class=&quot;csharp color1&quot;&gt;/// Notifies the &amp;lt;see cref=&quot;PacketProtocol&quot;/&amp;gt; instance that incoming data has been received from the stream. This method will invoke &amp;lt;see cref=&quot;MessageArrived&quot;/&amp;gt; as necessary. &lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number83 index82 alt2&quot;&gt;
&lt;code class=&quot;csharp spaces&quot;&gt;    &lt;/code&gt;&lt;code class=&quot;csharp color1&quot;&gt;/// &amp;lt;/summary&amp;gt; &lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number84 index83 alt1&quot;&gt;
&lt;code class=&quot;csharp spaces&quot;&gt;    &lt;/code&gt;&lt;code class=&quot;csharp color1&quot;&gt;/// &amp;lt;remarks&amp;gt; &lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number85 index84 alt2&quot;&gt;
&lt;code class=&quot;csharp spaces&quot;&gt;    &lt;/code&gt;&lt;code class=&quot;csharp color1&quot;&gt;/// &amp;lt;para&amp;gt;This method may invoke &amp;lt;see cref=&quot;MessageArrived&quot;/&amp;gt; zero or more times.&amp;lt;/para&amp;gt; &lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number86 index85 alt1&quot;&gt;
&lt;code class=&quot;csharp spaces&quot;&gt;    &lt;/code&gt;&lt;code class=&quot;csharp color1&quot;&gt;/// &amp;lt;para&amp;gt;Zero-length receives are ignored. Many streams use a 0-length read to indicate the end of a stream, but &amp;lt;see cref=&quot;PacketProtocol&quot;/&amp;gt; takes no action in this case.&amp;lt;/para&amp;gt; &lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number87 index86 alt2&quot;&gt;
&lt;code class=&quot;csharp spaces&quot;&gt;    &lt;/code&gt;&lt;code class=&quot;csharp color1&quot;&gt;/// &amp;lt;/remarks&amp;gt; &lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number88 index87 alt1&quot;&gt;
&lt;code class=&quot;csharp spaces&quot;&gt;    &lt;/code&gt;&lt;code class=&quot;csharp color1&quot;&gt;/// &amp;lt;param name=&quot;data&quot;&amp;gt;The data received from the stream. Cannot be null.&amp;lt;/param&amp;gt; &lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number89 index88 alt2&quot;&gt;
&lt;code class=&quot;csharp spaces&quot;&gt;    &lt;/code&gt;&lt;code class=&quot;csharp color1&quot;&gt;/// &amp;lt;exception cref=&quot;System.Net.ProtocolViolationException&quot;&amp;gt;If the data received is not a properly-formed message.&amp;lt;/exception&amp;gt; &lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number90 index89 alt1&quot;&gt;
&lt;code class=&quot;csharp spaces&quot;&gt;    &lt;/code&gt;&lt;code class=&quot;csharp keyword&quot;&gt;public&lt;/code&gt; &lt;code class=&quot;csharp keyword&quot;&gt;void&lt;/code&gt; &lt;code class=&quot;csharp plain&quot;&gt;DataReceived(&lt;/code&gt;&lt;code class=&quot;csharp keyword&quot;&gt;byte&lt;/code&gt;&lt;code class=&quot;csharp plain&quot;&gt;[] data) &lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number91 index90 alt2&quot;&gt;
&lt;code class=&quot;csharp spaces&quot;&gt;    &lt;/code&gt;&lt;code class=&quot;csharp plain&quot;&gt;{ &lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number92 index91 alt1&quot;&gt;
&lt;code class=&quot;csharp spaces&quot;&gt;        &lt;/code&gt;&lt;code class=&quot;csharp comments&quot;&gt;// Process the incoming data in chunks, as the ReadCompleted requests it &lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number93 index92 alt2&quot;&gt;
&lt;code class=&quot;csharp spaces&quot;&gt;  &lt;/code&gt; &lt;/div&gt;
&lt;div class=&quot;line number94 index93 alt1&quot;&gt;
&lt;code class=&quot;csharp spaces&quot;&gt;        &lt;/code&gt;&lt;code class=&quot;csharp comments&quot;&gt;// Logically, we are satisfying read requests with the received data, instead of processing the &lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number95 index94 alt2&quot;&gt;
&lt;code class=&quot;csharp spaces&quot;&gt;        &lt;/code&gt;&lt;code class=&quot;csharp comments&quot;&gt;//  incoming buffer looking for messages. &lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number96 index95 alt1&quot;&gt;
&lt;code class=&quot;csharp spaces&quot;&gt;  &lt;/code&gt; &lt;/div&gt;
&lt;div class=&quot;line number97 index96 alt2&quot;&gt;
&lt;code class=&quot;csharp spaces&quot;&gt;        &lt;/code&gt;&lt;code class=&quot;csharp keyword&quot;&gt;int&lt;/code&gt; &lt;code class=&quot;csharp plain&quot;&gt;i = 0; &lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number98 index97 alt1&quot;&gt;
&lt;code class=&quot;csharp spaces&quot;&gt;        &lt;/code&gt;&lt;code class=&quot;csharp keyword&quot;&gt;while&lt;/code&gt; &lt;code class=&quot;csharp plain&quot;&gt;(i != data.Length) &lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number99 index98 alt2&quot;&gt;
&lt;code class=&quot;csharp spaces&quot;&gt;        &lt;/code&gt;&lt;code class=&quot;csharp plain&quot;&gt;{ &lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number100 index99 alt1&quot;&gt;
&lt;code class=&quot;csharp spaces&quot;&gt;            &lt;/code&gt;&lt;code class=&quot;csharp comments&quot;&gt;// Determine how many bytes we want to transfer to the buffer and transfer them &lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number101 index100 alt2&quot;&gt;
&lt;code class=&quot;csharp spaces&quot;&gt;            &lt;/code&gt;&lt;code class=&quot;csharp keyword&quot;&gt;int&lt;/code&gt; &lt;code class=&quot;csharp plain&quot;&gt;bytesAvailable = data.Length - i; &lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number102 index101 alt1&quot;&gt;
&lt;code class=&quot;csharp spaces&quot;&gt;            &lt;/code&gt;&lt;code class=&quot;csharp keyword&quot;&gt;if&lt;/code&gt; &lt;code class=&quot;csharp plain&quot;&gt;(&lt;/code&gt;&lt;code class=&quot;csharp keyword&quot;&gt;this&lt;/code&gt;&lt;code class=&quot;csharp plain&quot;&gt;.dataBuffer != &lt;/code&gt;&lt;code class=&quot;csharp keyword&quot;&gt;null&lt;/code&gt;&lt;code class=&quot;csharp plain&quot;&gt;) &lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number103 index102 alt2&quot;&gt;
&lt;code class=&quot;csharp spaces&quot;&gt;            &lt;/code&gt;&lt;code class=&quot;csharp plain&quot;&gt;{ &lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number104 index103 alt1&quot;&gt;
&lt;code class=&quot;csharp spaces&quot;&gt;                &lt;/code&gt;&lt;code class=&quot;csharp comments&quot;&gt;// We&#39;re reading into the data buffer &lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number105 index104 alt2&quot;&gt;
&lt;code class=&quot;csharp spaces&quot;&gt;                &lt;/code&gt;&lt;code class=&quot;csharp keyword&quot;&gt;int&lt;/code&gt; &lt;code class=&quot;csharp plain&quot;&gt;bytesRequested = &lt;/code&gt;&lt;code class=&quot;csharp keyword&quot;&gt;this&lt;/code&gt;&lt;code class=&quot;csharp plain&quot;&gt;.dataBuffer.Length - &lt;/code&gt;&lt;code class=&quot;csharp keyword&quot;&gt;this&lt;/code&gt;&lt;code class=&quot;csharp plain&quot;&gt;.bytesReceived; &lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number106 index105 alt1&quot;&gt;
&lt;code class=&quot;csharp spaces&quot;&gt;  &lt;/code&gt; &lt;/div&gt;
&lt;div class=&quot;line number107 index106 alt2&quot;&gt;
&lt;code class=&quot;csharp spaces&quot;&gt;                &lt;/code&gt;&lt;code class=&quot;csharp comments&quot;&gt;// Copy the incoming bytes into the buffer &lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number108 index107 alt1&quot;&gt;
&lt;code class=&quot;csharp spaces&quot;&gt;                &lt;/code&gt;&lt;code class=&quot;csharp keyword&quot;&gt;int&lt;/code&gt; &lt;code class=&quot;csharp plain&quot;&gt;bytesTransferred = Math.Min(bytesRequested, bytesAvailable); &lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number109 index108 alt2&quot;&gt;
&lt;code class=&quot;csharp spaces&quot;&gt;                &lt;/code&gt;&lt;code class=&quot;csharp plain&quot;&gt;Array.Copy(data, i, &lt;/code&gt;&lt;code class=&quot;csharp keyword&quot;&gt;this&lt;/code&gt;&lt;code class=&quot;csharp plain&quot;&gt;.dataBuffer, &lt;/code&gt;&lt;code class=&quot;csharp keyword&quot;&gt;this&lt;/code&gt;&lt;code class=&quot;csharp plain&quot;&gt;.bytesReceived, bytesTransferred); &lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number110 index109 alt1&quot;&gt;
&lt;code class=&quot;csharp spaces&quot;&gt;                &lt;/code&gt;&lt;code class=&quot;csharp plain&quot;&gt;i += bytesTransferred; &lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number111 index110 alt2&quot;&gt;
&lt;code class=&quot;csharp spaces&quot;&gt;  &lt;/code&gt; &lt;/div&gt;
&lt;div class=&quot;line number112 index111 alt1&quot;&gt;
&lt;code class=&quot;csharp spaces&quot;&gt;                &lt;/code&gt;&lt;code class=&quot;csharp comments&quot;&gt;// Notify &quot;read completion&quot; &lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number113 index112 alt2&quot;&gt;
&lt;code class=&quot;csharp spaces&quot;&gt;                &lt;/code&gt;&lt;code class=&quot;csharp keyword&quot;&gt;this&lt;/code&gt;&lt;code class=&quot;csharp plain&quot;&gt;.ReadCompleted(bytesTransferred); &lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number114 index113 alt1&quot;&gt;
&lt;code class=&quot;csharp spaces&quot;&gt;            &lt;/code&gt;&lt;code class=&quot;csharp plain&quot;&gt;} &lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number115 index114 alt2&quot;&gt;
&lt;code class=&quot;csharp spaces&quot;&gt;            &lt;/code&gt;&lt;code class=&quot;csharp keyword&quot;&gt;else&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number116 index115 alt1&quot;&gt;
&lt;code class=&quot;csharp spaces&quot;&gt;            &lt;/code&gt;&lt;code class=&quot;csharp plain&quot;&gt;{ &lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number117 index116 alt2&quot;&gt;
&lt;code class=&quot;csharp spaces&quot;&gt;                &lt;/code&gt;&lt;code class=&quot;csharp comments&quot;&gt;// We&#39;re reading into the length prefix buffer &lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number118 index117 alt1&quot;&gt;
&lt;code class=&quot;csharp spaces&quot;&gt;                &lt;/code&gt;&lt;code class=&quot;csharp keyword&quot;&gt;int&lt;/code&gt; &lt;code class=&quot;csharp plain&quot;&gt;bytesRequested = &lt;/code&gt;&lt;code class=&quot;csharp keyword&quot;&gt;this&lt;/code&gt;&lt;code class=&quot;csharp plain&quot;&gt;.lengthBuffer.Length - &lt;/code&gt;&lt;code class=&quot;csharp keyword&quot;&gt;this&lt;/code&gt;&lt;code class=&quot;csharp plain&quot;&gt;.bytesReceived; &lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number119 index118 alt2&quot;&gt;
&lt;code class=&quot;csharp spaces&quot;&gt;  &lt;/code&gt; &lt;/div&gt;
&lt;div class=&quot;line number120 index119 alt1&quot;&gt;
&lt;code class=&quot;csharp spaces&quot;&gt;                &lt;/code&gt;&lt;code class=&quot;csharp comments&quot;&gt;// Copy the incoming bytes into the buffer &lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number121 index120 alt2&quot;&gt;
&lt;code class=&quot;csharp spaces&quot;&gt;                &lt;/code&gt;&lt;code class=&quot;csharp keyword&quot;&gt;int&lt;/code&gt; &lt;code class=&quot;csharp plain&quot;&gt;bytesTransferred = Math.Min(bytesRequested, bytesAvailable); &lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number122 index121 alt1&quot;&gt;
&lt;code class=&quot;csharp spaces&quot;&gt;                &lt;/code&gt;&lt;code class=&quot;csharp plain&quot;&gt;Array.Copy(data, i, &lt;/code&gt;&lt;code class=&quot;csharp keyword&quot;&gt;this&lt;/code&gt;&lt;code class=&quot;csharp plain&quot;&gt;.lengthBuffer, &lt;/code&gt;&lt;code class=&quot;csharp keyword&quot;&gt;this&lt;/code&gt;&lt;code class=&quot;csharp plain&quot;&gt;.bytesReceived, bytesTransferred); &lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number123 index122 alt2&quot;&gt;
&lt;code class=&quot;csharp spaces&quot;&gt;                &lt;/code&gt;&lt;code class=&quot;csharp plain&quot;&gt;i += bytesTransferred; &lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number124 index123 alt1&quot;&gt;
&lt;code class=&quot;csharp spaces&quot;&gt;  &lt;/code&gt; &lt;/div&gt;
&lt;div class=&quot;line number125 index124 alt2&quot;&gt;
&lt;code class=&quot;csharp spaces&quot;&gt;                &lt;/code&gt;&lt;code class=&quot;csharp comments&quot;&gt;// Notify &quot;read completion&quot; &lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number126 index125 alt1&quot;&gt;
&lt;code class=&quot;csharp spaces&quot;&gt;                &lt;/code&gt;&lt;code class=&quot;csharp keyword&quot;&gt;this&lt;/code&gt;&lt;code class=&quot;csharp plain&quot;&gt;.ReadCompleted(bytesTransferred); &lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number127 index126 alt2&quot;&gt;
&lt;code class=&quot;csharp spaces&quot;&gt;            &lt;/code&gt;&lt;code class=&quot;csharp plain&quot;&gt;} &lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number128 index127 alt1&quot;&gt;
&lt;code class=&quot;csharp spaces&quot;&gt;        &lt;/code&gt;&lt;code class=&quot;csharp plain&quot;&gt;} &lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number129 index128 alt2&quot;&gt;
&lt;code class=&quot;csharp spaces&quot;&gt;    &lt;/code&gt;&lt;code class=&quot;csharp plain&quot;&gt;} &lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number130 index129 alt1&quot;&gt;
&lt;code class=&quot;csharp spaces&quot;&gt;  &lt;/code&gt; &lt;/div&gt;
&lt;div class=&quot;line number131 index130 alt2&quot;&gt;
&lt;code class=&quot;csharp spaces&quot;&gt;    &lt;/code&gt;&lt;code class=&quot;csharp color1&quot;&gt;/// &amp;lt;summary&amp;gt; &lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number132 index131 alt1&quot;&gt;
&lt;code class=&quot;csharp spaces&quot;&gt;    &lt;/code&gt;&lt;code class=&quot;csharp color1&quot;&gt;/// Called when a read completes. Parses the received data and calls &amp;lt;see cref=&quot;MessageArrived&quot;/&amp;gt; if necessary. &lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number133 index132 alt2&quot;&gt;
&lt;code class=&quot;csharp spaces&quot;&gt;    &lt;/code&gt;&lt;code class=&quot;csharp color1&quot;&gt;/// &amp;lt;/summary&amp;gt; &lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number134 index133 alt1&quot;&gt;
&lt;code class=&quot;csharp spaces&quot;&gt;    &lt;/code&gt;&lt;code class=&quot;csharp color1&quot;&gt;/// &amp;lt;param name=&quot;count&quot;&amp;gt;The number of bytes read.&amp;lt;/param&amp;gt; &lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number135 index134 alt2&quot;&gt;
&lt;code class=&quot;csharp spaces&quot;&gt;    &lt;/code&gt;&lt;code class=&quot;csharp color1&quot;&gt;/// &amp;lt;exception cref=&quot;System.Net.ProtocolViolationException&quot;&amp;gt;If the data received is not a properly-formed message.&amp;lt;/exception&amp;gt; &lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number136 index135 alt1&quot;&gt;
&lt;code class=&quot;csharp spaces&quot;&gt;    &lt;/code&gt;&lt;code class=&quot;csharp keyword&quot;&gt;private&lt;/code&gt; &lt;code class=&quot;csharp keyword&quot;&gt;void&lt;/code&gt; &lt;code class=&quot;csharp plain&quot;&gt;ReadCompleted(&lt;/code&gt;&lt;code class=&quot;csharp keyword&quot;&gt;int&lt;/code&gt; &lt;code class=&quot;csharp plain&quot;&gt;count) &lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number137 index136 alt2&quot;&gt;
&lt;code class=&quot;csharp spaces&quot;&gt;    &lt;/code&gt;&lt;code class=&quot;csharp plain&quot;&gt;{ &lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number138 index137 alt1&quot;&gt;
&lt;code class=&quot;csharp spaces&quot;&gt;        &lt;/code&gt;&lt;code class=&quot;csharp comments&quot;&gt;// Get the number of bytes read into the buffer &lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number139 index138 alt2&quot;&gt;
&lt;code class=&quot;csharp spaces&quot;&gt;        &lt;/code&gt;&lt;code class=&quot;csharp keyword&quot;&gt;this&lt;/code&gt;&lt;code class=&quot;csharp plain&quot;&gt;.bytesReceived += count; &lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number140 index139 alt1&quot;&gt;
&lt;code class=&quot;csharp spaces&quot;&gt;  &lt;/code&gt; &lt;/div&gt;
&lt;div class=&quot;line number141 index140 alt2&quot;&gt;
&lt;code class=&quot;csharp spaces&quot;&gt;        &lt;/code&gt;&lt;code class=&quot;csharp keyword&quot;&gt;if&lt;/code&gt; &lt;code class=&quot;csharp plain&quot;&gt;(&lt;/code&gt;&lt;code class=&quot;csharp keyword&quot;&gt;this&lt;/code&gt;&lt;code class=&quot;csharp plain&quot;&gt;.dataBuffer == &lt;/code&gt;&lt;code class=&quot;csharp keyword&quot;&gt;null&lt;/code&gt;&lt;code class=&quot;csharp plain&quot;&gt;) &lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number142 index141 alt1&quot;&gt;
&lt;code class=&quot;csharp spaces&quot;&gt;        &lt;/code&gt;&lt;code class=&quot;csharp plain&quot;&gt;{ &lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number143 index142 alt2&quot;&gt;
&lt;code class=&quot;csharp spaces&quot;&gt;            &lt;/code&gt;&lt;code class=&quot;csharp comments&quot;&gt;// We&#39;re currently receiving the length buffer &lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number144 index143 alt1&quot;&gt;
&lt;code class=&quot;csharp spaces&quot;&gt;  &lt;/code&gt; &lt;/div&gt;
&lt;div class=&quot;line number145 index144 alt2&quot;&gt;
&lt;code class=&quot;csharp spaces&quot;&gt;            &lt;/code&gt;&lt;code class=&quot;csharp keyword&quot;&gt;if&lt;/code&gt; &lt;code class=&quot;csharp plain&quot;&gt;(&lt;/code&gt;&lt;code class=&quot;csharp keyword&quot;&gt;this&lt;/code&gt;&lt;code class=&quot;csharp plain&quot;&gt;.bytesReceived != &lt;/code&gt;&lt;code class=&quot;csharp keyword&quot;&gt;sizeof&lt;/code&gt;&lt;code class=&quot;csharp plain&quot;&gt;(&lt;/code&gt;&lt;code class=&quot;csharp keyword&quot;&gt;int&lt;/code&gt;&lt;code class=&quot;csharp plain&quot;&gt;)) &lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number146 index145 alt1&quot;&gt;
&lt;code class=&quot;csharp spaces&quot;&gt;            &lt;/code&gt;&lt;code class=&quot;csharp plain&quot;&gt;{ &lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number147 index146 alt2&quot;&gt;
&lt;code class=&quot;csharp spaces&quot;&gt;                &lt;/code&gt;&lt;code class=&quot;csharp comments&quot;&gt;// We haven&#39;t gotten all the length buffer yet: just wait for more data to arrive &lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number148 index147 alt1&quot;&gt;
&lt;code class=&quot;csharp spaces&quot;&gt;            &lt;/code&gt;&lt;code class=&quot;csharp plain&quot;&gt;} &lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number149 index148 alt2&quot;&gt;
&lt;code class=&quot;csharp spaces&quot;&gt;            &lt;/code&gt;&lt;code class=&quot;csharp keyword&quot;&gt;else&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number150 index149 alt1&quot;&gt;
&lt;code class=&quot;csharp spaces&quot;&gt;            &lt;/code&gt;&lt;code class=&quot;csharp plain&quot;&gt;{ &lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number151 index150 alt2&quot;&gt;
&lt;code class=&quot;csharp spaces&quot;&gt;                &lt;/code&gt;&lt;code class=&quot;csharp comments&quot;&gt;// We&#39;ve gotten the length buffer &lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number152 index151 alt1&quot;&gt;
&lt;code class=&quot;csharp spaces&quot;&gt;                &lt;/code&gt;&lt;code class=&quot;csharp keyword&quot;&gt;int&lt;/code&gt; &lt;code class=&quot;csharp plain&quot;&gt;length = BitConverter.ToInt32(&lt;/code&gt;&lt;code class=&quot;csharp keyword&quot;&gt;this&lt;/code&gt;&lt;code class=&quot;csharp plain&quot;&gt;.lengthBuffer, 0); &lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number153 index152 alt2&quot;&gt;
&lt;code class=&quot;csharp spaces&quot;&gt;  &lt;/code&gt; &lt;/div&gt;
&lt;div class=&quot;line number154 index153 alt1&quot;&gt;
&lt;code class=&quot;csharp spaces&quot;&gt;                &lt;/code&gt;&lt;code class=&quot;csharp comments&quot;&gt;// Sanity check for length &amp;lt; 0 &lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number155 index154 alt2&quot;&gt;
&lt;code class=&quot;csharp spaces&quot;&gt;                &lt;/code&gt;&lt;code class=&quot;csharp keyword&quot;&gt;if&lt;/code&gt; &lt;code class=&quot;csharp plain&quot;&gt;(length &amp;lt; 0) &lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number156 index155 alt1&quot;&gt;
&lt;code class=&quot;csharp spaces&quot;&gt;                    &lt;/code&gt;&lt;code class=&quot;csharp keyword&quot;&gt;throw&lt;/code&gt; &lt;code class=&quot;csharp keyword&quot;&gt;new&lt;/code&gt; &lt;code class=&quot;csharp plain&quot;&gt;System.Net.ProtocolViolationException(&lt;/code&gt;&lt;code class=&quot;csharp string&quot;&gt;&quot;Message length is less than zero&quot;&lt;/code&gt;&lt;code class=&quot;csharp plain&quot;&gt;); &lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number157 index156 alt2&quot;&gt;
&lt;code class=&quot;csharp spaces&quot;&gt;  &lt;/code&gt; &lt;/div&gt;
&lt;div class=&quot;line number158 index157 alt1&quot;&gt;
&lt;code class=&quot;csharp spaces&quot;&gt;                &lt;/code&gt;&lt;code class=&quot;csharp comments&quot;&gt;// Another sanity check is needed here for very large packets, to prevent denial-of-service attacks &lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number159 index158 alt2&quot;&gt;
&lt;code class=&quot;csharp spaces&quot;&gt;                &lt;/code&gt;&lt;code class=&quot;csharp keyword&quot;&gt;if&lt;/code&gt; &lt;code class=&quot;csharp plain&quot;&gt;(&lt;/code&gt;&lt;code class=&quot;csharp keyword&quot;&gt;this&lt;/code&gt;&lt;code class=&quot;csharp plain&quot;&gt;.maxMessageSize &amp;gt; 0 &amp;amp;&amp;amp; length &amp;gt; &lt;/code&gt;&lt;code class=&quot;csharp keyword&quot;&gt;this&lt;/code&gt;&lt;code class=&quot;csharp plain&quot;&gt;.maxMessageSize) &lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number160 index159 alt1&quot;&gt;
&lt;code class=&quot;csharp spaces&quot;&gt;                    &lt;/code&gt;&lt;code class=&quot;csharp keyword&quot;&gt;throw&lt;/code&gt; &lt;code class=&quot;csharp keyword&quot;&gt;new&lt;/code&gt; &lt;code class=&quot;csharp plain&quot;&gt;System.Net.ProtocolViolationException(&lt;/code&gt;&lt;code class=&quot;csharp string&quot;&gt;&quot;Message length &quot;&lt;/code&gt; &lt;code class=&quot;csharp plain&quot;&gt;+ length.ToString(System.Globalization.CultureInfo.InvariantCulture) + &lt;/code&gt;&lt;code class=&quot;csharp string&quot;&gt;&quot; is larger than maximum message size &quot;&lt;/code&gt; &lt;code class=&quot;csharp plain&quot;&gt;+ &lt;/code&gt;&lt;code class=&quot;csharp keyword&quot;&gt;this&lt;/code&gt;&lt;code class=&quot;csharp plain&quot;&gt;.maxMessageSize.ToString(System.Globalization.CultureInfo.InvariantCulture)); &lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number161 index160 alt2&quot;&gt;
&lt;code class=&quot;csharp spaces&quot;&gt;  &lt;/code&gt; &lt;/div&gt;
&lt;div class=&quot;line number162 index161 alt1&quot;&gt;
&lt;code class=&quot;csharp spaces&quot;&gt;                &lt;/code&gt;&lt;code class=&quot;csharp comments&quot;&gt;// Zero-length packets are allowed as keepalives &lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number163 index162 alt2&quot;&gt;
&lt;code class=&quot;csharp spaces&quot;&gt;                &lt;/code&gt;&lt;code class=&quot;csharp keyword&quot;&gt;if&lt;/code&gt; &lt;code class=&quot;csharp plain&quot;&gt;(length == 0) &lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number164 index163 alt1&quot;&gt;
&lt;code class=&quot;csharp spaces&quot;&gt;                &lt;/code&gt;&lt;code class=&quot;csharp plain&quot;&gt;{ &lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number165 index164 alt2&quot;&gt;
&lt;code class=&quot;csharp spaces&quot;&gt;                    &lt;/code&gt;&lt;code class=&quot;csharp keyword&quot;&gt;this&lt;/code&gt;&lt;code class=&quot;csharp plain&quot;&gt;.bytesReceived = 0; &lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number166 index165 alt1&quot;&gt;
&lt;code class=&quot;csharp spaces&quot;&gt;                    &lt;/code&gt;&lt;code class=&quot;csharp keyword&quot;&gt;if&lt;/code&gt; &lt;code class=&quot;csharp plain&quot;&gt;(&lt;/code&gt;&lt;code class=&quot;csharp keyword&quot;&gt;this&lt;/code&gt;&lt;code class=&quot;csharp plain&quot;&gt;.MessageArrived != &lt;/code&gt;&lt;code class=&quot;csharp keyword&quot;&gt;null&lt;/code&gt;&lt;code class=&quot;csharp plain&quot;&gt;) &lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number167 index166 alt2&quot;&gt;
&lt;code class=&quot;csharp spaces&quot;&gt;                        &lt;/code&gt;&lt;code class=&quot;csharp keyword&quot;&gt;this&lt;/code&gt;&lt;code class=&quot;csharp plain&quot;&gt;.MessageArrived(&lt;/code&gt;&lt;code class=&quot;csharp keyword&quot;&gt;new&lt;/code&gt; &lt;code class=&quot;csharp keyword&quot;&gt;byte&lt;/code&gt;&lt;code class=&quot;csharp plain&quot;&gt;[0]); &lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number168 index167 alt1&quot;&gt;
&lt;code class=&quot;csharp spaces&quot;&gt;                &lt;/code&gt;&lt;code class=&quot;csharp plain&quot;&gt;} &lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number169 index168 alt2&quot;&gt;
&lt;code class=&quot;csharp spaces&quot;&gt;                &lt;/code&gt;&lt;code class=&quot;csharp keyword&quot;&gt;else&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number170 index169 alt1&quot;&gt;
&lt;code class=&quot;csharp spaces&quot;&gt;                &lt;/code&gt;&lt;code class=&quot;csharp plain&quot;&gt;{ &lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number171 index170 alt2&quot;&gt;
&lt;code class=&quot;csharp spaces&quot;&gt;                    &lt;/code&gt;&lt;code class=&quot;csharp comments&quot;&gt;// Create the data buffer and start reading into it &lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number172 index171 alt1&quot;&gt;
&lt;code class=&quot;csharp spaces&quot;&gt;                    &lt;/code&gt;&lt;code class=&quot;csharp keyword&quot;&gt;this&lt;/code&gt;&lt;code class=&quot;csharp plain&quot;&gt;.dataBuffer = &lt;/code&gt;&lt;code class=&quot;csharp keyword&quot;&gt;new&lt;/code&gt; &lt;code class=&quot;csharp keyword&quot;&gt;byte&lt;/code&gt;&lt;code class=&quot;csharp plain&quot;&gt;[length]; &lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number173 index172 alt2&quot;&gt;
&lt;code class=&quot;csharp spaces&quot;&gt;                    &lt;/code&gt;&lt;code class=&quot;csharp keyword&quot;&gt;this&lt;/code&gt;&lt;code class=&quot;csharp plain&quot;&gt;.bytesReceived = 0; &lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number174 index173 alt1&quot;&gt;
&lt;code class=&quot;csharp spaces&quot;&gt;                &lt;/code&gt;&lt;code class=&quot;csharp plain&quot;&gt;} &lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number175 index174 alt2&quot;&gt;
&lt;code class=&quot;csharp spaces&quot;&gt;            &lt;/code&gt;&lt;code class=&quot;csharp plain&quot;&gt;} &lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number176 index175 alt1&quot;&gt;
&lt;code class=&quot;csharp spaces&quot;&gt;        &lt;/code&gt;&lt;code class=&quot;csharp plain&quot;&gt;} &lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number177 index176 alt2&quot;&gt;
&lt;code class=&quot;csharp spaces&quot;&gt;        &lt;/code&gt;&lt;code class=&quot;csharp keyword&quot;&gt;else&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number178 index177 alt1&quot;&gt;
&lt;code class=&quot;csharp spaces&quot;&gt;        &lt;/code&gt;&lt;code class=&quot;csharp plain&quot;&gt;{ &lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number179 index178 alt2&quot;&gt;
&lt;code class=&quot;csharp spaces&quot;&gt;            &lt;/code&gt;&lt;code class=&quot;csharp keyword&quot;&gt;if&lt;/code&gt; &lt;code class=&quot;csharp plain&quot;&gt;(&lt;/code&gt;&lt;code class=&quot;csharp keyword&quot;&gt;this&lt;/code&gt;&lt;code class=&quot;csharp plain&quot;&gt;.bytesReceived != &lt;/code&gt;&lt;code class=&quot;csharp keyword&quot;&gt;this&lt;/code&gt;&lt;code class=&quot;csharp plain&quot;&gt;.dataBuffer.Length) &lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number180 index179 alt1&quot;&gt;
&lt;code class=&quot;csharp spaces&quot;&gt;            &lt;/code&gt;&lt;code class=&quot;csharp plain&quot;&gt;{ &lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number181 index180 alt2&quot;&gt;
&lt;code class=&quot;csharp spaces&quot;&gt;                &lt;/code&gt;&lt;code class=&quot;csharp comments&quot;&gt;// We haven&#39;t gotten all the data buffer yet: just wait for more data to arrive &lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number182 index181 alt1&quot;&gt;
&lt;code class=&quot;csharp spaces&quot;&gt;            &lt;/code&gt;&lt;code class=&quot;csharp plain&quot;&gt;} &lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number183 index182 alt2&quot;&gt;
&lt;code class=&quot;csharp spaces&quot;&gt;            &lt;/code&gt;&lt;code class=&quot;csharp keyword&quot;&gt;else&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number184 index183 alt1&quot;&gt;
&lt;code class=&quot;csharp spaces&quot;&gt;            &lt;/code&gt;&lt;code class=&quot;csharp plain&quot;&gt;{ &lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number185 index184 alt2&quot;&gt;
&lt;code class=&quot;csharp spaces&quot;&gt;                &lt;/code&gt;&lt;code class=&quot;csharp comments&quot;&gt;// We&#39;ve gotten an entire packet &lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number186 index185 alt1&quot;&gt;
&lt;code class=&quot;csharp spaces&quot;&gt;                &lt;/code&gt;&lt;code class=&quot;csharp keyword&quot;&gt;if&lt;/code&gt; &lt;code class=&quot;csharp plain&quot;&gt;(&lt;/code&gt;&lt;code class=&quot;csharp keyword&quot;&gt;this&lt;/code&gt;&lt;code class=&quot;csharp plain&quot;&gt;.MessageArrived != &lt;/code&gt;&lt;code class=&quot;csharp keyword&quot;&gt;null&lt;/code&gt;&lt;code class=&quot;csharp plain&quot;&gt;) &lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number187 index186 alt2&quot;&gt;
&lt;code class=&quot;csharp spaces&quot;&gt;                    &lt;/code&gt;&lt;code class=&quot;csharp keyword&quot;&gt;this&lt;/code&gt;&lt;code class=&quot;csharp plain&quot;&gt;.MessageArrived(&lt;/code&gt;&lt;code class=&quot;csharp keyword&quot;&gt;this&lt;/code&gt;&lt;code class=&quot;csharp plain&quot;&gt;.dataBuffer); &lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number188 index187 alt1&quot;&gt;
&lt;code class=&quot;csharp spaces&quot;&gt;  &lt;/code&gt; &lt;/div&gt;
&lt;div class=&quot;line number189 index188 alt2&quot;&gt;
&lt;code class=&quot;csharp spaces&quot;&gt;                &lt;/code&gt;&lt;code class=&quot;csharp comments&quot;&gt;// Start reading the length buffer again &lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number190 index189 alt1&quot;&gt;
&lt;code class=&quot;csharp spaces&quot;&gt;                &lt;/code&gt;&lt;code class=&quot;csharp keyword&quot;&gt;this&lt;/code&gt;&lt;code class=&quot;csharp plain&quot;&gt;.dataBuffer = &lt;/code&gt;&lt;code class=&quot;csharp keyword&quot;&gt;null&lt;/code&gt;&lt;code class=&quot;csharp plain&quot;&gt;; &lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number191 index190 alt2&quot;&gt;
&lt;code class=&quot;csharp spaces&quot;&gt;                &lt;/code&gt;&lt;code class=&quot;csharp keyword&quot;&gt;this&lt;/code&gt;&lt;code class=&quot;csharp plain&quot;&gt;.bytesReceived = 0; &lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number192 index191 alt1&quot;&gt;
&lt;code class=&quot;csharp spaces&quot;&gt;            &lt;/code&gt;&lt;code class=&quot;csharp plain&quot;&gt;} &lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number193 index192 alt2&quot;&gt;
&lt;code class=&quot;csharp spaces&quot;&gt;        &lt;/code&gt;&lt;code class=&quot;csharp plain&quot;&gt;} &lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number194 index193 alt1&quot;&gt;
&lt;code class=&quot;csharp spaces&quot;&gt;    &lt;/code&gt;&lt;code class=&quot;csharp plain&quot;&gt;} &lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number195 index194 alt2&quot;&gt;
&lt;code class=&quot;csharp plain&quot;&gt;}&lt;/code&gt;&lt;/div&gt;
&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://bluedreamsandroid.blogspot.com/feeds/4933971661965529535/comments/default' title='Commenti sul post'/><link rel='replies' type='text/html' href='http://bluedreamsandroid.blogspot.com/2011/04/length-prefix-message-framing-for.html#comment-form' title='0 Commenti'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/921091465317807586/posts/default/4933971661965529535'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/921091465317807586/posts/default/4933971661965529535'/><link rel='alternate' type='text/html' href='http://bluedreamsandroid.blogspot.com/2011/04/length-prefix-message-framing-for.html' title='Length-prefix message framing for streams'/><author><name>BlueDremas</name><uri>http://www.blogger.com/profile/02561736174885737185</uri><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><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-921091465317807586.post-3980242191813166544</id><published>2011-03-22T23:55:00.000-07:00</published><updated>2011-11-16T15:11:50.184-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Codice"/><category scheme="http://www.blogger.com/atom/ns#" term="esempio"/><title type='text'>Color Picker</title><content type='html'>&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjjW_CV736h-I3vSKc5g73Df7nQiUZ9zDDUKdnLBtRqQanGrGY_XEu3PLDsC1VVIOR4KSeEY48w00Lspy7msG0l1H-5Hbbpo0QcuYE9O7jgtw0vJHGBOSvEAeJ-RnbVRQRqhP0qKagYPTXE/s1600/device.png&quot; imageanchor=&quot;1&quot; style=&quot;clear: right; float: right; margin-bottom: 1em; margin-left: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjjW_CV736h-I3vSKc5g73Df7nQiUZ9zDDUKdnLBtRqQanGrGY_XEu3PLDsC1VVIOR4KSeEY48w00Lspy7msG0l1H-5Hbbpo0QcuYE9O7jgtw0vJHGBOSvEAeJ-RnbVRQRqhP0qKagYPTXE/s1600/device.png&quot; /&gt;&lt;/a&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjLzCZlVed7VoPUCF3mkwjD0_j1fs8arvCMSk-JcBa_dnJ0xHA1cI3RecTmtgMg8xAhs8fhRomwKH8evGQx3XJNc3Q8GJkzxP67rSM3PpXYOm67w6m1yM7_zf1B4OtfoF4xlJC9wCt0vlzW/s1600/device1.png&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjLzCZlVed7VoPUCF3mkwjD0_j1fs8arvCMSk-JcBa_dnJ0xHA1cI3RecTmtgMg8xAhs8fhRomwKH8evGQx3XJNc3Q8GJkzxP67rSM3PpXYOm67w6m1yM7_zf1B4OtfoF4xlJC9wCt0vlzW/s1600/device1.png&quot; /&gt;&lt;/a&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEixO8f3-qpOk63DIWhaRYfb4K8SWwkiAYJ80fEDYxZl519nQTFkrXlE1Km1d4MfYAN26roHBn3P7cE6yMwENxqQCgdHVEQr7mS-Ty35DhzwQMEm-fqws_y7av0LmP5w_CgY8jh_Eej5UAq4/s1600/device3.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEixO8f3-qpOk63DIWhaRYfb4K8SWwkiAYJ80fEDYxZl519nQTFkrXlE1Km1d4MfYAN26roHBn3P7cE6yMwENxqQCgdHVEQr7mS-Ty35DhzwQMEm-fqws_y7av0LmP5w_CgY8jh_Eej5UAq4/s1600/device3.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;span style=&quot;background-color: blue; color: white;&quot;&gt;color_picker_seekbar_r.xml&lt;/span&gt;&lt;br /&gt;
&amp;lt;?xml 
version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&amp;gt;&lt;br /&gt;
&amp;lt;layer-list xmlns:android=&quot;&lt;a href=&quot;http://schemas.android.com/apk/res/android&quot;&gt;&lt;span style=&quot;color: #888888;&quot;&gt;http://schemas.android.com/apk/res/android&lt;/span&gt;&lt;/a&gt;&quot;&amp;gt;&lt;br /&gt;
&amp;lt;item android:id=&quot;@android:id/background&quot;&amp;gt;&lt;br /&gt;
&amp;lt;shape&amp;gt;      
&lt;br /&gt;
&amp;lt;corners android:radius=&quot;5dip&quot; /&amp;gt;       &lt;br /&gt;
&amp;lt;gradient           &lt;br /&gt;
android:startColor=&quot;#ff000000&quot;          &lt;br /&gt;
android:centerY=&quot;0.5&quot;          &lt;br /&gt;
android:endColor=&quot;#ffff0000&quot;          &lt;br /&gt;
android:angle=&quot;0&quot;      
&lt;br /&gt;
/&amp;gt;     &lt;br /&gt;
&amp;lt;/shape&amp;gt;&lt;br /&gt;
&amp;lt;/item&amp;gt;&lt;br /&gt;
&amp;lt;item android:id=&quot;@android:id/progress&quot;&amp;gt;&lt;br /&gt;
&amp;lt;clip&amp;gt;&lt;br /&gt;
&amp;lt;shape&amp;gt;&lt;br /&gt;
&amp;lt;corners 
android:radius=&quot;5dip&quot; /&amp;gt;&lt;br /&gt;
&amp;lt;gradient&lt;br /&gt;
android:startColor=&quot;#ff000000&quot;&lt;br /&gt;
android:centerY=&quot;0.5&quot;          
&lt;br /&gt;
android:endColor=&quot;#ffff0000&quot;          &lt;br /&gt;
android:angle=&quot;0&quot;        &lt;br /&gt;
/&amp;gt;       &lt;br /&gt;
&amp;lt;/shape&amp;gt;     &lt;br /&gt;
&amp;lt;/clip&amp;gt;   &lt;br /&gt;
&amp;lt;/item&amp;gt;&lt;br /&gt;
&amp;lt;/layer-list&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;background-color: blue; color: white;&quot;&gt;color_picker_seekbar_g.xml&lt;/span&gt;&lt;br /&gt;
&amp;lt;?xml 
version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&amp;gt;&lt;br /&gt;
&amp;lt;layer-list xmlns:android=&quot;&lt;a href=&quot;http://schemas.android.com/apk/res/android&quot;&gt;&lt;span style=&quot;color: #888888;&quot;&gt;http://schemas.android.com/apk/res/android&lt;/span&gt;&lt;/a&gt;&quot;&amp;gt;&lt;br /&gt;
&amp;lt;item 
android:id=&quot;@android:id/background&quot;&amp;gt;&lt;br /&gt;
&amp;lt;shape&amp;gt;      &lt;br /&gt;
&amp;lt;corners android:radius=&quot;5dip&quot; /&amp;gt;       &lt;br /&gt;
&amp;lt;gradient           &lt;br /&gt;
android:startColor=&quot;#ff000000&quot;          
&lt;br /&gt;
android:centerY=&quot;0.5&quot;          &lt;br /&gt;
android:endColor=&quot;#ff00ff00&quot;          &lt;br /&gt;
android:angle=&quot;0&quot;      
&lt;br /&gt;
/&amp;gt;     &lt;br /&gt;
&amp;lt;/shape&amp;gt;&lt;br /&gt;
&amp;lt;/item&amp;gt;&lt;br /&gt;
&amp;lt;item android:id=&quot;@android:id/progress&quot;&amp;gt;&lt;br /&gt;
&amp;lt;clip&amp;gt;&lt;br /&gt;
&amp;lt;shape&amp;gt;&lt;br /&gt;
&amp;lt;corners 
android:radius=&quot;5dip&quot; /&amp;gt;&lt;br /&gt;
&amp;lt;gradient&lt;br /&gt;
android:startColor=&quot;#ff000000&quot;&lt;br /&gt;
android:centerY=&quot;0.5&quot;          
&lt;br /&gt;
android:endColor=&quot;#ff00ff00&quot;          &lt;br /&gt;
android:angle=&quot;0&quot;        &lt;br /&gt;
/&amp;gt;       &lt;br /&gt;
&amp;lt;/shape&amp;gt;     &lt;br /&gt;
&amp;lt;/clip&amp;gt;   &lt;br /&gt;
&amp;lt;/item&amp;gt;&lt;br /&gt;
&amp;lt;/layer-list&amp;gt;&lt;br /&gt;
&lt;span style=&quot;background-color: blue; color: white;&quot;&gt;color_picker_seekbar_b.xml&lt;/span&gt;&lt;br /&gt;
&amp;lt;?xml 
version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&amp;gt;&lt;br /&gt;
&amp;lt;layer-list xmlns:android=&quot;&lt;a href=&quot;http://schemas.android.com/apk/res/android&quot;&gt;&lt;span style=&quot;color: #888888;&quot;&gt;http://schemas.android.com/apk/res/android&lt;/span&gt;&lt;/a&gt;&quot;&amp;gt;&lt;br /&gt;
&amp;lt;item 
android:id=&quot;@android:id/background&quot;&amp;gt;&lt;br /&gt;
&amp;lt;shape&amp;gt;      &lt;br /&gt;
&amp;lt;corners android:radius=&quot;5dip&quot; /&amp;gt;       &lt;br /&gt;
&amp;lt;gradient           &lt;br /&gt;
android:startColor=&quot;#ff000000&quot;          
&lt;br /&gt;
android:centerY=&quot;0.5&quot;          &lt;br /&gt;
android:endColor=&quot;#ff0000ff&quot;          &lt;br /&gt;
android:angle=&quot;0&quot;      
&lt;br /&gt;
/&amp;gt;     &lt;br /&gt;
&amp;lt;/shape&amp;gt;&lt;br /&gt;
&amp;lt;/item&amp;gt;&lt;br /&gt;
&amp;lt;item android:id=&quot;@android:id/progress&quot;&amp;gt;&lt;br /&gt;
&amp;lt;clip&amp;gt;&lt;br /&gt;
&amp;lt;shape&amp;gt;&lt;br /&gt;
&amp;lt;corners 
android:radius=&quot;5dip&quot; /&amp;gt;&lt;br /&gt;
&amp;lt;gradient&lt;br /&gt;
android:startColor=&quot;#ff000000&quot;&lt;br /&gt;
android:centerY=&quot;0.5&quot;          
&lt;br /&gt;
android:endColor=&quot;#ff0000ff&quot;          &lt;br /&gt;
android:angle=&quot;0&quot;        &lt;br /&gt;
/&amp;gt;       &lt;br /&gt;
&amp;lt;/shape&amp;gt;     &lt;br /&gt;
&amp;lt;/clip&amp;gt;   &lt;br /&gt;
&amp;lt;/item&amp;gt;&lt;br /&gt;
&amp;lt;/layer-list&amp;gt;&lt;br /&gt;
&lt;span style=&quot;background-color: blue; color: white;&quot;&gt;main.xml&lt;/span&gt;&lt;br /&gt;
&amp;lt;?xml 
version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&amp;gt;&lt;br /&gt;
&amp;lt;LinearLayout xmlns:android=&quot;&lt;a href=&quot;http://schemas.android.com/apk/res/android&quot;&gt;&lt;span style=&quot;color: #888888;&quot;&gt;http://schemas.android.com/apk/res/android&lt;/span&gt;&lt;/a&gt;&quot;&lt;br /&gt;
android:orientation=&quot;vertical&quot;&lt;br /&gt;
android:layout_width=&quot;fill_parent&quot;&lt;br /&gt;
android:layout_height=&quot;fill_parent&quot;&lt;br /&gt;
&amp;gt;&lt;br /&gt;
&amp;lt;Button 
android:id=&quot;@+id/changeTextColorButton&quot;&lt;br /&gt;
android:layout_width=&quot;fill_parent&quot;&lt;br /&gt;
android:layout_height=&quot;wrap_content&quot;&lt;br /&gt;
android:text=&quot;Change 
Text Color&quot;&lt;br /&gt;
/&amp;gt;&lt;br /&gt;
&amp;lt;Button 
android:id=&quot;@+id/changeBackgroundColorButton&quot;&lt;br /&gt;
android:layout_width=&quot;fill_parent&quot;&lt;br /&gt;
android:layout_height=&quot;wrap_content&quot;&lt;br /&gt;
android:text=&quot;Change 
Background Color&quot;&lt;br /&gt;
/&amp;gt;&lt;br /&gt;
&amp;lt;TextView 
android:id=&quot;@+id/sampleTextView1&quot;&lt;br /&gt;
android:layout_width=&quot;fill_parent&quot;&lt;br /&gt;
android:layout_height=&quot;40dp&quot;&lt;br /&gt;
android:gravity=&quot;center_vertical|center_horizontal&quot;&lt;br /&gt;
android:textSize=&quot;20dp&quot;&lt;br /&gt;
android:text=&quot;Sample1&quot;/&amp;gt;&lt;br /&gt;
&amp;lt;/LinearLayout&amp;gt;&lt;br /&gt;
&lt;span style=&quot;background-color: blue; color: white;&quot;&gt;dialog_picker.xml&lt;/span&gt;&lt;br /&gt;
&amp;lt;?xml 
version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&amp;gt;&lt;br /&gt;
&amp;lt;LinearLayout xmlns:android=&quot;&lt;a href=&quot;http://schemas.android.com/apk/res/android&quot;&gt;&lt;span style=&quot;color: #888888;&quot;&gt;http://schemas.android.com/apk/res/android&lt;/span&gt;&lt;/a&gt;&quot;&lt;br /&gt;
android:layout_width=&quot;fill_parent&quot;&lt;br /&gt;
android:layout_height=&quot;fill_parent&quot;&lt;br /&gt;
android:padding=&quot;4dp&quot;&lt;br /&gt;
android:orientation=&quot;vertical&quot;&amp;gt;&lt;br /&gt;
&amp;lt;TextView&lt;br /&gt;
android:layout_width=&quot;fill_parent&quot; &lt;br /&gt;
android:layout_height=&quot;wrap_content&quot; &lt;br /&gt;
android:paddingLeft=&quot;5dp&quot; &lt;br /&gt;
android:paddingRight=&quot;5dp&quot; &lt;br /&gt;
android:text=&quot;@string/color_picker_viewer&quot;/&amp;gt;&lt;br /&gt;
&amp;lt;TextView 
android:id=&quot;@+id/colorPickerViewer&quot; &lt;br /&gt;
android:layout_width=&quot;fill_parent&quot; 
&lt;br /&gt;
android:layout_height=&quot;40dp&quot; &lt;br /&gt;
android:layout_marginLeft=&quot;5dp&quot; 
&lt;br /&gt;
android:layout_marginRight=&quot;5dp&quot;/&amp;gt;&lt;br /&gt;
&amp;lt;TextView 
android:id=&quot;@+id/colorPickerTextR&quot;&lt;br /&gt;
android:layout_width=&quot;fill_parent&quot; 
&lt;br /&gt;
android:layout_height=&quot;wrap_content&quot; &lt;br /&gt;
android:paddingLeft=&quot;5dp&quot; 
&lt;br /&gt;
android:paddingTop=&quot;5dp&quot;/&amp;gt;&lt;br /&gt;
&amp;lt;SeekBar 
android:id=&quot;@+id/colorPickerSeekBarR&quot; &lt;br /&gt;
android:layout_height=&quot;fill_parent&quot; &lt;br /&gt;
android:layout_width=&quot;fill_parent&quot; 
&lt;br /&gt;
android:max=&quot;255&quot; &lt;br /&gt;
android:padding=&quot;8dp&quot;&lt;br /&gt;
android:progressDrawable=&quot;@drawable/color_picker_seekbar_r&quot;/&amp;gt;&lt;br /&gt;
&amp;lt;TextView android:id=&quot;@+id/colorPickerTextG&quot;&lt;br /&gt;
android:layout_width=&quot;fill_parent&quot;&lt;br /&gt;
android:layout_height=&quot;wrap_content&quot;&lt;br /&gt;
android:paddingLeft=&quot;5dp&quot;/&amp;gt;&lt;br /&gt;
&amp;lt;SeekBar 
android:id=&quot;@+id/colorPickerSeekBarG&quot;&lt;br /&gt;
android:layout_height=&quot;fill_parent&quot;&lt;br /&gt;
android:layout_width=&quot;fill_parent&quot;&lt;br /&gt;
android:max=&quot;255&quot;&lt;br /&gt;
android:padding=&quot;8dp&quot;&lt;br /&gt;
android:progressDrawable=&quot;@drawable/color_picker_seekbar_g&quot;/&amp;gt;&lt;br /&gt;
&amp;lt;TextView android:id=&quot;@+id/colorPickerTextB&quot;&lt;br /&gt;
android:layout_width=&quot;fill_parent&quot;&lt;br /&gt;
android:layout_height=&quot;wrap_content&quot;&lt;br /&gt;
android:paddingLeft=&quot;5dp&quot;/&amp;gt;&lt;br /&gt;
&amp;lt;SeekBar 
android:id=&quot;@+id/colorPickerSeekBarB&quot;&lt;br /&gt;
android:layout_height=&quot;fill_parent&quot;&lt;br /&gt;
android:layout_width=&quot;fill_parent&quot;&lt;br /&gt;
android:max=&quot;255&quot;&lt;br /&gt;
android:padding=&quot;8dp&quot;&lt;br /&gt;
android:progressDrawable=&quot;@drawable/color_picker_seekbar_b&quot; 
/&amp;gt;&lt;br /&gt;
&amp;lt;/LinearLayout&amp;gt;&lt;br /&gt;
&lt;span style=&quot;background-color: blue; color: white;&quot;&gt;dialog_selecter.xml&lt;/span&gt;&lt;br /&gt;
&amp;lt;?xml 
version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&amp;gt;&lt;br /&gt;
&amp;lt;LinearLayout xmlns:android=&quot;&lt;a href=&quot;http://schemas.android.com/apk/res/android&quot;&gt;&lt;span style=&quot;color: #888888;&quot;&gt;http://schemas.android.com/apk/res/android&lt;/span&gt;&lt;/a&gt;&quot;&lt;br /&gt;
android:layout_width=&quot;fill_parent&quot;&lt;br /&gt;
android:layout_height=&quot;fill_parent&quot;&lt;br /&gt;
android:orientation=&quot;vertical&quot;&lt;br /&gt;
&amp;gt;&lt;br /&gt;
&amp;lt;GridView android:id=&quot;@+id/colorSelectGridView&quot;&lt;br /&gt;
android:layout_height=&quot;fill_parent&quot;&lt;br /&gt;
android:layout_width=&quot;fill_parent&quot;&lt;br /&gt;
android:verticalSpacing=&quot;6dp&quot;&lt;br /&gt;
android:horizontalSpacing=&quot;6dp&quot;&lt;br /&gt;
android:numColumns=&quot;4&quot;/&amp;gt;&lt;br /&gt;
&amp;lt;/LinearLayout&amp;gt;&lt;br /&gt;
&lt;span style=&quot;background-color: blue; color: white;&quot;&gt;strings.xml&lt;/span&gt;&lt;br /&gt;
&amp;lt;?xml 
version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&amp;gt;&lt;br /&gt;
&amp;lt;resources&amp;gt;&lt;br /&gt;
&amp;lt;string 
name=&quot;hello&quot;&amp;gt;Hello World, ColorSelectDialog!&amp;lt;/string&amp;gt;&lt;br /&gt;
&amp;lt;string 
name=&quot;app_name&quot;&amp;gt;Color Select Dialog&amp;lt;/string&amp;gt;&lt;br /&gt;
&amp;lt;string 
name=&quot;color_picker_viewer&quot;&amp;gt;Color Viewer(Click to select 
16Color)&amp;lt;/string&amp;gt;&lt;br /&gt;
&amp;lt;string 
name=&quot;color_picker_red&quot;&amp;gt;RED&amp;lt;/string&amp;gt;&lt;br /&gt;
&amp;lt;string 
name=&quot;color_picker_green&quot;&amp;gt;GREEN&amp;lt;/string&amp;gt;&lt;br /&gt;
&amp;lt;string 
name=&quot;color_picker_blue&quot;&amp;gt;BLUE&amp;lt;/string&amp;gt;&lt;br /&gt;
&amp;lt;/resources&amp;gt;&lt;br /&gt;
&lt;span style=&quot;background-color: blue; color: white;&quot;&gt;ColorSelectDialog.java&lt;/span&gt;&lt;br /&gt;
package 
jp.hiro711.ColorSelectDialog;&lt;br /&gt;
&lt;br /&gt;
import android.app.Activity;&lt;br /&gt;
import 
android.app.AlertDialog;&lt;br /&gt;
import android.app.Dialog;&lt;br /&gt;
import 
android.content.DialogInterface;&lt;br /&gt;
import android.os.Bundle;&lt;br /&gt;
import 
android.view.LayoutInflater;&lt;br /&gt;
import android.view.View;&lt;br /&gt;
import 
android.view.ViewGroup;&lt;br /&gt;
import android.view.View.OnClickListener;&lt;br /&gt;
import 
android.widget.AdapterView;&lt;br /&gt;
import 
android.widget.AdapterView.OnItemClickListener;&lt;br /&gt;
import 
android.widget.ArrayAdapter;&lt;br /&gt;
import android.widget.Button;&lt;br /&gt;
import 
android.widget.GridView;&lt;br /&gt;
import android.widget.SeekBar;&lt;br /&gt;
import 
android.widget.TextView;&lt;br /&gt;
import 
android.widget.SeekBar.OnSeekBarChangeListener;&lt;br /&gt;
&lt;br /&gt;
public class 
ColorSelectDialog extends Activity {&lt;br /&gt;
final int CHANGE_TEXT = 0;&lt;br /&gt;
final int CHANGE_BACKGROUND = 1;&lt;br /&gt;
&lt;br /&gt;
final int COLOR_TABLE[] = 
{&lt;br /&gt;
0xffffffff, 0xffc0c0c0, 0xff808080, 0xff000000,&lt;br /&gt;
0xffffc0c0, 0xffff6060, 0xffff0000, 0xff800000,&lt;br /&gt;
0xffffe0c0, 
0xffffb060, 0xffff8000, 0xff804000,&lt;br /&gt;
0xffffffc0, 0xffffff60, 
0xffffff00, 0xff808000,&lt;br /&gt;
0xffe0ffc0, 0xffb0ff60, 0xff80ff00, 
0xff408000,&lt;br /&gt;
0xffc0ffc0, 0xff60ff60, 0xff00ff00, 
0xff008000,&lt;br /&gt;
0xffc0ffe0, 0xff60ffb0, 0xff00ff80, 
0xff008040,&lt;br /&gt;
0xffc0ffff, 0xff60ffff, 0xff00ffff, 
0xff008080,&lt;br /&gt;
0xffc0e0ff, 0xff60b0ff, 0xff0080ff, 
0xff004480,&lt;br /&gt;
0xffc0c0ff, 0xff6060ff, 0xff0000ff, 
0xff000080,&lt;br /&gt;
0xffe0c0ff, 0xffb060ff, 0xff8000ff, 
0xff400080,&lt;br /&gt;
0xffffc0ff, 0xffff60ff, 0xffff00ff, 
0xff800080,&lt;br /&gt;
0xffffc0e0, 0xffff60b0, 0xffff0080, 0xff800040&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
int mColor = 0xffffffff;&lt;br /&gt;
int mTextColor = 
0xffc0c0c0;&lt;br /&gt;
int mBackgroundColor = 0xff000000;&lt;br /&gt;
&lt;br /&gt;
LayoutInflater 
inflater;   &lt;br /&gt;
View dialogView;&lt;br /&gt;
&lt;br /&gt;
@Override&lt;br /&gt;
public void 
onCreate(Bundle savedInstanceState) {&lt;br /&gt;
super.onCreate(savedInstanceState);&lt;br /&gt;
setContentView(R.layout.main);&lt;br /&gt;
&lt;br /&gt;
final Button button1 = 
(Button)findViewById(R.id.changeTextColorButton);&lt;br /&gt;
button1.setOnClickListener(new OnClickListener() {&lt;br /&gt;
@Override&lt;br /&gt;
public void onClick(View v) {&lt;br /&gt;
mColor 
= mTextColor;&lt;br /&gt;
colorDialog(CHANGE_TEXT);&lt;br /&gt;
}&lt;br /&gt;
});&lt;br /&gt;
final Button button2 = 
(Button)findViewById(R.id.changeBackgroundColorButton);&lt;br /&gt;
button2.setOnClickListener(new OnClickListener() {&lt;br /&gt;
@Override&lt;br /&gt;
public void onClick(View v) {&lt;br /&gt;
mColor 
= mBackgroundColor;&lt;br /&gt;
colorDialog(CHANGE_BACKGROUND);&lt;br /&gt;
}&lt;br /&gt;
});&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
private void colorDialog(final int where) {&lt;br /&gt;
final String 
rString = getResources().getString(R.string.color_picker_red);&lt;br /&gt;
final 
String gString = 
getResources().getString(R.string.color_picker_green);&lt;br /&gt;
final String 
bString = getResources().getString(R.string.color_picker_blue);&lt;br /&gt;
&lt;br /&gt;
inflater = LayoutInflater.from(this);   &lt;br /&gt;
dialogView = 
inflater.inflate(R.layout.dialog_picker, null);&lt;br /&gt;
&lt;br /&gt;
final 
TextView textR = 
(TextView)dialogView.findViewById(R.id.colorPickerTextR);&lt;br /&gt;
textR.setText(String.format(&quot;%s(%02X)&quot;, rString, (mColor &amp;amp; 0x00ff0000) 
&amp;gt;&amp;gt; 16));&lt;br /&gt;
final TextView textG = 
(TextView)dialogView.findViewById(R.id.colorPickerTextG);&lt;br /&gt;
textG.setText(String.format(&quot;%s(%02X)&quot;, gString, (mColor &amp;amp; 0x0000ff00) 
&amp;gt;&amp;gt; 8));&lt;br /&gt;
final TextView textB = 
(TextView)dialogView.findViewById(R.id.colorPickerTextB);&lt;br /&gt;
textB.setText(String.format(&quot;%s(%02X)&quot;, bString, (mColor &amp;amp; 
0x000000ff)));&lt;br /&gt;
final TextView viewer = 
(TextView)dialogView.findViewById(R.id.colorPickerViewer);&lt;br /&gt;
viewer.setBackgroundColor(mColor);&lt;br /&gt;
viewer.setOnClickListener(new 
OnClickListener() {&lt;br /&gt;
@Override&lt;br /&gt;
public void 
onClick(View v) {&lt;br /&gt;
showDialog(0);&lt;br /&gt;
}&lt;br /&gt;
});&lt;br /&gt;
&lt;br /&gt;
final SeekBar seekBarR = 
(SeekBar)dialogView.findViewById(R.id.colorPickerSeekBarR);&lt;br /&gt;
seekBarR.setProgress((mColor &amp;amp; 0x00ff0000) &amp;gt;&amp;gt;16);&lt;br /&gt;
seekBarR.setOnSeekBarChangeListener(new OnSeekBarChangeListener() 
{&lt;br /&gt;
&lt;br /&gt;
@Override&lt;br /&gt;
public void onStopTrackingTouch(SeekBar 
seekBar) {&lt;br /&gt;
int value = seekBar.getProgress();&lt;br /&gt;
textR.setText(String.format(&quot;%s(%02X)&quot;, rString, value));&lt;br /&gt;
mColor 
= (mColor &amp;amp; 0xff00ffff) | value &amp;lt;&amp;lt; 16; &lt;br /&gt;
viewer.setBackgroundColor(mColor);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
@Override&lt;br /&gt;
public void onStartTrackingTouch(SeekBar seekBar) 
{&lt;br /&gt;
int value = seekBar.getProgress();&lt;br /&gt;
textR.setText(String.format(&quot;%s(%02X)&quot;, rString, value));&lt;br /&gt;
mColor 
= (mColor &amp;amp; 0xff00ffff) | value &amp;lt;&amp;lt; 16; &lt;br /&gt;
viewer.setBackgroundColor(mColor);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
@Override&lt;br /&gt;
public void onProgressChanged(SeekBar seekBar, int 
progress,&lt;br /&gt;
boolean fromUser) {&lt;br /&gt;
int value = 
seekBar.getProgress();&lt;br /&gt;
textR.setText(String.format(&quot;%s(%02X)&quot;, 
rString, value));&lt;br /&gt;
mColor = (mColor &amp;amp; 0xff00ffff) | value 
&amp;lt;&amp;lt; 16; &lt;br /&gt;
viewer.setBackgroundColor(mColor);&lt;br /&gt;
}&lt;br /&gt;
});&lt;br /&gt;
final SeekBar seekBarG = 
(SeekBar)dialogView.findViewById(R.id.colorPickerSeekBarG);&lt;br /&gt;
seekBarG.setProgress((mColor &amp;amp; 0x0000ff00) &amp;gt;&amp;gt; 8);&lt;br /&gt;
seekBarG.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {&lt;br /&gt;
@Override&lt;br /&gt;
public void onStopTrackingTouch(SeekBar seekBar) 
{&lt;br /&gt;
int value = seekBar.getProgress();&lt;br /&gt;
textG.setText(String.format(&quot;%s(%02X)&quot;, gString, value));&lt;br /&gt;
mColor 
= (mColor &amp;amp; 0xffff00ff) | value &amp;lt;&amp;lt; 8; &lt;br /&gt;
viewer.setBackgroundColor(mColor);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
@Override&lt;br /&gt;
public void onStartTrackingTouch(SeekBar seekBar) 
{&lt;br /&gt;
int value = seekBar.getProgress();&lt;br /&gt;
textG.setText(String.format(&quot;%s(%02X)&quot;, gString, value));&lt;br /&gt;
mColor 
= (mColor &amp;amp; 0xffff00ff) | value &amp;lt;&amp;lt; 8; &lt;br /&gt;
viewer.setBackgroundColor(mColor);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
@Override&lt;br /&gt;
public void onProgressChanged(SeekBar seekBar, int 
progress,&lt;br /&gt;
boolean fromUser) {&lt;br /&gt;
int value = 
seekBar.getProgress();&lt;br /&gt;
textG.setText(String.format(&quot;%s(%02X)&quot;, 
gString, value));&lt;br /&gt;
mColor = (mColor &amp;amp; 0xffff00ff) | value 
&amp;lt;&amp;lt; 8; &lt;br /&gt;
viewer.setBackgroundColor(mColor);&lt;br /&gt;
}&lt;br /&gt;
});&lt;br /&gt;
final SeekBar seekBarB = 
(SeekBar)dialogView.findViewById(R.id.colorPickerSeekBarB);&lt;br /&gt;
seekBarB.setProgress((mColor &amp;amp; 0x000000ff));&lt;br /&gt;
seekBarB.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {&lt;br /&gt;
@Override&lt;br /&gt;
public void onStopTrackingTouch(SeekBar seekBar) 
{&lt;br /&gt;
int value = seekBar.getProgress();&lt;br /&gt;
textB.setText(String.format(&quot;%s(%02X)&quot;, bString, value));&lt;br /&gt;
mColor 
= (mColor &amp;amp; 0xffffff00) | value; &lt;br /&gt;
viewer.setBackgroundColor(mColor);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
@Override&lt;br /&gt;
public void onStartTrackingTouch(SeekBar seekBar) 
{&lt;br /&gt;
int value = seekBar.getProgress();&lt;br /&gt;
textB.setText(String.format(&quot;%s(%02X)&quot;, bString, value));&lt;br /&gt;
mColor 
= (mColor &amp;amp; 0xffffff00) | value; &lt;br /&gt;
viewer.setBackgroundColor(mColor);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
@Override&lt;br /&gt;
public void onProgressChanged(SeekBar seekBar, int 
progress,&lt;br /&gt;
boolean fromUser) {&lt;br /&gt;
int value = 
seekBar.getProgress();&lt;br /&gt;
textB.setText(String.format(&quot;%s(%02X)&quot;, 
bString, value));&lt;br /&gt;
mColor = (mColor &amp;amp; 0xffffff00) | value; 
&lt;br /&gt;
viewer.setBackgroundColor(mColor);&lt;br /&gt;
}&lt;br /&gt;
});&lt;br /&gt;
final AlertDialog.Builder alert = new AlertDialog.Builder(this);   
&lt;br /&gt;
alert.setView(dialogView);      &lt;br /&gt;
alert.setPositiveButton(&quot;OK&quot;, 
new DialogInterface.OnClickListener(){   &lt;br /&gt;
@Override  
&lt;br /&gt;
public void onClick(DialogInterface dialog, int idx) 
{&lt;br /&gt;
switch(where) {&lt;br /&gt;
case 
CHANGE_TEXT:&lt;br /&gt;
mTextColor = mColor;&lt;br /&gt;
final 
TextView textView0 = 
(TextView)findViewById(R.id.sampleTextView1);&lt;br /&gt;
textView0.setTextColor(mTextColor);&lt;br /&gt;
break;&lt;br /&gt;
case CHANGE_BACKGROUND:&lt;br /&gt;
mBackgroundColor = 
mColor;&lt;br /&gt;
final TextView textView1 = 
(TextView)findViewById(R.id.sampleTextView1);&lt;br /&gt;
textView1.setBackgroundColor(mBackgroundColor);&lt;br /&gt;
break;&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
});   
&lt;br /&gt;
alert.show();&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
@Override&lt;br /&gt;
protected Dialog 
onCreateDialog(int id) {&lt;br /&gt;
if(id == 0) {&lt;br /&gt;
final String rString = 
getResources().getString(R.string.color_picker_red);&lt;br /&gt;
final String 
gString = getResources().getString(R.string.color_picker_green);&lt;br /&gt;
final String bString = 
getResources().getString(R.string.color_picker_blue);&lt;br /&gt;
&lt;br /&gt;
LayoutInflater 
inflater1 = LayoutInflater.from(this);   &lt;br /&gt;
final View dialogView1 = 
inflater1.inflate(R.layout.dialog_selecter, null);&lt;br /&gt;
&lt;br /&gt;
final 
GridView gridView = 
(GridView)dialogView1.findViewById(R.id.colorSelectGridView);&lt;br /&gt;
ArrayAdapter&amp;lt;String&amp;gt; adapter = new 
ArrayAdapter&amp;lt;String&amp;gt;(this,   android.R.layout.simple_list_item_1) 
{&lt;br /&gt;
@Override&lt;br /&gt;
public View getView(int position, View 
convertView, ViewGroup parent) {&lt;br /&gt;
View view = 
super.getView(position, convertView, parent);&lt;br /&gt;
view.setBackgroundColor(COLOR_TABLE[position]);&lt;br /&gt;
return 
view;&lt;br /&gt;
}&lt;br /&gt;
};&lt;br /&gt;
for(int i = 0; 
i&amp;lt;COLOR_TABLE.length; i++) {&lt;br /&gt;
adapter.add(&quot;&quot;);&lt;br /&gt;
}&lt;br /&gt;
gridView.setAdapter(adapter);&lt;br /&gt;
gridView.setOnItemClickListener(new OnItemClickListener() {&lt;br /&gt;
@Override&lt;br /&gt;
public void onItemClick(AdapterView&amp;lt;?&amp;gt; arg0, View 
arg1, int arg2,&lt;br /&gt;
long arg3) {&lt;br /&gt;
mColor = 
COLOR_TABLE[arg2];&lt;br /&gt;
final TextView textR = 
(TextView)dialogView.findViewById(R.id.colorPickerTextR);&lt;br /&gt;
textR.setText(String.format(&quot;%s(%02X)&quot;, 
rString, (mColor &amp;amp; 0x00ff0000) &amp;gt;&amp;gt; 16));&lt;br /&gt;
final 
TextView textG = 
(TextView)dialogView.findViewById(R.id.colorPickerTextG);&lt;br /&gt;
textG.setText(String.format(&quot;%s(%02X)&quot;, gString, (mColor &amp;amp; 0x0000ff00) 
&amp;gt;&amp;gt; 8));&lt;br /&gt;
final TextView textB = 
(TextView)dialogView.findViewById(R.id.colorPickerTextB);&lt;br /&gt;
textB.setText(String.format(&quot;%s(%02X)&quot;, bString, (mColor &amp;amp; 
0x000000ff)));&lt;br /&gt;
final TextView viewer = 
(TextView)dialogView.findViewById(R.id.colorPickerViewer);&lt;br /&gt;
viewer.setBackgroundColor(mColor);&lt;br /&gt;
final SeekBar seekBarR = 
(SeekBar)dialogView.findViewById(R.id.colorPickerSeekBarR);&lt;br /&gt;
seekBarR.setProgress((mColor &amp;amp; 0x00ff0000) &amp;gt;&amp;gt;16);&lt;br /&gt;
final SeekBar seekBarG = 
(SeekBar)dialogView.findViewById(R.id.colorPickerSeekBarG);&lt;br /&gt;
seekBarG.setProgress((mColor &amp;amp; 0x0000ff00) &amp;gt;&amp;gt; 8);&lt;br /&gt;
final SeekBar seekBarB = 
(SeekBar)dialogView.findViewById(R.id.colorPickerSeekBarB);&lt;br /&gt;
seekBarB.setProgress((mColor &amp;amp; 0x000000ff));&lt;br /&gt;
dismissDialog(0);&lt;br /&gt;
}&lt;br /&gt;
});&lt;br /&gt;
&lt;br /&gt;
return new 
AlertDialog.Builder(this)&lt;br /&gt;
.setView(dialogView1)&lt;br /&gt;
.setNegativeButton(&quot;Cancel&quot;, null)&lt;br /&gt;
.create();&lt;br /&gt;
}&lt;br /&gt;
return super.onCreateDialog(id);&lt;br /&gt;
}&lt;br /&gt;
}</content><link rel='replies' type='application/atom+xml' href='http://bluedreamsandroid.blogspot.com/feeds/3980242191813166544/comments/default' title='Commenti sul post'/><link rel='replies' type='text/html' href='http://bluedreamsandroid.blogspot.com/2011/03/color-picker.html#comment-form' title='0 Commenti'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/921091465317807586/posts/default/3980242191813166544'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/921091465317807586/posts/default/3980242191813166544'/><link rel='alternate' type='text/html' href='http://bluedreamsandroid.blogspot.com/2011/03/color-picker.html' title='Color Picker'/><author><name>BlueDremas</name><uri>http://www.blogger.com/profile/02561736174885737185</uri><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/AVvXsEjjW_CV736h-I3vSKc5g73Df7nQiUZ9zDDUKdnLBtRqQanGrGY_XEu3PLDsC1VVIOR4KSeEY48w00Lspy7msG0l1H-5Hbbpo0QcuYE9O7jgtw0vJHGBOSvEAeJ-RnbVRQRqhP0qKagYPTXE/s72-c/device.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-921091465317807586.post-2449944676881725722</id><published>2011-02-08T15:15:00.000-08:00</published><updated>2011-11-14T14:42:43.025-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Android SDK"/><category scheme="http://www.blogger.com/atom/ns#" term="installazione"/><title type='text'>Installazione Android SDK</title><content type='html'>In questi primi articoli dedicati al sistema operativo &lt;strong&gt;&lt;span style=&quot;color: #222222;&quot;&gt;Android&lt;/span&gt;&lt;/strong&gt; 
cercheremo di affrontare alcuni aspetti fondamentali per preparare il nostro 
ambiente di sviluppo e conoscerne le più importanti caratteristiche. 
&lt;br /&gt;
&lt;br /&gt;
Quindi per prima cosa, vediamo come e cosa scaricare per prepararci a 
sviluppare le nostre applicazioni. L&#39; ambiente di sviluppo è composto dai 
seguenti componenti: 
&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;&lt;span style=&quot;color: #222222;&quot;&gt;Android SDK&lt;/span&gt;&lt;/strong&gt; (&lt;i&gt;Software development kit&lt;/i&gt;) disponibile 
per i diversi sistemi operativi 
&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;&lt;span style=&quot;color: #222222;&quot;&gt;Android Development Tools&lt;/span&gt;&lt;/strong&gt; (&lt;i&gt;ADT&lt;/i&gt;), un plugin per 
&lt;strong&gt;&lt;span style=&quot;color: #222222;&quot;&gt;Eclipse&lt;/span&gt;&lt;/strong&gt; che è stato progettato per fornire un potente ed 
integrato ambiente in cui costruire le applicazioni Android &lt;/li&gt;
&lt;/ul&gt;
Il 
requisito indispensabile per installare l&#39;intero ambiente di sviluppo è 
ovviamente la presenza del JDK (Java Developer Kit) lo potete scaricare a questo 
indirizzo &lt;a href=&quot;http://java.sun.com/javase/downloads/widget/jdk6.jsp&quot; target=&quot;_blank&quot;&gt;&lt;span style=&quot;color: #2b2bd4;&quot;&gt;JDK (Java Developer Kit)&lt;/span&gt;&lt;/a&gt;. 
&lt;br /&gt;
&lt;h2&gt;


Installare l&#39;SDK&lt;/h2&gt;
Il primo passo per creare l&#39;ambiente Android è 
scaricare il pacchetto &lt;strong&gt;&lt;span style=&quot;color: #222222;&quot;&gt;Android SDK Starter&lt;/span&gt;&lt;/strong&gt;. Il pacchetto SDK 
Starter non è un completo ambiente di sviluppo - comprende solo il nucleo SDK 
Tools, che si puè utilizzare per scaricare il resto dei componenti SDK. E&#39; 
possibile scaricare l&#39;ultima versione del pacchetto SDK Starter alla &lt;a href=&quot;http://developer.android.com/sdk/index.html&quot; target=&quot;_blank&quot;&gt;&lt;span style=&quot;color: #2b2bd4;&quot;&gt;SDK download 
page&lt;/span&gt;&lt;/a&gt;. Assicurarsi di scaricare il pacchetto appropriato per il proprio 
sistema operativo. &lt;br /&gt;
&lt;br /&gt;
Dopo aver scaricato, bisogna scompattare l&#39;archivio 
Android SDK in una posizione a vostra scelta del vostro file system. Per 
impostazione predefinita, i file SDK sono in una directory chiamata 
&lt;strong&gt;&lt;span style=&quot;color: #222222;&quot;&gt;android-sdk-&lt;i&gt;&amp;lt;machine-platform&amp;gt;&lt;/i&gt;&lt;/span&gt;&lt;/strong&gt;. Prendere nota del 
nome e del percorso della directory SDK che avete scompattato sul sistema - è 
necessario fare riferimento alla directory SDK più tardi, quando si imposta il 
plugin ADT o quando si utilizzano gli strumenti SDK. &lt;br /&gt;
&lt;br /&gt;
Quindi una volta 
installato il tutto bisogna avviare il download degli altri componenti tramite 
&lt;strong&gt;&lt;span style=&quot;color: #222222;&quot;&gt;AVD Manager&lt;/span&gt;&lt;/strong&gt;. Quindi bisogna accedere alla cartella 
&lt;strong&gt;&lt;span style=&quot;color: #222222;&quot;&gt;android-sdk-&lt;i&gt;&amp;lt;machine-platform&amp;gt;&lt;/i&gt;&lt;/span&gt;&lt;/strong&gt; e lanciare: 
&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;Per utenti Windows: il file &lt;b&gt;SDK Setup.exe&lt;/b&gt; 
&lt;/li&gt;
&lt;li&gt;Mentre per amibienti linux e Mac-Os da riga di comando nella cartella 
/Tools: &lt;pre&gt;&lt;span class=&quot;pln&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;typ&quot;&gt;&lt;span style=&quot;color: #660066;&quot;&gt;Androide&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;
Adesso 
bisogna scegliere i componenti aggiuntivi per integrare le funzionalitè 
dell&#39;ambiente. I componenti richiesti sono oltre al SDK Tools che è già presente 
nella cartella, bisogna selezionare la &lt;strong&gt;&lt;span style=&quot;color: #222222;&quot;&gt;Platform SDK&lt;/span&gt;&lt;/strong&gt; che è 
necessaria per la compilazione, e la creazione di un Virtual Android Device 
(AVD) che sarebbe l&#39;emulatore per testare le applicazioni. Inoltre è 
raccomandato scaricare anche la documentazione, i driver USB - per testare 
direttamente le applicazioni sul un dispositivo collegato al computer (solo per 
utenti Windows, poichè Linux e Mac-OS hanno giè questi driver) - ed infine gli 
esempi compresi di codici sorgenti. 
&lt;br /&gt;
&lt;h2&gt;


Installare il plugin ADT per Eclipse&lt;/h2&gt;
Adesso invece passiamo 
all&#39;installazione del plugin per Eclipse. Se non avete Eclipse installato sul 
vostro computer procedete con l&#39;installazione, scaricando una versione di 
Eclipse RPC, oppure Eclipse 3.5 Classic reperibili alla pagina &lt;a href=&quot;http://www.eclipse.org/downloads/&quot; target=&quot;_blank&quot;&gt;&lt;span style=&quot;color: #2b2bd4;&quot;&gt;Eclipse Downloads&lt;/span&gt;&lt;/a&gt; 
&lt;br /&gt;
&lt;br /&gt;
Dal menu &lt;strong&gt;&lt;span style=&quot;color: #222222;&quot;&gt;Help&lt;/span&gt;&lt;/strong&gt; selezionate la voce &lt;i&gt;Software 
Updates&lt;/i&gt;(Eclipse 3.4 Ganymede) oppure &lt;i&gt;Install New Software&lt;/i&gt; (Eclipse 
Galileo). Selezionate Add ed inserite alla voce Name la stringa &lt;i&gt;&quot;Android 
Plugin&quot;&lt;/i&gt; e nella casella Location il seguente url: &lt;br /&gt;
&lt;pre&gt;&lt;span class=&quot;pln&quot;&gt;https&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span style=&quot;color: #666600;&quot;&gt;:&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;com&quot;&gt;&lt;span style=&quot;color: #880000;&quot;&gt;//dl-ssl.google.com/android/eclipse/&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;
Adesso 
alla voce &lt;i&gt;Work With&lt;/i&gt; selezionate &lt;strong&gt;&lt;span style=&quot;color: #222222;&quot;&gt;Android Plugin&lt;/span&gt;&lt;/strong&gt; e 
spuntate &lt;i&gt;Developer Tools&lt;/i&gt;. A questo punto cliccate su &lt;i&gt;Next&lt;/i&gt; e 
dovrebbe partire il download del Plugin. Una volta concluso il download sarete 
guidati nell&#39;installazione. Al termine dell&#39;installazione riavviate Eclipse. 
&lt;br /&gt;
&lt;h3&gt;


Configurazione dell&#39; ADT Plugin&lt;/h3&gt;
Adesso non ci resta che configurare 
velocemente il Plugin in modo tale da collegarlo all&#39;SDK Android. Andare sulla 
voce &lt;i&gt;Windows -&amp;gt; Preferences&lt;/i&gt; e selezionare &lt;strong&gt;&lt;span style=&quot;color: #222222;&quot;&gt;Android&lt;/span&gt;&lt;/strong&gt;. A 
questo punto bisogna specificare la directory di installazione dell&#39;SDK 
(&lt;strong&gt;&lt;span style=&quot;color: #222222;&quot;&gt;android-sdk-&lt;i&gt;&amp;lt;machine-platform&amp;gt;&lt;/i&gt;&lt;/span&gt;&lt;/strong&gt;). 
&lt;br /&gt;
&lt;h3&gt;


Configurare l&#39;emulatore&lt;/h3&gt;
Come ultimo passaggio non ci resta che 
configuare l&#39;emulatore in caso non si dispone di un dispositivo reale che monta 
Android. Selezionate &lt;i&gt;Window -&amp;gt; Android SDK and AVD Manager&lt;/i&gt;, oppure 
potete aprire l&#39;ADV Manager direttamente dalla directory di Android come abbiamo 
visto sopra. Dal menu a sinistra bisogna selezionare la voce &lt;i&gt;Virtual 
Device&lt;/i&gt; e cliccare sul tasto &lt;i&gt;New&lt;/i&gt; a destra del pannello. Si aprira 
un&#39;altra finestra dove bisogna specificare il &lt;i&gt;Nome&lt;/i&gt;, ad esempio 
AndroidEmulator, e il &lt;i&gt;Target&lt;/i&gt; dove potete selezionare le Api Level (ad 
esempio Android 1.6 - API Level 4); e per concludere cliccate su Create ADV. 
&lt;br /&gt;
&lt;br /&gt;
Dopo questa breve e veloce panoramica sull&#39;installazione non ci resta 
che avventurarci in nuove guide ed articoli dove vedremo insieme come creare 
semplici applicazioni, per poi passare ad argomenti un po più complessi, 
cercando di toccare i vari aspetti di quest&#39;ambiente di sviluppo.</content><link rel='replies' type='application/atom+xml' href='http://bluedreamsandroid.blogspot.com/feeds/2449944676881725722/comments/default' title='Commenti sul post'/><link rel='replies' type='text/html' href='http://bluedreamsandroid.blogspot.com/2011/11/installazione-android-sdk.html#comment-form' title='0 Commenti'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/921091465317807586/posts/default/2449944676881725722'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/921091465317807586/posts/default/2449944676881725722'/><link rel='alternate' type='text/html' href='http://bluedreamsandroid.blogspot.com/2011/11/installazione-android-sdk.html' title='Installazione Android SDK'/><author><name>BlueDremas</name><uri>http://www.blogger.com/profile/02561736174885737185</uri><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><thr:total>0</thr:total></entry></feed>