<?xml version='1.0' encoding='UTF-8'?><rss xmlns:atom="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" version="2.0"><channel><atom:id>tag:blogger.com,1999:blog-1686662779713559896</atom:id><lastBuildDate>Thu, 10 Sep 2026 18:36:55 +0000</lastBuildDate><category>developer iOS</category><category>thebestandroide ejercicios ios</category><category>ejercicio iOS</category><category>thebestandroide</category><category>Android Context menu</category><category>Android orientacion vertical</category><category>Objetive C</category><category>UITableView</category><category>android twitter</category><category>blog thebestandroide</category><category>instantiateViewControllerWithIdentifier identifier</category><category>ios cambiar texto label</category><category>ios change text label</category><category>AlertView clickedButtonAtIndex</category><category>AlertView textFieldAtIndex</category><category>Android Asynktask</category><category>Android TelephonyManager</category><category>Android animar imageview</category><category>Android animar imageview xml</category><category>Android bitmap</category><category>Android camera java</category><category>Android camera. Android take photo</category><category>Android capar atras</category><category>Android change button xml</category><category>Android ciclo de vida actividad</category><category>Android contar caracteres InputText</category><category>Android contar caracteres texto</category><category>Android context menu example</category><category>Android context menu item icon</category><category>Android context menu item image</category><category>Android contextmenu radiobutton</category><category>Android deshabilitar boton atras</category><category>Android estandar programacion</category><category>Android estandar programar google</category><category>Android frame animation</category><category>Android layout ancho</category><category>Android listview adapter</category><category>Android listview adapter tutorial</category><category>Android listview example</category><category>Android listview text imageview</category><category>Android manager</category><category>Android navigation drawer</category><category>Android notificacion</category><category>Android notification manager</category><category>Android notification manager example</category><category>Android notification manager new instance</category><category>Android notification manager nueva instancia</category><category>Android onCreateContextMenu</category><category>Android orientation</category><category>Android orientation horizontal</category><category>Android preferences</category><category>Android preferences example</category><category>Android redimensionner bitmap</category><category>Android registerForContextMenu</category><category>Android run()</category><category>Android segundo hilo</category><category>Android softreference bitmap</category><category>Android tirar otro hilo</category><category>Android toast con imagen</category><category>Android toast example</category><category>Android toast image</category><category>Android vibrate</category><category>Android volteo pantalla</category><category>Boxing Clock</category><category>Boxing Clock thebestandroide</category><category>Code Snippet Library</category><category>Contador asaltos boxeo Android</category><category>Fragment ciclo de vida</category><category>Fragment listview</category><category>IUWebView XCode</category><category>MPMoviePlayerController</category><category>Navigation Controller</category><category>Navigation Controller Identifier View Controller</category><category>Navigation Controller Storyboard ID</category><category>Objetive C Bundle OS Type code</category><category>OutOfMemoryError</category><category>TableView</category><category>TextView cambiar color</category><category>TextView cambiar color xml</category><category>UIAlertViewStyleLoginAndPasswordInput</category><category>UIAlertViewStylePlainTextInput</category><category>UIAlertViewStyleSecureTextInput</category><category>UIImageview desde server</category><category>UINavigationController</category><category>UITableView UINavigationController</category><category>UITableView personalizada</category><category>UIWebView html</category><category>UIWebView javascript</category><category>UIWebView url</category><category>XCode acceder directorio documents</category><category>XCode core animation</category><category>XCode play video url</category><category>XCode reproducir video</category><category>XCode stream video</category><category>XCode video streaming</category><category>acceder directorio documents</category><category>android add view</category><category>android add vista</category><category>android animate</category><category>android animate imageview rotation</category><category>android animation imageview move</category><category>android añadir view</category><category>android añadir vista</category><category>android botones fisicos</category><category>android cambiar boton xml</category><category>android como escribo tweet</category><category>android conexion servidores</category><category>android datos telefono</category><category>android dialog pager</category><category>android drawer menu</category><category>android estandar java google</category><category>android feed twitter</category><category>android fragment</category><category>android fragment comunicacion</category><category>android fragment listview</category><category>android frame animation xml</category><category>android frames animacion</category><category>android intent object</category><category>android java layout height</category><category>android java layout width</category><category>android json java</category><category>android keyEvent botones</category><category>android layout alto</category><category>android layout height</category><category>android layout width</category><category>android no cambiar landscape</category><category>android orientation portrait</category><category>android orientation vertical portrait</category><category>android parsear JSON</category><category>android phisical buttons</category><category>android picture frames</category><category>android preferencias</category><category>android tipos intent</category><category>android twittear</category><category>android twitter application</category><category>android twitter feed</category><category>android twitter lector etiquetas</category><category>android varios fragment</category><category>android varios fragment xml</category><category>android vibracion java</category><category>android vibration</category><category>aplicación Android Twitter</category><category>aprender asp.net</category><category>aprender ejercicios iOS</category><category>asp.net</category><category>atomic</category><category>atomic vs nonatomic</category><category>blog programacion android</category><category>blog programacion iOS</category><category>boxeo asaltos android</category><category>celda personalizada</category><category>ciclos de vida activity</category><category>comunicar fragment listview</category><category>crear Snippet</category><category>crear aplicacion twitter android</category><category>crear json android</category><category>cursos informatica gratis</category><category>cursos online gratis</category><category>cursos universitarios</category><category>developer mobile</category><category>developer mobile ios</category><category>developer mobile soluciones</category><category>dialog pager inside android</category><category>diferencias atomic nonatomic</category><category>drawer actionbar tabs android</category><category>enlazar twitter android</category><category>feed twitter android</category><category>fragment modifica fragment</category><category>fragment update fragment</category><category>framework MapKit</category><category>funciones objetive c</category><category>get</category><category>google styleguide Java</category><category>heightForRowAtIndexPath</category><category>iOS CMMotionManager</category><category>iOS Cambiar Viewcontroller</category><category>iOS IUWebView load url</category><category>iOS NSFileManager</category><category>iOS Notificación local</category><category>iOS Required background modes</category><category>iOS acceder camara y galeria</category><category>iOS acelerometro</category><category>iOS aplicacion background estado</category><category>iOS boton facebook</category><category>iOS boton twitter</category><category>iOS camara</category><category>iOS core motion</category><category>iOS ejercicios</category><category>iOS estado suspension</category><category>iOS facebook</category><category>iOS hilo segundario</category><category>iOS imagen internet</category><category>iOS lista array</category><category>iOS play streaming</category><category>iOS saber localización</category><category>iOS twitter</category><category>iOS usar acelerometro</category><category>instantiateViewControllerWithIdentifier label text</category><category>intent android</category><category>intent bundle android</category><category>ios</category><category>ios MKMapView</category><category>ios MapKit</category><category>ios arquitectura TabbarController</category><category>ios cambio imagen click boton</category><category>ios change imageview click button</category><category>ios crear lista</category><category>item icon</category><category>leer json android</category><category>loadView</category><category>mensajes</category><category>menu fragments</category><category>metodos objetive c</category><category>navigation drawer  fragment</category><category>nonatomic</category><category>objective C facebook</category><category>objective C twitter</category><category>objetive C cargar imagen internet</category><category>objetive c notificacion</category><category>objetive c notificacion local</category><category>objetos</category><category>onBackPressed()</category><category>onCreate</category><category>onDestroy</category><category>onPause</category><category>onRestart</category><category>onResume</category><category>onStart</category><category>onStop</category><category>parsear json android</category><category>personalizar UITableViewCell</category><category>programacion Android</category><category>request URL</category><category>set</category><category>snippet</category><category>stream video XCode</category><category>tabla array dinamico</category><category>tabla cellForRowAtIndexPath</category><category>thebestandroide Android</category><category>thebestandroide asp.net</category><category>thebestandroide ios</category><category>thebestandroide orientacion</category><category>thebestandroide read JSON</category><category>thebestandroide twitter</category><category>thestandroide json</category><category>tipos datos Objetive c</category><category>tipos de UIAlertView</category><category>tutorial asp.net mvc</category><category>twittear android</category><category>twittear aplicacion android</category><category>twitter feed etiqueta</category><category>xcode</category><category>xcode CLLocation</category><category>xcode Documents</category><category>xcode MKMapView</category><category>xcode acceder camara galeria</category><category>xcode camara</category><category>xcode duration mp3</category><category>xcode duration sonido</category><category>xcode localizacion</category><category>xcode mapa</category><category>xcode mapview</category><category>xcode reproducir audio</category><category>xcode reproducir mp3</category><category>xcode song duration</category><category>xcode transicion vistas</category><category>xcode view</category><title>THE BEST ANDROIDE</title><description>BLOG DEVELOPER MOBILE</description><link>http://thebestandroide.blogspot.com/</link><managingEditor>noreply@blogger.com (David)</managingEditor><generator>Blogger</generator><openSearch:totalResults>74</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><item><guid isPermaLink="false">tag:blogger.com,1999:blog-1686662779713559896.post-4521558627199290003</guid><pubDate>Thu, 16 Jul 2015 05:08:00 +0000</pubDate><atom:updated>2015-07-16T06:08:36.870+01:00</atom:updated><title>Blog cerrado</title><description>&lt;p dir=&quot;ltr&quot;&gt;ESTAMOS cerrando el blog, en un periodo de tiempo dejaremos de escribir entradas ya que estamos modelando la migracion del blog a liferay, donde dedicare una secci&amp;#243;n a Android. Sigo dejandolo publico para que podais descargar c&amp;#243;digo, ya que la idea inicial era compartir codigo e ideas con la cominidad java, especificamente Android.&lt;/p&gt;
&lt;p dir=&quot;ltr&quot;&gt;Salu2!&lt;/p&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/AVvXsEio7zcqrCiCsE3-cxYRCCOygRUQen9aBn97E2XbJd0I0rl15vyl2FmPSp5uvtaSfQ_YzKJjIbHI2c5l4vaJZEWmw9_dpgLsGePjoJ2xxFYXOcTOie6cY08KVyqT8nRkfD1VlR9wliruSUYM/s1600/android-triste-campana-de-microsoft-contra-android.gif&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/AVvXsEio7zcqrCiCsE3-cxYRCCOygRUQen9aBn97E2XbJd0I0rl15vyl2FmPSp5uvtaSfQ_YzKJjIbHI2c5l4vaJZEWmw9_dpgLsGePjoJ2xxFYXOcTOie6cY08KVyqT8nRkfD1VlR9wliruSUYM/s640/android-triste-campana-de-microsoft-contra-android.gif&quot;&gt; &lt;/a&gt; &lt;/div&gt;</description><link>http://thebestandroide.blogspot.com/2015/07/blog-cerrado.html</link><author>noreply@blogger.com (David)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEio7zcqrCiCsE3-cxYRCCOygRUQen9aBn97E2XbJd0I0rl15vyl2FmPSp5uvtaSfQ_YzKJjIbHI2c5l4vaJZEWmw9_dpgLsGePjoJ2xxFYXOcTOie6cY08KVyqT8nRkfD1VlR9wliruSUYM/s72-c/android-triste-campana-de-microsoft-contra-android.gif" height="72" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-1686662779713559896.post-2590372995897956587</guid><pubDate>Wed, 08 Apr 2015 07:57:00 +0000</pubDate><atom:updated>2015-04-08T08:57:05.075+01:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">android dialog pager</category><category domain="http://www.blogger.com/atom/ns#">dialog pager inside android</category><title>Android : Dialog con Pager dentro</title><description>&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/AVvXsEi7E4TebC5a-zL3BU3eROj80Q803BQHBpbGQR226VSyZlK6rpOkQ9E-6GIZ-EdVRe4GO9548ud2UJwfO-_kFRqgF-tHO5z0uL5iP_x-ezUu2aXzbAAKaCWBOz8tBoGqY35SWa17saERyPjX/s1600/img1.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/AVvXsEi7E4TebC5a-zL3BU3eROj80Q803BQHBpbGQR226VSyZlK6rpOkQ9E-6GIZ-EdVRe4GO9548ud2UJwfO-_kFRqgF-tHO5z0uL5iP_x-ezUu2aXzbAAKaCWBOz8tBoGqY35SWa17saERyPjX/s1600/img1.png&quot; height=&quot;155&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;span style=&quot;color: #a5130f; font-size: x-large;&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;
&lt;span style=&quot;color: #a5130f; font-size: x-large;&quot;&gt;&lt;b&gt;View Pager dentro DialogFragment&lt;/b&gt;&lt;/span&gt;
&lt;br /&gt;
&lt;span style=&quot;color: #a5130f; font-size: x-large;&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Buenas developers, en esta ocasión vamos a combinar un &lt;b&gt;Dialog&lt;/b&gt; con un &lt;b&gt;View Pager&lt;/b&gt;. Este tipo de combos los podemos usar para desarrollar tutoriales dentro de nuestras aplicaciones entre otras cosas.
&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Antes de empezar quiero destacar que la implementación de la librería &lt;b&gt;android.support.v4.app&lt;/b&gt; es una chapuza de las más grandes de Android, y todo por la maldita fragmentación, así que en este caso voy a poner todos los imports de las clases para que no haya confusión ante las librerías que usan los objetos.
&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
Comenazmos creando 2 fragments : fragmento y fragmento2 :
&lt;br /&gt;
&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/AVvXsEhTbHMDFaUUtnKfpRs0sRmS9vA_T6H-HHvB4ISqGJ2fzeWJh-XB_vWUulloUghIvx_HmFNI-RzQ2yPmTCrREUL4mgmHEEgiE-cDMgZdxTqBtvJe7cCGQOC6GjPteE_rNvrf9panIYYEHpFI/s1600/screenshot1.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/AVvXsEhTbHMDFaUUtnKfpRs0sRmS9vA_T6H-HHvB4ISqGJ2fzeWJh-XB_vWUulloUghIvx_HmFNI-RzQ2yPmTCrREUL4mgmHEEgiE-cDMgZdxTqBtvJe7cCGQOC6GjPteE_rNvrf9panIYYEHpFI/s1600/screenshot1.png&quot; height=&quot;400&quot; width=&quot;207&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&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/AVvXsEhfcD-ozVbU5esZSnhPsn1-8Ef3TghP0hpX6H94Gwy7sZy3z7Br19FZelj6jnWKw52ZFjpCwL4dqskxnIRdOk4xjVhkra4KJ02FdYCP5EqzJOpAa2CBJ0OnYHuRoLWEcMjpxFfeq1h6mPE7/s1600/screenshot2.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/AVvXsEhfcD-ozVbU5esZSnhPsn1-8Ef3TghP0hpX6H94Gwy7sZy3z7Br19FZelj6jnWKw52ZFjpCwL4dqskxnIRdOk4xjVhkra4KJ02FdYCP5EqzJOpAa2CBJ0OnYHuRoLWEcMjpxFfeq1h6mPE7/s1600/screenshot2.png&quot; height=&quot;400&quot; width=&quot;213&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush:java&quot;&gt;import android.net.Uri;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
 
public class fragmento extends Fragment {
 
    private OnFragmentInteractionListener mListener;

    // TODO: Rename and change types and number of parameters
    public static fragmento newInstance(String param1, String param2) {
        fragmento fragment = new fragmento();
        Bundle args = new Bundle();
        fragment.setArguments(args);
        return fragment;
    }

    public fragmento() {
        // Required empty public constructor
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        // Inflate the layout for this fragment
        return inflater.inflate(R.layout.fragmento, container, false);
    }

    @Override
    public void onDetach() {
        super.onDetach();
        mListener = null;
    }

    public interface OnFragmentInteractionListener {
        // TODO: Update argument type and name
        public void onFragmentInteraction(Uri uri);
    }
}
&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush:java&quot;&gt;import android.net.Uri;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

public class fragmento2 extends Fragment {

    public fragmento2() {
        // Required empty public constructor
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        // Inflate the layout for this fragment
        return inflater.inflate(R.layout.fragmento2, container, false);
    }

    @Override
    public void onDetach() {
        super.onDetach();
    }

    public interface OnFragmentInteractionListener {
        // TODO: Update argument type and name
        public void onFragmentInteraction(Uri uri);
    }
}
&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Y ahora vamos con el DialogFragment, que es quien va a contener el pager, con su correspondiente adaptador :
&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;&lt;/span&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/AVvXsEhCon0arq7GM-64KTf72cUzx41TnQ_RunW7X8ZxmT0vviOtE7DCLu1XPSttRNxiqCs9NsUc3CxSRp0Z8tVLK6NxEBUPREPUHRZgO99WIpF6Nm9xBA-assQVQH1iYt7sX8_yilQZ9sk3vj3d/s1600/screenshot3.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/AVvXsEhCon0arq7GM-64KTf72cUzx41TnQ_RunW7X8ZxmT0vviOtE7DCLu1XPSttRNxiqCs9NsUc3CxSRp0Z8tVLK6NxEBUPREPUHRZgO99WIpF6Nm9xBA-assQVQH1iYt7sX8_yilQZ9sk3vj3d/s1600/screenshot3.png&quot; height=&quot;177&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;android .support.v4.view.viewpager=&quot;&quot; android:id=&quot;@+id/pager&quot; android:layout_height=&quot;match_parent&quot; android:layout_width=&quot;match_parent&quot; xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot; xmlns:tools=&quot;http://schemas.android.com/tools&quot;&gt;
    &lt;!-- Current + adjacent page titles...--&gt;
&lt;/android&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush:java&quot;&gt;import android.app.Dialog;
import android.support.v4.app.DialogFragment;
import android.os.Bundle;
import android.support.v4.view.ViewPager;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;


/**
 * Created by makone on 16/03/2015.
 */
public class fragmentDialogo extends DialogFragment{

  private PageAdapter PagAdapter; //ADAPTADOR
  private ViewPager viewPager;

  @Override
    public Dialog onCreateDialog(final Bundle savedInstanceState) {
      Dialog dialog = super.onCreateDialog(savedInstanceState);
      //Configuracion Dialog
      dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
      dialog.getWindow().setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
      return dialog;
    }

  @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
      View view = inflater.inflate(R.layout.fragment_dialog, container);   //INFLAMOS CON LA VIEW
      android.support.v4.app.FragmentManager fm = getChildFragmentManager();
      PagAdapter = new PageAdapter(fm);                              //CREAMOS ADAPTER
      viewPager = (ViewPager)view.findViewById(R.id.pager);          //INICIAMOS PAGER
      viewPager.setAdapter(PagAdapter);                              //APLICAMOS ADAPTER AL PAGER

      return view;
    }
}
&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush:java&quot;&gt;import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
 
public class PageAdapter extends FragmentPagerAdapter {

  public PageAdapter(FragmentManager fm) {
        super(fm);
    }

  @Override
    public android.support.v4.app.Fragment getItem(int position) {
      if (position == 0) {
        // find first fragment...
        fragmento ft1 = new fragmento();
        return ft1;
      }

      if (position == 1) {
        // find first fragment...
        fragmento2 ft2 = new fragmento2();
        return ft2;
      }

      return null;
    }

  @Override
    public int getCount() {
      return 2;
    }
}
&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Bien, ya está todo montado, solo falta nuestra actividad principal crear un botón para llamar al &lt;b&gt;Dialog&lt;/b&gt; con el pager cargado :
&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;&lt;/span&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/AVvXsEjb6uZggyTge4uXQUhUJeS0bn-TA2TJHiVrGdX2AdTrwQsLWlbaiP0Abyzrj1t75ZozTtQdhlaKLNVO55RGLM-CPFN8QRI3f0D_mbfLgprArPKO0wj7T5zCz2HVDwMwRI6zieety8GhRk1e/s1600/screenshot4.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/AVvXsEjb6uZggyTge4uXQUhUJeS0bn-TA2TJHiVrGdX2AdTrwQsLWlbaiP0Abyzrj1t75ZozTtQdhlaKLNVO55RGLM-CPFN8QRI3f0D_mbfLgprArPKO0wj7T5zCz2HVDwMwRI6zieety8GhRk1e/s1600/screenshot4.png&quot; height=&quot;400&quot; width=&quot;223&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush:java&quot;&gt;import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentManager;
import android.view.View;
import android.widget.Button;

public class MainActivity extends FragmentActivity {
  private Button boton;
  @Override
    protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
      boton = (Button) findViewById(R.id.botonAction);   //REFERENCIA AL BOTON
      boton.setOnClickListener(new View.OnClickListener() {
        @Override
          public void onClick(View v) {
                openDialog(v);
          }
      });
    }

  public void openDialog(View view) {
    FragmentManager fm = getSupportFragmentManager();
    fragmentDialogo overlay = new fragmentDialogo();
    overlay.show(fm, &quot;FragmentDialog&quot;);
  }
}
&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
Y este es el resultado :
&lt;br /&gt;
&lt;br /&gt;
&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/AVvXsEhnnKGAG22KjZZjdrZ52FQ1IminU3WAdWlDnC8vxzhLUmUHWWlasj_VmdVyIHcoEVAiFABxR8z93aHKSu-V7rLKaC7z60A9a_UMmhCd-EUDqUPEc54WIqNVmV_u1HQrtVj75XDHwG6LVL3P/s1600/dialogpager.gif&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/AVvXsEhnnKGAG22KjZZjdrZ52FQ1IminU3WAdWlDnC8vxzhLUmUHWWlasj_VmdVyIHcoEVAiFABxR8z93aHKSu-V7rLKaC7z60A9a_UMmhCd-EUDqUPEc54WIqNVmV_u1HQrtVj75XDHwG6LVL3P/s1600/dialogpager.gif&quot; height=&quot;320&quot; width=&quot;188&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;script language=&quot;JavaScript&quot;&gt;
function muestra_oculta(id,tipo){
 var resultado=tipo
 var dir = document.location.href;
 var tit = document.title;
 var tit2 = encodeURIComponent(tit);
 var url =&quot;&quot;;
if(resultado==1){
 var url =&quot;http://www.facebook.com/share.php?u=&quot;+dir+&quot;&amp;t=&quot;+tit2
 window.open(url, &#39;TheBestAndroide&#39;);
}
if(resultado==2){
  var url =&quot;http://twitter.com/home?status=Estoy en &quot;+dir+&quot; leyendo &quot;+tit2
  window.open(url, &#39;TheBestAndroide&#39;);
}
if(resultado==3){
 var url =&quot;http://www.linkedin.com/shareArticle?mini=true&amp;url=&quot;+dir+&quot;&amp;title=&quot;+tit2+&quot;&amp;source=http://thebestandroide.blogspot.com.es/&quot;;
  window.open(url, &#39;TheBestAndroide&#39;);
}
if(resultado==4){
  var url =&quot;http://feeds.feedburner.com/Thebestandroide&quot;
  window.open(url, &#39;TheBestAndroide&#39;);
}

if (document.getElementById){ //se obtiene el id
var el = document.getElementById(id); //se define la variable &quot;el&quot; igual a nuestro div
el.style.display = (el.style.display == &#39;none&#39;) ? &#39;block&#39; : &#39;none&#39;; //damos un atributo display:none que oculta el div
}
}
window.onload = function(){/*hace que se cargue la función lo que predetermina que div estará oculto hasta llamar a la función nuevamente*/
muestra_oculta(&#39;contenido_a_mostrar&#39;);/* &quot;contenido_a_mostrar&quot; es el nombre que le dimos al DIV */
}
&lt;/script&gt;

&lt;br /&gt;
&lt;table style=&quot;width: 260px;&quot;&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;img alt=&quot;Compartir&quot; border=&quot;0&quot; height=&quot;50&quot; onclick=&quot;muestra_oculta(&#39;contenido_a_mostrar&#39;,1)&quot; src=&quot;https://dl.dropboxusercontent.com/u/28565502/images/redface.png&quot; style=&quot;margin-right: 10px;&quot; width=&quot;50&quot; /&gt;

&lt;img alt=&quot;Compartir&quot; border=&quot;0&quot; height=&quot;50&quot; onclick=&quot;muestra_oculta(&#39;contenido_a_mostrar&#39;,2)&quot; src=&quot;https://dl.dropboxusercontent.com/u/28565502/images/twitterRed.png&quot; style=&quot;margin-right: 10px;&quot; width=&quot;50&quot; /&gt;

&lt;img alt=&quot;Compartir&quot; border=&quot;0&quot; height=&quot;50&quot; onclick=&quot;muestra_oculta(&#39;contenido_a_mostrar&#39;,3)&quot; src=&quot;https://dl.dropboxusercontent.com/u/28565502/images/LinkedIn-Logo.png&quot; style=&quot;margin-right: 10px;&quot; width=&quot;50&quot; /&gt;

&lt;img alt=&quot;Compartir&quot; border=&quot;0&quot; height=&quot;50&quot; onclick=&quot;muestra_oculta(&#39;contenido_a_mostrar&#39;,4)&quot; src=&quot;https://dl.dropboxusercontent.com/u/28565502/images/rss.png&quot; style=&quot;margin-right: 10px;&quot; width=&quot;50&quot; /&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br /&gt;
&lt;div id=&quot;contenido_a_mostrar&quot;&gt;
&lt;span style=&quot;color: #a5130f;&quot;&gt;&lt;a href=&quot;https://dl.dropbox.com/s/5enclxqcmkceh5v/DrawerPagerDialog.rar?dl=0&quot; target=&quot;_blank&quot;&gt;Descargar Dialog + pager&lt;/a&gt;.&lt;/span&gt;&lt;/div&gt;
</description><link>http://thebestandroide.blogspot.com/2015/04/android-dialog-con-pager-dentro.html</link><author>noreply@blogger.com (David)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi7E4TebC5a-zL3BU3eROj80Q803BQHBpbGQR226VSyZlK6rpOkQ9E-6GIZ-EdVRe4GO9548ud2UJwfO-_kFRqgF-tHO5z0uL5iP_x-ezUu2aXzbAAKaCWBOz8tBoGqY35SWa17saERyPjX/s72-c/img1.png" height="72" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-1686662779713559896.post-5651970539708155523</guid><pubDate>Mon, 16 Mar 2015 13:24:00 +0000</pubDate><atom:updated>2015-03-16T13:24:09.988+00:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">android intent object</category><category domain="http://www.blogger.com/atom/ns#">android tipos intent</category><category domain="http://www.blogger.com/atom/ns#">intent android</category><category domain="http://www.blogger.com/atom/ns#">intent bundle android</category><title>Intents en Android</title><description>&lt;b&gt;&lt;span style=&quot;color: #a5130f; font-size: x-large;&quot;&gt;Tipos y uso de intents&lt;/span&gt;&lt;/b&gt;
&lt;br /&gt;
&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/AVvXsEh7QvdnsVIr5VHFnBeyulal574ZQm-zD25w1t5s15ALfHvJ6NUwjMwA0_K1iZzmI-Zeo1z4H6Or37q-11TlwKnXYos3tfWaSnWA2iEe2x9_7LxnMHN_Qw4PJiooIV_F2GP-dWJZLS4pUaNH/s1600/foto2.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/AVvXsEh7QvdnsVIr5VHFnBeyulal574ZQm-zD25w1t5s15ALfHvJ6NUwjMwA0_K1iZzmI-Zeo1z4H6Or37q-11TlwKnXYos3tfWaSnWA2iEe2x9_7LxnMHN_Qw4PJiooIV_F2GP-dWJZLS4pUaNH/s1600/foto2.png&quot; height=&quot;193&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Buenas developers, a continuación aumento el repositorio de código con un tema bastante sencillo, los intents.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
Vamos a ver una serie de intents &quot;&lt;i&gt;curiosos&lt;/i&gt;&quot; que nos aportarán funcionalidades distintas.
Empezamos por el más básico, cambio de actividad con el paso de parámetros, en un proyeco en blanco, he creado 2 actividades :
&lt;br /&gt;
&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/AVvXsEiNO0hhPfuRt5zL8-vDNFIz_3SlfeZGo_aAVMIi3rnbAgLBz807n7-aBHAUE9bKUTXK0Ar6wTn9Kgql-yVhVVMrLaL6Da5Ps8PWr434oXdzUme0q1X1RdN9_ww-e6cucm48tPb3Gv6XjbrW/s1600/screensot1.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/AVvXsEiNO0hhPfuRt5zL8-vDNFIz_3SlfeZGo_aAVMIi3rnbAgLBz807n7-aBHAUE9bKUTXK0Ar6wTn9Kgql-yVhVVMrLaL6Da5Ps8PWr434oXdzUme0q1X1RdN9_ww-e6cucm48tPb3Gv6XjbrW/s1600/screensot1.png&quot; height=&quot;320&quot; width=&quot;217&quot; /&gt;&amp;nbsp;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&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/AVvXsEhqwWQWLTxGsI4uDpPJnenusmcMk2f4aaDClvVlJTyor4b74Ig9SiDi0FSM_3nxkKuzCDRCK7HQJDy6ptlRV8jOCVTNFwkxlTz6QXCa9yaPaLKYFCyUabjiG0U9jenO69cLfWbPuantMU3Q/s1600/screensot2.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/AVvXsEhqwWQWLTxGsI4uDpPJnenusmcMk2f4aaDClvVlJTyor4b74Ig9SiDi0FSM_3nxkKuzCDRCK7HQJDy6ptlRV8jOCVTNFwkxlTz6QXCa9yaPaLKYFCyUabjiG0U9jenO69cLfWbPuantMU3Q/s1600/screensot2.png&quot; height=&quot;320&quot; width=&quot;211&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush:java&quot;&gt;public class MainActivity extends Activity {

  int numero    = 8;
  String cadena = &quot;Blog ThebestAndroide&quot;;

  private Button boton;

  @Override
    protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
      //REFERENCIA BOTON
      boton = (Button) findViewById(R.id.button);
      boton.setOnClickListener(new View.OnClickListener() {
          @Override
          public void onClick(View v) {
              lanzarIntent1(MainActivity.this, cadena, numero);
          }
      });
    }

  public static void lanzarIntent1(Activity activity, String cadena, int numero) {
    String NombreActivity = &quot;segundaActivity&quot;;
    Intent intent = new Intent(NombreActivity);
    Bundle bundle = new Bundle();
    bundle.putInt(&quot;NUMERO&quot;, numero);
    bundle.putString(&quot;CADENA&quot;, cadena);
    intent.putExtras(bundle);

    activity.startActivity(intent);
  }
}
&lt;/pre&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush:java&quot;&gt;public class Activity2 extends Activity {

  @Override
    protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_activity2);

      TextView text1, text2;

      //REFERENCIA OBJETOS XML
      text1 = (TextView) findViewById(R.id.textView2);
      text2 = (TextView) findViewById(R.id.textView3);

      //RECOGER PARÁMETROS
      Bundle extras = getIntent().getExtras();
      if (extras != null) {
        String cadena = extras.getString(&quot;CADENA&quot;);
        int numero = extras.getInt(&quot;NUMERO&quot;);
        if (cadena != null) {
          text1.setText(&quot;Variable Int : &quot; + numero);
          text2.setText(&quot;Variable String : &quot; + cadena);
        }
      }
    }
}
&lt;/pre&gt;
&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/AVvXsEiwMbP2oq4f8MC2x2Gac6bojjLyW_vM_Gx_fGwOhp9X8SYtWuoilkity8ohdcZDKZHEzm70YZ_LkdDraIONr5jsYC1_qyeossvg1m77WQ8xwtRnQA4MtmdUJOMRq8-Y1puKyrNTAAOwF5Qv/s1600/screensot3.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/AVvXsEiwMbP2oq4f8MC2x2Gac6bojjLyW_vM_Gx_fGwOhp9X8SYtWuoilkity8ohdcZDKZHEzm70YZ_LkdDraIONr5jsYC1_qyeossvg1m77WQ8xwtRnQA4MtmdUJOMRq8-Y1puKyrNTAAOwF5Qv/s1600/screensot3.png&quot; height=&quot;263&quot; width=&quot;400&quot; /&gt;&amp;nbsp;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&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/AVvXsEgPqrvLve876yAj0YFn1hbPg2ml0qO39XT-wFHoz5JBpp5O9LlO3rISN2xKH1gRV7dywcHmXqWLy92ZYCCz7PbBm6lqWuUt-KQbhpLnQzdzqehrztaf6bnRMewMzlEfugkv3rBur361fHk8/s1600/simpleIntent.gif&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/AVvXsEgPqrvLve876yAj0YFn1hbPg2ml0qO39XT-wFHoz5JBpp5O9LlO3rISN2xKH1gRV7dywcHmXqWLy92ZYCCz7PbBm6lqWuUt-KQbhpLnQzdzqehrztaf6bnRMewMzlEfugkv3rBur361fHk8/s1600/simpleIntent.gif&quot; height=&quot;320&quot; width=&quot;208&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Observamos que la variable &lt;span style=&quot;color: #a5130f;&quot;&gt;NombreActivity &lt;/span&gt;tiene el mismo nombre que le ponemos en la etiqueta intent del &lt;b&gt;androidManifest&lt;/b&gt;, en el ejemplo hemos pasado 2 tipos de datos en el intent primitivos, ¿Sencillito no? ahora bien, veremos como pasar un objeto.&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&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/AVvXsEgMmNdllRxjIO2dLOV4qArvPuwC3H_pu8EQayGEtcUUBvEH-zeiu9wEj15LQPrdsDPtnR_bL68F0SLZNyqf9IZhYCstuH7UXEzBbqYzpc67drZd308FAH2nozu0OV6scBLygqttUcThr5Lk/s1600/foto1.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/AVvXsEgMmNdllRxjIO2dLOV4qArvPuwC3H_pu8EQayGEtcUUBvEH-zeiu9wEj15LQPrdsDPtnR_bL68F0SLZNyqf9IZhYCstuH7UXEzBbqYzpc67drZd308FAH2nozu0OV6scBLygqttUcThr5Lk/s1600/foto1.png&quot; height=&quot;258&quot; width=&quot;400&quot; /&gt;&amp;nbsp;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;color: #a5130f; font-size: large;&quot;&gt;¿Cómo pasamos un objeto por medio de un intent?&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;font-size: large;&quot;&gt; &lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Podríamos serializar una clase por medio de una interfaz &lt;b&gt;serializable&lt;/b&gt;, pero este proceso en Android supone un&lt;u&gt; problema de rendimiento&lt;/u&gt;.&amp;nbsp; &lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
Para eso usamos la interfad&lt;b&gt; Parcelable&lt;/b&gt;, que es específica para serializar objetos y moverlos de actividad a actividad. Así que modificamos nuestro Javabeans para que podamos serializar los objetos.&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush:java&quot;&gt;package intents.thebestandroide.intents;

import android.os.Parcel;
import android.os.Parcelable;

/**
 * Created by makone on 15/03/2015.
 */
public class producto implements Parcelable {
    int id;
    String name;
    String descripcion;

    public producto() {
    }

    public producto(int id, String name, String descripcion) {
        this.id = id;
        this.name = name;
        this.descripcion = descripcion;
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getDescripcion() {
        return descripcion;
    }

    public void setDescripcion(String descripcion) {
        this.descripcion = descripcion;
    }

    @Override
    public int describeContents() {
        return 0;
    }

    public producto (Parcel parcel){
        readToParcel(parcel);
    }

    public static final Parcelable.Creator&lt;producto&gt; CREATOR =
            new Parcelable.Creator&lt;producto&gt;() {
                public producto createFromParcel(Parcel source) {
                    return new producto(source);
                }
                public producto[] newArray(int size) {
                    return new producto[size];
                }
    };

    @Override
    public void writeToParcel(Parcel out, int flags) {
        out.writeInt(id);
        out.writeString(name);
        out.writeString(descripcion);
    }

    public void readToParcel(Parcel parcel){
        id = parcel.readInt();
        name = parcel.readString();
        descripcion = parcel.readString();
    }
}
&lt;/producto&gt;&lt;/producto&gt;&lt;/pre&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Y en nuestras dos activity, cambiamos el código referente a las variables :&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush:java&quot;&gt;public class MainActivity extends Activity {
  private Button boton;

  @Override
    protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
      //REFERENCIA BOTON
      boton = (Button) findViewById(R.id.button);
      boton.setOnClickListener(new View.OnClickListener() {
          @Override
          public void onClick(View v) {
              lanzarIntent1(MainActivity.this);
          }
      });
    }

  public static void lanzarIntent1(Activity activity) {
    String NombreActivity = &quot;segundaActivity&quot;;
    Intent intent = new Intent(NombreActivity);

    producto p = new producto();
    p.setId(1);
    p.setName(&quot;makone&quot;);
    p.setDescripcion(&quot;thebestAndroide&quot;);

    //Insertamos objeto
    intent.putExtra(&quot;producto&quot;,p);

    activity.startActivity(intent);
  }
}
&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush:java&quot;&gt;public class Activity2 extends Activity {

  @Override
    protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_activity2);

      TextView text1, text2, text3;

      //REFERENCIA OBJETOS XML
      text1 = (TextView) findViewById(R.id.textView2);
      text2 = (TextView) findViewById(R.id.textView3);
      text3 = (TextView) findViewById(R.id.textView4);

      //RECOGER PARÁMETROS
      Bundle extras = getIntent().getExtras();
      producto p = extras.getParcelable(&quot;producto&quot;);

      if (extras != null) {
         int numero    = p.getId();
         String nombre = p.getName();
         String desc   = p.getDescripcion();

         text1.setText(&quot;Id : &quot; + numero );
         text2.setText(&quot;Nombre : &quot; + nombre );
         text3.setText(&quot;Descripcion : &quot; + desc );
      }
    }
}
&lt;/pre&gt;
&lt;br /&gt;
&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/AVvXsEiX-57dgH9w64rSbVVhra1rcZ2EXFlX5PFTgYLEb3whfVWeebpdXg4K9PiglsZ-XxAd4XL6MzD2yFlmqlsYeXVn37IAhMd_ACjIUmzGI_34tqgOQbkUnouMLU5ypMCO9U9rp3sTQLVUEX6s/s1600/intentObject.gif&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/AVvXsEiX-57dgH9w64rSbVVhra1rcZ2EXFlX5PFTgYLEb3whfVWeebpdXg4K9PiglsZ-XxAd4XL6MzD2yFlmqlsYeXVn37IAhMd_ACjIUmzGI_34tqgOQbkUnouMLU5ypMCO9U9rp3sTQLVUEX6s/s1600/intentObject.gif&quot; height=&quot;400&quot; width=&quot;260&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Bien, ahora que ya hemos visto cómo hacer un intent simple con parámetros primitivos, además de un paso de objeto (el paso de arraylist lo he omitido porque para algo se crearon las BBDD) , ahora vamos a ver diversos intents curiosos que aportan funcionalidades distintas :&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;b&gt;&lt;span style=&quot;color: #a5130f; font-size: large;&quot;&gt;Abrir dirección web&lt;/span&gt;&lt;/b&gt; &lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush:java&quot;&gt;//la url debe incluir siempre el protocolo
  public static void lanzarIntent1(Activity activity) {
    String url = &quot;http://www.google.es&quot;;
    activity.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url)));
  }
&lt;/pre&gt;
&lt;br /&gt;
&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/AVvXsEjIDanSS9dXCFrXL8t7tZ01D_Sme5VWCZwmeqbqcQ538VjZchRC8WtnOd8Nfr-k63A3DIA-7PYB5KSxJ7D8x4Teo9rbKk5ZwM1LibQlWK6VtAXCuZUmS9sbLmLP07dyssSkOcMSrJ-Lc-EI/s1600/intentInternet.gif&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/AVvXsEjIDanSS9dXCFrXL8t7tZ01D_Sme5VWCZwmeqbqcQ538VjZchRC8WtnOd8Nfr-k63A3DIA-7PYB5KSxJ7D8x4Teo9rbKk5ZwM1LibQlWK6VtAXCuZUmS9sbLmLP07dyssSkOcMSrJ-Lc-EI/s1600/intentInternet.gif&quot; height=&quot;400&quot; width=&quot;210&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;color: #a5130f; font-size: large;&quot;&gt;Buscar en Youtube con la app oficial&lt;/span&gt;&lt;/b&gt;&amp;nbsp; &lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush:java&quot;&gt;  public static void lanzarIntent1(Activity activity) {
    Intent intent = new Intent(Intent.ACTION_SEARCH);
    intent.setPackage(&quot;com.google.android.youtube&quot;);
    //CADENA PARA BÚSQUEDA
    intent.putExtra(&quot;query&quot;, &quot;zenet soñar contigo&quot;);
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    try{

      activity.startActivity(intent);
      } catch (ActivityNotFoundException e) {
        //la app no está instalada
        System.out.println(&quot;App youtube no instalada&quot;);
      }
    }
&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;color: #a5130f; font-size: large;&quot;&gt;Abrir aplicación Google Play con el id de la app&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;color: #a5130f; font-size: large;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/b&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush:java&quot;&gt;  public static void lanzarIntent1(Activity activity) {
    Intent intent = new Intent(Intent.ACTION_VIEW);
    intent.setData(Uri.parse(&quot;market://details?id=cronometroboxeo.com&quot;));
    try {
      activity.startActivity(intent);
    } catch (android.content.ActivityNotFoundException e) {
      //SI HA DADO EXCEPCION PORQUE EL MARKET NO ESTA DISPONIBLE, ABRIMOS NAVEGADOR CON LA RUTA DE LA APP INTERESADA
      activity.startActivity(new Intent(Intent.ACTION_VIEW,
    Uri.parse(&quot;https://play.google.com/store/apps/details?id=cronometroboxeo.com&quot;)));
      System.out.println(&quot;Market no disponible&quot;);
    }
  }
&lt;/pre&gt;
&lt;br /&gt;
&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/AVvXsEiB9moALCcboaD5nQW_c29cc9UlgDA-cJ90kPMEh-E5JwpyxSpZdnIFekwllCkAe9ypucYDGJX8bsGfBl-iPf3VK-GezivSS4krZ5ahzSzr9y08k4heziVa5Xu09ukuuHi2hDtleQt7HMgC/s1600/intentGooglePlay.gif&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/AVvXsEiB9moALCcboaD5nQW_c29cc9UlgDA-cJ90kPMEh-E5JwpyxSpZdnIFekwllCkAe9ypucYDGJX8bsGfBl-iPf3VK-GezivSS4krZ5ahzSzr9y08k4heziVa5Xu09ukuuHi2hDtleQt7HMgC/s1600/intentGooglePlay.gif&quot; height=&quot;400&quot; width=&quot;210&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;color: #a5130f; font-size: large;&quot;&gt;Buscar en Google&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;color: #a5130f; font-size: large;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/b&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush:java&quot;&gt;  public static void lanzarIntent1(Activity activity) {
    Intent intent = new Intent(Intent.ACTION_WEB_SEARCH);
    intent.putExtra(SearchManager.QUERY, &quot;Thebestandroide&quot;);
    activity.startActivity(intent);
  }
&lt;/pre&gt;
&lt;br /&gt;
&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/AVvXsEhGBQJEN27fK98PE_g9Xg-v8uZgP2UJkpChnlE4NEzQga2v_jmcDAYmOR18OrAmwH0cu4W1kMF0nLBBqdOUZA03aTmHWGg61nVzAe_a6yZK8L20rJN5I5l8AQl8jopm0LBNR0r3L5daWg1J/s1600/intentbGoogle.gif&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/AVvXsEhGBQJEN27fK98PE_g9Xg-v8uZgP2UJkpChnlE4NEzQga2v_jmcDAYmOR18OrAmwH0cu4W1kMF0nLBBqdOUZA03aTmHWGg61nVzAe_a6yZK8L20rJN5I5l8AQl8jopm0LBNR0r3L5daWg1J/s1600/intentbGoogle.gif&quot; height=&quot;400&quot; width=&quot;211&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;color: #a5130f; font-size: large;&quot;&gt;Compartir / enviar&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;color: #a5130f; font-size: large;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/b&gt;
&lt;pre class=&quot;brush:java&quot;&gt;public static void lanzarIntent1(Activity activity) {
  Intent intent = new Intent(android.content.Intent.ACTION_SEND);
  intent.setType(&quot;text/plain&quot;);
  intent.putExtra(android.content.Intent.EXTRA_SUBJECT, &quot;Asunto&quot;); 
  intent.putExtra(Intent.EXTRA_TEXT, &quot;Contenido mensaje&quot;);
  activity.startActivity(Intent.createChooser(intent, &quot;Compartir usando&quot;));
}
&lt;/pre&gt;
&lt;br /&gt;
&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/AVvXsEh3E2PpU4gqvKor5EF2_wDmjyFYDEDmJZ1EfgWrrHFXcPyed3eSRY_4OAWBNtNMT6Xg27kOej955mGrQo1h9FrY4urILL1v7y6CvwuKQgeH7c2s4wo_V7EaUOdfCVmAqMzWC_3r1y90bCkt/s1600/intentSms.gif&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/AVvXsEh3E2PpU4gqvKor5EF2_wDmjyFYDEDmJZ1EfgWrrHFXcPyed3eSRY_4OAWBNtNMT6Xg27kOej955mGrQo1h9FrY4urILL1v7y6CvwuKQgeH7c2s4wo_V7EaUOdfCVmAqMzWC_3r1y90bCkt/s1600/intentSms.gif&quot; height=&quot;400&quot; width=&quot;211&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;color: #a5130f; font-size: large;&quot;&gt;Enviar E-mail&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;color: #a5130f; font-size: large;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/b&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush:java&quot;&gt;  public static void lanzarIntent1(Activity activity) {
    Intent emailIntent = new Intent(Intent.ACTION_SENDTO, Uri.parse(&quot;mailto:mail@gmail.com&quot;));
    emailIntent.putExtra(Intent.EXTRA_SUBJECT, &quot;Subject&quot;);
    emailIntent.putExtra(Intent.EXTRA_TEXT, &quot;body&quot;);
    activity.startActivity(Intent.createChooser(emailIntent, &quot;Seleccione una aplicación&quot;));
  }
&lt;/pre&gt;
&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;color: #a5130f; font-size: large;&quot;&gt;Agregar contactos&amp;nbsp;&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;color: #a5130f; font-size: large;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/b&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush:java&quot;&gt;  public static void lanzarIntent1(Activity activity) {
    Intent contactIntent = new Intent(Intent.ACTION_INSERT);
    contactIntent.setType(ContactsContract.Contacts.CONTENT_TYPE);
    contactIntent.putExtra(ContactsContract.Intents.Insert.NAME,&quot;Peter Parker&quot;);
    contactIntent.putExtra(ContactsContract.Intents.Insert.EMAIL,&quot;mail@mail.com&quot;);
    contactIntent.putExtra(ContactsContract.Intents.Insert.PHONE,&quot;11-7-666-23&quot;);
    activity.startActivity(contactIntent);
  }
&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;color: #a5130f; font-size: large;&quot;&gt;Guardar en gestores de eventos&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;color: #a5130f; font-size: large;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/b&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush:java&quot;&gt;  public static void lanzarIntent1(Activity activity) {
    Intent intent = new Intent(Intent.ACTION_EDIT);
    intent.setType(&quot;vnd.android.cursor.item/event&quot;);
    intent.putExtra(&quot;allDay&quot;, false);
    intent.putExtra(&quot;title&quot;, &quot;Cita Laura&quot;);
    intent.putExtra(&quot;description&quot;, &quot;Llevar preservativos por si se deja...&quot;);
    activity.startActivity(Intent.createChooser(intent, &quot;Seleccione una aplicación&quot;));
  }
 &lt;/pre&gt;
&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;color: #a5130f; font-size: large;&quot;&gt;Reproducir multimedia&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;color: #a5130f; font-size: large;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/b&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Hay que procurar indicar el MimeType correcto, vamos el formato según el tipo al que queramos acceder.Puede ser una url remota o un archivo : (file:///sdcard/MUSICA/song.mp3)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&amp;nbsp;&lt;/span&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush:java&quot;&gt;    public static void lanzarIntent1(Activity activity) {
      Intent intent = new Intent(Intent.ACTION_VIEW);
      intent.setDataAndType(Uri.parse(&quot;http://dominio.com/song.mp3&quot;),&quot;audio/mpeg&quot;);
      activity.startActivity(intent);
    }
&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;color: #a5130f; font-size: large;&quot;&gt;Hacer una llamada&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;color: #a5130f; font-size: large;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/b&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Hay que especificar, que para nuestras aplicaciones, en el caso que necesitemos hacer una llamada, para evitar poner el permiso en la app de que esta pueda llamar, usamos &lt;b&gt;ACTION.DIAL&lt;/b&gt;.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush:java&quot;&gt;    //ACTION DIAL NO REQUIERE CALL_PHONE
    public void HacerLLamada(){
      try {
      Intent callIntent;
      callIntent = new Intent(Intent.ACTION_DIAL);
      Resources res = getResources();
      //String text = String.format(res.getString(R.string.telefono)); //PARA TELF EN STRING
      String text = &quot;tel:555-555-555&quot;;
      Log.e(&quot;formato  llamada ::: &quot;, text.toString());
      callIntent.setData(Uri.parse(&quot;tel:&quot;+text));
      startActivity(callIntent);
      } catch (ActivityNotFoundException activityException) {
        Log.e(&quot;dialing-example&quot;, &quot;Llamada fallida&quot;, activityException);
      }
    }  
&lt;/pre&gt;
&lt;br /&gt;
&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/AVvXsEhXUusvi0PIRy5-DKvoXo9RkZ2juJKsw1ungZz1VXHiR3oooAo9kH1ykiCKVa0ge37qZFbod7iDKC1Q6R-75SVgyiryPfkIvQAZGyEB3PbZRDMu7PAcJHNVm-VeAh9u8IPZZg8fEODZYmu9/s1600/intentLlamar.gif&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/AVvXsEhXUusvi0PIRy5-DKvoXo9RkZ2juJKsw1ungZz1VXHiR3oooAo9kH1ykiCKVa0ge37qZFbod7iDKC1Q6R-75SVgyiryPfkIvQAZGyEB3PbZRDMu7PAcJHNVm-VeAh9u8IPZZg8fEODZYmu9/s1600/intentLlamar.gif&quot; height=&quot;400&quot; width=&quot;211&quot; /&gt;&amp;nbsp;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;script language=&quot;JavaScript&quot;&gt;
function muestra_oculta(id,tipo){
 var resultado=tipo
 var dir = document.location.href;
 var tit = document.title;
 var tit2 = encodeURIComponent(tit);
 var url =&quot;&quot;;
if(resultado==1){
 var url =&quot;http://www.facebook.com/share.php?u=&quot;+dir+&quot;&amp;t=&quot;+tit2
 window.open(url, &#39;TheBestAndroide&#39;);
}
if(resultado==2){
  var url =&quot;http://twitter.com/home?status=Estoy en &quot;+dir+&quot; leyendo &quot;+tit2
  window.open(url, &#39;TheBestAndroide&#39;);
}
if(resultado==3){
 var url =&quot;http://www.linkedin.com/shareArticle?mini=true&amp;url=&quot;+dir+&quot;&amp;title=&quot;+tit2+&quot;&amp;source=http://thebestandroide.blogspot.com.es/&quot;;
  window.open(url, &#39;TheBestAndroide&#39;);
}
if(resultado==4){
  var url =&quot;http://feeds.feedburner.com/Thebestandroide&quot;
  window.open(url, &#39;TheBestAndroide&#39;);
}

if (document.getElementById){ //se obtiene el id
var el = document.getElementById(id); //se define la variable &quot;el&quot; igual a nuestro div
el.style.display = (el.style.display == &#39;none&#39;) ? &#39;block&#39; : &#39;none&#39;; //damos un atributo display:none que oculta el div
}
}
window.onload = function(){/*hace que se cargue la función lo que predetermina que div estará oculto hasta llamar a la función nuevamente*/
muestra_oculta(&#39;contenido_a_mostrar&#39;);/* &quot;contenido_a_mostrar&quot; es el nombre que le dimos al DIV */
}
&lt;/script&gt;

&lt;br /&gt;
&lt;table style=&quot;width: 260px;&quot;&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;img alt=&quot;Compartir&quot; border=&quot;0&quot; height=&quot;50&quot; onclick=&quot;muestra_oculta(&#39;contenido_a_mostrar&#39;,1)&quot; src=&quot;https://dl.dropboxusercontent.com/u/28565502/images/redface.png&quot; style=&quot;margin-right: 10px;&quot; width=&quot;50&quot; /&gt;

&lt;img alt=&quot;Compartir&quot; border=&quot;0&quot; height=&quot;50&quot; onclick=&quot;muestra_oculta(&#39;contenido_a_mostrar&#39;,2)&quot; src=&quot;https://dl.dropboxusercontent.com/u/28565502/images/twitterRed.png&quot; style=&quot;margin-right: 10px;&quot; width=&quot;50&quot; /&gt;

&lt;img alt=&quot;Compartir&quot; border=&quot;0&quot; height=&quot;50&quot; onclick=&quot;muestra_oculta(&#39;contenido_a_mostrar&#39;,3)&quot; src=&quot;https://dl.dropboxusercontent.com/u/28565502/images/LinkedIn-Logo.png&quot; style=&quot;margin-right: 10px;&quot; width=&quot;50&quot; /&gt;

&lt;img alt=&quot;Compartir&quot; border=&quot;0&quot; height=&quot;50&quot; onclick=&quot;muestra_oculta(&#39;contenido_a_mostrar&#39;,4)&quot; src=&quot;https://dl.dropboxusercontent.com/u/28565502/images/rss.png&quot; style=&quot;margin-right: 10px;&quot; width=&quot;50&quot; /&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br /&gt;</description><link>http://thebestandroide.blogspot.com/2015/03/intents-en-android.html</link><author>noreply@blogger.com (David)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh7QvdnsVIr5VHFnBeyulal574ZQm-zD25w1t5s15ALfHvJ6NUwjMwA0_K1iZzmI-Zeo1z4H6Or37q-11TlwKnXYos3tfWaSnWA2iEe2x9_7LxnMHN_Qw4PJiooIV_F2GP-dWJZLS4pUaNH/s72-c/foto2.png" height="72" width="72"/><thr:total>2</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-1686662779713559896.post-2968076156406718431</guid><pubDate>Mon, 09 Feb 2015 16:55:00 +0000</pubDate><atom:updated>2015-02-09T17:22:37.602+00:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">drawer actionbar tabs android</category><title>Drawer menu con Action Bar y Tabs</title><description>&lt;a href=&quot;http://thebestandroide.blogspot.com.es/&quot;&gt;&lt;span style=&quot;color: #a5130f;&quot;&gt;Blog &lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #a5130f;&quot;&gt;&lt;a href=&quot;http://thebestandroide.blogspot.com/2014/06/lista-soluciones.html&quot;&gt; &amp;gt;Lista Soluciones &amp;gt;&lt;/a&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #a5130f;&quot;&gt;&lt;b&gt;-Drawer Menu + Action Bar&amp;nbsp;+ Tabs&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #a5130f;&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;
&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/AVvXsEhKoXalujCTLG24YgSWdi2MEfSHshL2WDMJE0RL2L8_pRto-P6AsYKZMJ_n4lC0NrJbexesYEUCS8wcKm1EHxu4tHJNAOFuCzyDCqyy7SZe89iBaY_pC165yqTicspwXp6w2KFnUAokq_qJ/s1600/nav.jpg&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/AVvXsEhKoXalujCTLG24YgSWdi2MEfSHshL2WDMJE0RL2L8_pRto-P6AsYKZMJ_n4lC0NrJbexesYEUCS8wcKm1EHxu4tHJNAOFuCzyDCqyy7SZe89iBaY_pC165yqTicspwXp6w2KFnUAokq_qJ/s1600/nav.jpg&quot; height=&quot;210&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;b style=&quot;color: #a5130f;&quot;&gt;&lt;span style=&quot;font-size: x-large;&quot;&gt;Drawer menu manejando ActionBar con Tabs&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;En el post iremos viendo en &lt;b&gt;Android Studio&lt;/b&gt; un menú de navegación vistoso paso a paso, en primer lugar crearemos el menú drawer.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
Si quereis ver qué es un menú drawer podeis verlo desde &lt;a href=&quot;http://thebestandroide.blogspot.com.es/2014/11/navigation-drawer-con-drawerlayout.html&quot; target=&quot;_blank&quot;&gt;aquí&lt;/a&gt;.
En este caso cambiaremos los parámetros para que modificar la interfaz visual desde el drawer menu al ActionBar, y en esta ocasión también trataremos el ActionBar con pestañas.&lt;br /&gt;
&lt;br /&gt;
Vamos allá con el código :&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&amp;nbsp;&lt;b style=&quot;color: #a5130f;&quot;&gt;1 Creacción del Drawer Menu&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;CLASE &lt;/b&gt;itemsMenuDrawer&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush:java&quot;&gt;/**
 * Created by makone
 * Description : Encapsula objetos para el menú del Dawer
 */
public class itemsMenuDrawer {
  private int id;
  private String name;
  private String subName;
  private Drawable icon;

  public itemsMenuDrawer(int id, String name, String subName, Drawable icon) {
    this.id = id;
    this.name = name;
    this.subName = subName;
    this.icon = icon;
  }

  public int getId() { return id; }
  public void setId(int id) { this.id = id; }

  public String getName() { return name; }
  public void setName(String name) { this.name = name; }

  public String getSubName() { return subName; }
  public void setSubName(String subName) { this.subName = subName; }

  public Drawable getIcon() { return icon; }
  public void setIcon(Drawable icon) { this.icon = icon; }
}
&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;CLASE&lt;/b&gt; menuAdapter
&lt;br /&gt;
&lt;pre class=&quot;brush:java&quot;&gt;/**
 * Created by makone.
 * Description : Adapter para los objetos del Drawer
 */
public class menuAdapter extends BaseAdapter {

  protected Activity activity;
  //ARRAYLIST CON TODOS LOS ITEMS
  protected ArrayList&lt;itemsmenudrawer&gt; items;
    
  //CONSTRUCTOR
  public menuAdapter(Activity activity, ArrayList&lt;itemsmenudrawer&gt; items) {
    this.activity = activity;
    this.items = items;
  }

  //CUENTA LOS ELEMENTOS
  @Override
  public int getCount() {
        return items.size();
    }
  //DEVUELVE UN OBJETO DE UNA DETERMINADA POSICION
  @Override
    public Object getItem(int arg0) {
        return items.get(arg0);
    }

    //DEVUELVE EL ID DE UN ELEMENTO
    @Override
      public long getItemId(int position) {
        return items.get(position).getId();
    }

      //METODO PRINCIPAL, AQUI SE LLENAN LOS DATOS
      @Override
      public View getView(int position, View convertView, ViewGroup parent) {
        View v = convertView;
        //ASOCIAMOS LA VISTA AL LAYOUT DEL RECURSO XML DONDE ESTA LA BASE DE
        if (convertView == null) {
          LayoutInflater inf = (LayoutInflater) activity.
                    getSystemService(activity.getApplicationContext().LAYOUT_INFLATER_SERVICE);
          v = inf.inflate(R.layout.itemdrawer, null);
        }

        itemsMenuDrawer dir = items.get(position);
        //RELLENAMOS LA IMAGEN Y EL TEXTO
        ImageView foto = (ImageView) v.findViewById(R.id.img_menu);
        foto.setImageDrawable(dir.getIcon());
        TextView txtPrinc = (TextView) v.findViewById(R.id.txt_princip);
        txtPrinc.setText(dir.getName());
        TextView txtSecund = (TextView) v.findViewById(R.id.txt_secund);
        txtSecund.setText(dir.getSubName());

        // DEVOLVEMOS VISTA
        return v;
    }
}
&lt;/itemsmenudrawer&gt;&lt;/itemsmenudrawer&gt;&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;CLASE&lt;/b&gt; MainActivity
&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush:java&quot;&gt;public class MainActivity extends ActionBarActivity {
  DrawerLayout drawerLayout;
  FrameLayout contenedorPrincipal;
  ListView listaMenu;
  private ArrayList&lt;itemsmenudrawer&gt; array;

  Activity activity;
  Context context;

  @Override
    protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
      this.activity = MainActivity.this;
      this.context = activity.getApplicationContext();
      gestionDatos();

    }
  
  public void gestionDatos(){
    instanciarObjetos ();
    configurarMenuDrawer();
  }

  public void configurarMenuDrawer(){

  }

  public void instanciarObjetos (){
    contenedorPrincipal=(FrameLayout) findViewById(R.id.contenedor_principal);
    drawerLayout = (DrawerLayout) findViewById(R.id.menu_drawer);

    listaMenu = (ListView) findViewById(R.id.lista_menu);
    listaMenu.setOnItemClickListener(new AdapterView.OnItemClickListener(){
      @Override
        public void onItemClick(AdapterView parent, View view,int position, long id) {
          seleccionarFragment(position);
        }

    });
      
    View header=getLayoutInflater().inflate(R.layout.header_menu, null); //HEADER
    listaMenu.addHeaderView(header,null,false);

    array = new ArrayList&lt;itemsmenudrawer&gt;();
    llenarListaMenu(array);

    menuAdapter adaptador = new menuAdapter(this, array);             //ADAPTER
    listaMenu.setAdapter(adaptador);
  }
    
  public void seleccionarFragment(int posicion){
    switch (posicion) {
      // BOTON PLAY, PRIMERA POSICION = 0
      case 1:
        //fragment1
        break;
      case 2:
        //fragment2
        break;
      case 3:
        //fragment3
        break;
      case 4:
        //fragment4
        break;
      case 5:
        finish();
      }
  }
  //LLENAR LISTA DE OBJETOS DEL MENU
  public void llenarListaMenu(ArrayList &lt;itemsmenudrawer&gt; arraydir){
    itemsMenuDrawer item;
    // Introduzco los elementos
    item = new itemsMenuDrawer(1, &quot;Nirvana&quot;, &quot;Heart, sharped box&quot;,
                          context.getResources().getDrawable(R.drawable.ico1));
    arraydir.add(item);
    item = new itemsMenuDrawer(2, &quot;The pixies&quot;, &quot;Where is my mind&quot;,
                          context.getResources().getDrawable(R.drawable.ico2));
    arraydir.add(item);
    item = new itemsMenuDrawer(3,&quot;Bob Dylan&quot;,&quot;Hurrican Carter&quot;,
                          context.getResources().getDrawable(R.drawable.ico3));
    arraydir.add(item);
    item = new itemsMenuDrawer(4, &quot;Toxicity&quot;,&quot;System of a down&quot;,
                          context.getResources().getDrawable(R.drawable.ico4));
    arraydir.add(item);
    item = new itemsMenuDrawer(5, &quot;Maneras de vivir&quot;, &quot;Rosendo&quot;,
                          context.getResources().getDrawable(R.drawable.ico5));
    arraydir.add(item);
  }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
      // Inflate the menu; this adds items to the actionBar if it is present.
      getMenuInflater().inflate(R.menu.menu_main, menu);
      return true;
    }

  @Override
    public boolean onOptionsItemSelected(MenuItem item) {
      // Handle action bar item clicks here. The action bar will
      // automatically handle clicks on the Home/Up button, so long
      // as you specify a parent activity in AndroidManifest.xml.
      switch (item.getItemId()) {
              return super.onOptionsItemSelected(item);
      }
  }
}//END CLASS
&lt;/itemsmenudrawer&gt;&lt;/itemsmenudrawer&gt;&lt;/itemsmenudrawer&gt;&lt;/pre&gt;
&lt;br /&gt;
Este es el resultado :&lt;br /&gt;
&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/AVvXsEgHHTDTszjfowSKNk3tobCY_ZACZ3bwbX8sAOiTc4Earsm5acUfc3senW0LYWER8lgnPxFy4e0BIDS961ZwrR6k4M3OY69tBpT3rq9AJEQj9DK7O3a30tncRfl2fidQnbh_1qLEOHWHgqNM/s1600/screenshot2.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/AVvXsEgHHTDTszjfowSKNk3tobCY_ZACZ3bwbX8sAOiTc4Earsm5acUfc3senW0LYWER8lgnPxFy4e0BIDS961ZwrR6k4M3OY69tBpT3rq9AJEQj9DK7O3a30tncRfl2fidQnbh_1qLEOHWHgqNM/s1600/screenshot2.png&quot; height=&quot;640&quot; width=&quot;555&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Si quereis ver cómo se hacen los diseños de R.layout.itemdrawer o el propio activity_main podeis verlo en el post anteriormente mencionado &lt;a href=&quot;http://thebestandroide.blogspot.com.es/2014/11/navigation-drawer-con-drawerlayout.html&quot; target=&quot;_blank&quot;&gt;aquí&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;b style=&quot;color: #a5130f; font-size: x-large;&quot;&gt;2 Implementamos una Action Bar&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
Antes vamos a insertar la librería de compatibilidad con versiones anteriores, así que le damos click derecho al proyecto y en &lt;b&gt;open module settings &lt;/b&gt;(penúltima por abajo), vamos a dependencies y en el + &lt;b&gt;Library Dependency&lt;/b&gt; buscamos &lt;b&gt;com.android.support:appcompat-v7&lt;/b&gt;.&lt;br /&gt;
&lt;br /&gt;
&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/AVvXsEjamnxulRBz7MSTS6bkIfKUV2xjvM9lFkcSWrnyWV-HdDQbTfM_X_3lz4cJVUiSLQaN_Tubd5EQ9e6_BUUQA3z1NIRIOSZCQOXZ_sEoizrZIXUttqLajdhWlZJ1MwsMQGJ_6-RTeiHmbASd/s1600/screenshot1.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/AVvXsEjamnxulRBz7MSTS6bkIfKUV2xjvM9lFkcSWrnyWV-HdDQbTfM_X_3lz4cJVUiSLQaN_Tubd5EQ9e6_BUUQA3z1NIRIOSZCQOXZ_sEoizrZIXUttqLajdhWlZJ1MwsMQGJ_6-RTeiHmbASd/s1600/screenshot1.png&quot; height=&quot;227&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;application android:allowbackup=&quot;true&quot; android:icon=&quot;@drawable/ic_launcher&quot; android:label=&quot;@string/app_name&quot; android:logo=&quot;@drawable/ico1&quot; android:theme=&quot;@style/Theme.AppCompat.Light.DarkActionBar&quot;&gt;
  
        &lt;activity android:label=&quot;@string/app_name&quot; android:name=&quot;.MainActivity&quot;&gt;
            &lt;intent-filter&gt;
                &lt;action android:name=&quot;android.intent.action.MAIN&quot;&gt;

                &lt;category android:name=&quot;android.intent.category.LAUNCHER&quot;&gt;
            &lt;/category&gt;&lt;/action&gt;&lt;/intent-filter&gt;
&lt;br /&gt;
Podemos usarla para toda la aplicación o para alguna actividad que nos interese.
&lt;br /&gt;
&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-size: large;&quot;&gt;

Ahora vamos a darle un menú a la Action Bar independiente del Drawer, esto a la hora de desarrollar la aplicación es muy importante estudiar este combo, ya que debemos eliminar la redundancia de información.&lt;/span&gt;&lt;/activity&gt;&lt;/application&gt;&lt;br /&gt;
&lt;application android:allowbackup=&quot;true&quot; android:icon=&quot;@drawable/ic_launcher&quot; android:label=&quot;@string/app_name&quot; android:logo=&quot;@drawable/ico1&quot; android:theme=&quot;@style/Theme.AppCompat.Light.DarkActionBar&quot;&gt;&lt;activity android:label=&quot;@string/app_name&quot; android:name=&quot;.MainActivity&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/activity&gt;&lt;/application&gt;
&lt;application android:allowbackup=&quot;true&quot; android:icon=&quot;@drawable/ic_launcher&quot; android:label=&quot;@string/app_name&quot; android:logo=&quot;@drawable/ico1&quot; android:theme=&quot;@style/Theme.AppCompat.Light.DarkActionBar&quot;&gt;&lt;activity android:label=&quot;@string/app_name&quot; android:name=&quot;.MainActivity&quot;&gt;En este caso en particular, vamos a cambiar los parámetros para que cambie la interfaz visual desde el drawer menu al Action Bar.&lt;/activity&gt;&lt;/application&gt;&lt;br /&gt;
&lt;application android:allowbackup=&quot;true&quot; android:icon=&quot;@drawable/ic_launcher&quot; android:label=&quot;@string/app_name&quot; android:logo=&quot;@drawable/ico1&quot; android:theme=&quot;@style/Theme.AppCompat.Light.DarkActionBar&quot;&gt;&lt;activity android:label=&quot;@string/app_name&quot; android:name=&quot;.MainActivity&quot;&gt;&lt;br /&gt;
Para manejar los iconos que deben ir en la Action Bar creamos una clase en el que le pasamos la opción y genera una Action Bar diferente dependiendo de donde se llame :&amp;nbsp;&lt;/activity&gt;&lt;/application&gt;&lt;br /&gt;
&lt;application android:allowbackup=&quot;true&quot; android:icon=&quot;@drawable/ic_launcher&quot; android:label=&quot;@string/app_name&quot; android:logo=&quot;@drawable/ico1&quot; android:theme=&quot;@style/Theme.AppCompat.Light.DarkActionBar&quot;&gt;&lt;activity android:label=&quot;@string/app_name&quot; android:name=&quot;.MainActivity&quot;&gt;&lt;br /&gt;&lt;b&gt;CLASE &lt;/b&gt;configActionBAR
&lt;br /&gt;
&lt;/activity&gt;&lt;/application&gt;&lt;br /&gt;
&lt;pre class=&quot;brush:java&quot;&gt;import texto.cifrador.makone.cifradortexto.R;

/**
 * Created by makone.
 * Description : Gestiona los menús que deben salir en cada actividad
 */
public class configActionBAR {

  ActionBar actionBar = null;
  int opcion;

  public configActionBAR(ActionBar menu, int opcion) {
    this.actionBar = menu;
    this.opcion = opcion;
    ClasificarMenu(opcion);
  }

  public void ClasificarMenu(int opcion) {
    switch (opcion) {
      case 1:cifrador();

      case 2:

      case 3:
   
      default:
        Log.e(&quot;BotoonesMenu&quot;, &quot;Opcion incorrecta&quot;);
    }
  }

  public void cifrador (){
    //actionBar.hide();                        //Ocultar ActionBar
    actionBar.setIcon(R.drawable.ic_launcher); //Establecer icono
    actionBar.setTitle(&quot;Cifrador&quot;);            //Establecer titulo
    actionBar.setSubtitle(&quot;Menu principal&quot;);   //Establecer Subtitulo

    // actionBar.setDisplayHomeAsUpEnabled(true); //Boton atras
    }
}
&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Y para darle la funcionalidad al botón de atrás de la Action Bar, vamos al método &lt;b&gt;onOptionsItemSelected&lt;/b&gt; de MainActivity, donde &lt;b&gt;android.R.id.home&lt;/b&gt; es la instancia del botón atrás del ActionBar.&amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;
CLASE&lt;/b&gt; MainActivity
&lt;br /&gt;
&lt;pre class=&quot;brush:java&quot;&gt; @Override
    public boolean onOptionsItemSelected(MenuItem item) {
      // Handle action bar item clicks here. The action bar will
      // automatically handle clicks on the Home/Up button, so long
      // as you specify a parent activity in AndroidManifest.xml.
      switch (item.getItemId()) {
          case android.R.id.home :
              drawerLayout.openDrawer(Gravity.LEFT);
              return true;
&lt;/pre&gt;
&lt;br /&gt;
Usamos la nueva clase para poner los items en lista desplegable o en el título que nos parezca&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp;
&lt;br /&gt;
&lt;b&gt;CLASE&lt;/b&gt; MainActivity&lt;/div&gt;
&lt;div&gt;
&amp;nbsp;
&lt;br /&gt;
&lt;pre class=&quot;brush:java&quot;&gt;  public void configurarMenuDrawer(){
    actionBar = getSupportActionBar();
  }
  //EN EL ONCLICK DE listaMenu PARA PODER DARLE OTRA APARIENCIA DEPENDIENDO DEL FRAGMENT
  ACM = new configActionBAR(actionBar,position);
  
&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Ahora vamos a modificar el menú principal&lt;b&gt; activity_main.xml&lt;/b&gt;, pero antes veamos estos atributos :&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&amp;nbsp;
&lt;/span&gt;&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;b&gt;ifRoom&lt;/b&gt; : &amp;nbsp; &amp;nbsp;Muestra el icono si lo tiene y tiene espacio.&amp;nbsp;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;b&gt;withText&lt;/b&gt; : Icono + título si tiene espacio.&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;b&gt;always&lt;/b&gt; : &amp;nbsp; &amp;nbsp; Siempre muestra el icono.&amp;nbsp;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;b&gt;never &lt;/b&gt;: &amp;nbsp; &amp;nbsp; &amp;nbsp; Unicamente estará en el desplegable.&amp;nbsp;&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;
Con &lt;b&gt;always&lt;/b&gt; hay que tener cuidado, ya que en pasadas versiones los tamaños eran más pequeños y puede dar problemas, con &lt;b&gt;ifRoom&lt;/b&gt; está solucionado, ahora sólo nos hace falta jugar un poco con las propiedades :&amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&amp;lt;menu xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; xmlns:tools=&quot;http://schemas.android.com/tools&quot;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; xmlns:texto.makone=&quot;http://schemas.android.com/apk/res-auto&quot;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; tools:context=&quot;.MainActivity&quot;&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;lt;item&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; android:id=&quot;@+id/compartirApp&quot;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; android:title=&quot;@string/menu_google_App&quot;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; android:icon=&quot;@drawable/ic_action_share&quot;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; texto.makone:showAsAction=&quot;ifRoom|withText&quot;/&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;lt;item&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; android:id=&quot;@+id/menuAjustes&quot;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; android:title=&quot;@string/menu_ajustes&quot;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; android:icon=&quot;@drawable/ic_action_settings&quot;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; texto.makone.:showAsAction=&quot;ifRoom|withText&quot;/&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;lt;item&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; android:id=&quot;@+id/GoogleAppPago&quot;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; android:title=&quot;@string/menu_google_App&quot;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; android:icon=&quot;@drawable/google_play_icon&quot;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; texto.makone:showAsAction=&quot;ifRoom|withText&quot;/&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;lt;item&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;android:id=&quot;@+id/menuDescripcion&quot;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;android:title=&quot;@string/menu_descripcion&quot;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;android:icon=&quot;@drawable/google_play_icon&quot;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;texto.makone:showAsAction=&quot;never&quot;/&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;lt;item&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;android:id=&quot;@+id/menuEjemplo&quot;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;android:title=&quot;@string/menu_ejemplo&quot;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;android:icon=&quot;@drawable/google_play_icon&quot;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;texto.makone:showAsAction=&quot;never&quot;/&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp;&amp;lt;/menu&amp;gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;menu tools:context=&quot;.MainActivity&quot; xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot; xmlns:texto.makone=&quot;http://schemas.android.com/apk/res-auto&quot; xmlns:tools=&quot;http://schemas.android.com/tools&quot;&gt;
&lt;item android:icon=&quot;@drawable/ic_action_share&quot; android:id=&quot;@+id/compartirApp&quot; android:title=&quot;@string/menu_google_App&quot; texto.makone:showasaction=&quot;ifRoom|withText&quot;&gt;
&lt;item android:icon=&quot;@drawable/ic_action_settings&quot; android:id=&quot;@+id/menuAjustes&quot; android:title=&quot;@string/menu_ajustes&quot; texto.makone:showasaction=&quot;ifRoom|withText&quot;&gt;
&lt;item android:icon=&quot;@drawable/google_play_icon&quot; android:id=&quot;@+id/GoogleAppPago&quot; android:title=&quot;@string/menu_google_App&quot; texto.makone:showasaction=&quot;ifRoom|withText&quot;&gt;
&lt;item android:icon=&quot;@drawable/google_play_icon&quot; android:id=&quot;@+id/menuDescripcion&quot; android:title=&quot;@string/menu_descripcion&quot; texto.makone.:showasaction=&quot;never&quot;&gt;
&lt;item android:icon=&quot;@drawable/google_play_icon&quot; android:id=&quot;@+id/menuEjemplo&quot; android:title=&quot;@string/menu_ejemplo&quot; texto.makone:showasaction=&quot;never&quot;&gt;
 &lt;/item&gt;&lt;/item&gt;&lt;/item&gt;&lt;/item&gt;&lt;/item&gt;&lt;/menu&gt;

texto.makone es el nombre del paquete de mi app y esta linea también es importante :&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;pre class=&quot;brush:java&quot;&gt;xmlns:texto.makone=&quot;http://schemas.android.com/apk/res-auto&quot;&lt;/pre&gt;
&lt;pre class=&quot;brush:java&quot;&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&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/AVvXsEi-qACaQtg-fjvf74eR-ZK4qFPZPss1ajFGc41GL6ctjFcyFiISKXS3M9TXc_soJ11jMcl-l8T83sBFdz1dlvMZQfMh45UaksxH_w4K7uNh3rkC75_M_z7Y8l1dpfMQFCgp8wkJyRxq14fa/s1600/screenshot3.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/AVvXsEi-qACaQtg-fjvf74eR-ZK4qFPZPss1ajFGc41GL6ctjFcyFiISKXS3M9TXc_soJ11jMcl-l8T83sBFdz1dlvMZQfMh45UaksxH_w4K7uNh3rkC75_M_z7Y8l1dpfMQFCgp8wkJyRxq14fa/s1600/screenshot3.png&quot; height=&quot;325&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&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/AVvXsEisTAPEV966lD88XW9lirwUI8dhRDgTRl-tPFblDwGXfeGm-CrpWBRRjre4kjGTbNMneTE3mHFaNtERSO4b_yusr7iQSQjiLZAmwYotL4yIz3imRCWAiJZux1GgiiJMpEp3y3M4p19DhWvB/s1600/screenshot4.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/AVvXsEisTAPEV966lD88XW9lirwUI8dhRDgTRl-tPFblDwGXfeGm-CrpWBRRjre4kjGTbNMneTE3mHFaNtERSO4b_yusr7iQSQjiLZAmwYotL4yIz3imRCWAiJZux1GgiiJMpEp3y3M4p19DhWvB/s1600/screenshot4.png&quot; height=&quot;293&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush:java&quot;&gt;&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;
Vemos que Descripcion o Ejemplo no aparecen en el Action mientras que los demás están configurados para que sí. Ahora vamos con el tema de la gestión de fragments. Con Android Studio  crea el fragment completamente, he creado 2, pero se pueden hacer todos los que se quiera o necesite :&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&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/AVvXsEgr4-amzadLBguIGAM-0_dQNxqS_2JzypuSyjo6nZZgMq-g4_9E_OG-YveqtGlibkbOmXnhydYw3TTkAoMiEtH4b-aM8WnIoWqf6w-fgnGmz321fn3rlhmKu1ZmxtWnAD7FLkxXRsIqgOyM/s1600/screenshot5.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/AVvXsEgr4-amzadLBguIGAM-0_dQNxqS_2JzypuSyjo6nZZgMq-g4_9E_OG-YveqtGlibkbOmXnhydYw3TTkAoMiEtH4b-aM8WnIoWqf6w-fgnGmz321fn3rlhmKu1ZmxtWnAD7FLkxXRsIqgOyM/s1600/screenshot5.png&quot; height=&quot;400&quot; width=&quot;198&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&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/AVvXsEiUeFzoWdQIxsK6U_IyQsCqeb_bcVcEQ_DR_mfqkPI3-8770h8RlXcQ1MUcnrWZnyeOflNFqz2wj63S5KvHmoqrnyIcYkPR8SXoNGJ6J0ZEnbGArJwH8JIp1cWM4NbAG5_ruPs-XmRLMdpM/s1600/screenshot6.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/AVvXsEiUeFzoWdQIxsK6U_IyQsCqeb_bcVcEQ_DR_mfqkPI3-8770h8RlXcQ1MUcnrWZnyeOflNFqz2wj63S5KvHmoqrnyIcYkPR8SXoNGJ6J0ZEnbGArJwH8JIp1cWM4NbAG5_ruPs-XmRLMdpM/s1600/screenshot6.png&quot; height=&quot;400&quot; width=&quot;208&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;
Omito el diseño de los fragments, ya que podeis ver cómo en post como los mencionados anteriormente. Y esta es la clase que por defecto nos crea Android Studio&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush:java&quot;&gt;public class fragmentIntro extends Fragment {
    // TODO: Rename parameter arguments, choose names that match
    // the fragment initialization parameters, e.g. ARG_ITEM_NUMBER
    private static final String ARG_PARAM1 = &quot;param1&quot;;
    private static final String ARG_PARAM2 = &quot;param2&quot;;

    // TODO: Rename and change types of parameters
    private String mParam1;
    private String mParam2;

    private OnFragmentInteractionListener mListener;

    /**
     * Use this factory method to create a new instance of
     * this fragment using the provided parameters.
     *
     * @param param1 Parameter 1.
     * @param param2 Parameter 2.
     * @return A new instance of fragment fragmentIntro.
     */
    // TODO: Rename and change types and number of parameters
    public static fragmentIntro newInstance(String param1, String param2) {
        fragmentIntro fragment = new fragmentIntro();
        Bundle args = new Bundle();
        args.putString(ARG_PARAM1, param1);
        args.putString(ARG_PARAM2, param2);
        fragment.setArguments(args);
        return fragment;
    }

    public fragmentIntro() {
        // Required empty public constructor
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        if (getArguments() != null) {
            mParam1 = getArguments().getString(ARG_PARAM1);
            mParam2 = getArguments().getString(ARG_PARAM2);
        }
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                                                      Bundle savedInstanceState) {

        View v = inflater.inflate(R.layout.fragment_cifrador, container, false);


        return v;
    }

    // TODO: Rename method, update argument and hook method into UI event
    public void onButtonPressed(Uri uri) {
        if (mListener != null) {
            mListener.onFragmentInteraction(uri);
        }
    }
 
    //Comentamos porque sino de momento daría error
    /*@Override
    public void onAttach(Activity activity) {
        super.onAttach(activity);
        try {
            mListener = (OnFragmentInteractionListener) activity;
        } catch (ClassCastException e) {
            throw new ClassCastException(activity.toString()
                    + &quot; must implement OnFragmentInteractionListener&quot;);
        }
    }*/

    @Override
    public void onDetach() {
        super.onDetach();
        mListener = null;
    }

    /**
     * This interface must be implemented by activities that contain this
     * fragment to allow an interaction in this fragment to be communicated
     * to the activity and potentially other fragments contained in that
     * activity.
     * * See the Android Training lesson &lt;a basics=&quot;&quot; communicating.html=&quot;&quot; developer.android.com=&quot;&quot; fragments=&quot;&quot; href=&quot;https://www.blogger.com/*&quot; http:=&quot;&quot; training=&quot;&quot;&gt;Communicating with Other Fragments&lt;/a&gt; for more information.
     */
    public interface OnFragmentInteractionListener {
        // TODO: Update argument type and name
        public void onFragmentInteraction(Uri uri);
    }

}
&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;
Aprovechamos y modificamos la función &lt;b&gt;seleccionarFragment&lt;/b&gt; para que nos vayamos moviendo por los fragment y vaya cambiando nuestro Action Bar a antojo, según este ejemplo, la opción 1 del drawer nos llevara al fragmentIntro, mientras que las demás nos llevarán al fragmentCifrador.&amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Para poder cambiar nuestro Action Bar desde cualquier fragment, que es un problema que me ha llevado un rato, basta con :&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush:java&quot;&gt;this.activity.invalidateOptionsMenu();       //PARA REFRESCAR ACTION BAR JUSTO ANTES DE CREAR EL MENU
this.actionBar = actionBar = ((android.support.v7.app.ActionBarActivity) activity).getSupportActionBar();

//EN CADA FRAGMENT GENERAMOS onCreateOptionsMenu Y AÑADIMOS menu.clear()
public class fragmentIntro extends  Fragment {
  @Override
    public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
      super.onCreateOptionsMenu(menu, inflater);
      menu.clear();    //Vaciar el menu
      inflater.inflate(R.menu.menu_main, menu);
  }

//EN CADA FRAGMENT GENERAMOS  onActivityCreated Y AÑADIMOS  setHasOptionsMenu(true); 
  @Override
    public void onActivityCreated(@Nullable Bundle savedInstanceState) {
      super.onActivityCreated(savedInstanceState);
      setHasOptionsMenu(true);        //PARA PODER MODIFICAR EL MENU
   }
}
&lt;/pre&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;No os olvideis de poner el número para que entre en el switch del MainActivity, y en la clase  configActionBAR(ActionBar menu, int opcion) en el método&lt;b&gt; ClasificarMenu&lt;/b&gt;(int opcion) agregar tantos métodos como queramos modificar los Action Bar en cada caso.&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush:java&quot;&gt;  public void instanciarObjetos (){
    contenedorPrincipal=(FrameLayout) findViewById(R.id.contenedor_principal);
    drawerLayout = (DrawerLayout) findViewById(R.id.menu_drawer);

    listaMenu = (ListView) findViewById(R.id.lista_menu);
    listaMenu.setOnItemClickListener(new AdapterView.OnItemClickListener(){
      @Override
        public void onItemClick(AdapterView parent, View view,int position, long id) {
          seleccionarFragment(position);
        }

    });

    View header=getLayoutInflater().inflate(R.layout.header_menu, null); //HEADER
    listaMenu.addHeaderView(header,null,false);

    array = new ArrayList&lt;itemsmenudrawer&gt;();
    llenarListaMenu(array);

    menuAdapter adaptador = new menuAdapter(this, array);           //ADAPTER
    listaMenu.setAdapter(adaptador);

    //PARA QUE SEA POR DEFECTO EL FRAGMENT INTRO
    seleccionarFragment(1);
    Log.e(&quot;MainActivity&quot;, &quot;PASOOOOOOOO on CREATE&quot;);
  }

  public void seleccionarFragment(int posicion){
      Log.e(&quot;MainActivity&quot;, &quot;PAS Selecciono fragment&quot;+posicion);
      boolean salida=false;
      android.support.v4.app.Fragment fragment=null;
    switch (posicion) {
      // BOTON PLAY, PRIMERA POSICION = 0
      case 1:
        fragment = new fragmentIntro();
        break;
      case 2:
        fragment = new fragmentCifrador();
        break;
      case 3:
        fragment = new fragmentImagen();
        break;
      case 4:
        fragment = new fragmentCripto();
        break;
      case 5:
        salida=true;

        //MARCAMOS EL CLICKADO
        listaMenu.setItemChecked(posicion, true);
        drawerLayout.closeDrawer(listaMenu);
        finish();
        break;

      default:  Log.e(&quot;Main Activity  &quot;, &quot;Opcion  &quot;+posicion);
    }
    //SI SE SALE DE LA APLICACIÓN, AL HACER EL CAMBIO DE FRAGMENT DARIA NULLPOINTEREXCEPTION
    if (salida==false) {
      FragmentManager fragmentManager = getSupportFragmentManager();
      fragmentManager.beginTransaction()
              .replace(R.id.contenedor_principal, fragment)
              .commit();

       listaMenu.setItemChecked(posicion, true);    //MARCAMOS EL CLICKADO
       drawerLayout.closeDrawer(listaMenu);

    }
  }
&lt;/itemsmenudrawer&gt;&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
Si todo ha ido bien, ahora cambiará el estilo de nuestro action Bar y el contenido de los botones que tiene dentro. Ya nos podemos mover por nuestros fragments sin problema. Claro está que en cada recurso menu.xml que hagamos de cada fragmento, nos tocará listar los items, además de asignarles un icono apropiado.&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;b style=&quot;color: #a5130f; font-size: x-large;&quot;&gt;&lt;br /&gt;&lt;/b&gt;
&lt;b style=&quot;color: #a5130f; font-size: x-large;&quot;&gt;&lt;br /&gt;&lt;/b&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&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/AVvXsEiRRpZG12vQsvtpe7e4sPuAucOm-GN-ju36dWDFxSXh4arthjPo2fOvNMqMI-AvggtUIV-g6S48a_l6Z2ZULMn-yTHZIFHF8_Ro9btEGeUXEDcxMjREebh-GP3LphNW_qiuRs44gjuxdgyE/s1600/screenshot8.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/AVvXsEiRRpZG12vQsvtpe7e4sPuAucOm-GN-ju36dWDFxSXh4arthjPo2fOvNMqMI-AvggtUIV-g6S48a_l6Z2ZULMn-yTHZIFHF8_Ro9btEGeUXEDcxMjREebh-GP3LphNW_qiuRs44gjuxdgyE/s1600/screenshot8.png&quot; height=&quot;317&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&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/AVvXsEgp7EEUWeHuz2O8uZKoFXMCphDe29wvuaeVdBe0t_zwlQPRq-kIayC6gP2hl_Swo5nbPWeaPq4pbBPEcDvWt9WLlDVL7wujNGeHzctFlD5AdEIonmH59ImvkxBnNLFV_7UYFB4Rxl7Otvx9/s1600/screenshot9.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/AVvXsEgp7EEUWeHuz2O8uZKoFXMCphDe29wvuaeVdBe0t_zwlQPRq-kIayC6gP2hl_Swo5nbPWeaPq4pbBPEcDvWt9WLlDVL7wujNGeHzctFlD5AdEIonmH59ImvkxBnNLFV_7UYFB4Rxl7Otvx9/s1600/screenshot9.png&quot; height=&quot;262&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;b style=&quot;color: #a5130f; font-size: x-large;&quot;&gt;&lt;br /&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div&gt;
&lt;b style=&quot;color: #a5130f; font-size: x-large;&quot;&gt;4 Creacción de Swipey tabs en un fragment&lt;/b&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Ahora vamos a conseguir un efecto muy chulo en uno de nuestros fragments, en el cifrador en concreto, vamos a insertar unas pestañas que al seleccionar cada una que no sea la misma en donde estamos, la vista se va a &quot;correr&quot; hacia un lado dejando paso a la nueva vista. Creamos 3 fragments más y añadimos a fragmentCifrador.xml el componente &lt;b&gt;ViewPager&lt;/b&gt; :&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp;&amp;lt;android.support.v4.view.ViewPager &amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp;xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot; &amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp;android:id=&quot;@+id/pager&quot; &amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp;android:layout_width=&quot;match_parent&quot; &amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp;android:layout_height=&quot;match_parent&quot; &amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;gt; &amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp;&amp;lt;/android.support.v4.view.ViewPager&amp;gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Page Adapter nueva clase
&lt;br /&gt;
&lt;pre class=&quot;brush:java&quot;&gt;/**
 * Created by makone 
 */
public class PageAdapter extends FragmentPagerAdapter
{
    public PageAdapter(FragmentManager fm) {
        super(fm);
    }

    @Override
    public android.support.v4.app.Fragment getItem(int position) {
        // TODO Auto-generated method stub
        switch (position) {
            case 0:
                return new fragmentNew1();
            case 1:
                return new fragmentNew2();
            case 2:
                return new fragmentNew3();
            default:
                break;
        }
        return null;
    }

    @Override
    public int getCount() {
        return 3;
    }
}
&lt;/pre&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Así que nuestro FragmentCifrador se queda así, claro que hay que crear fragmentNew1, fragmentNew2, fragmentNew3, modificarlos gráficamente y posteriormente ver el efecto.&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
Tenemos también que prestar atención al método &lt;b&gt;onDetach()&lt;/b&gt;, ya que cada vez que se inicia el fragment, se añaden tabs, es importante que en cada fragment por el que naveguemos lleve las mismas líneas de código en el mismo método &lt;b&gt;onDetach()&lt;/b&gt; que a continuación :
&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush:java&quot;&gt;package FRAGMENTS.FRAGMENTS_CIFRADOR;

import android.app.Activity;
//import android.app.Fragment;
import android.net.Uri;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentTransaction;
import android.support.v4.view.ViewPager;
import android.support.v7.app.ActionBarActivity;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.View;
import android.view.ViewGroup;

import GESTION.configActionBAR;
import JAVAEE.PageAdapter;
import texto.cifrador.makone.cifradortexto.R;

public class fragmentCifrador extends  Fragment implements android.support.v7.app.ActionBar.TabListener{
  // TODO: Rename parameter arguments, choose names that match
  // the fragment initialization parameters, e.g. ARG_ITEM_NUMBER
  private static final String ARG_PARAM1 = &quot;param1&quot;;
  private static final String ARG_PARAM2 = &quot;param2&quot;;

  // TODO: Rename and change types of parameters
  private String mParam1;
  private String mParam2;

  private OnFragmentInteractionListener mListener;

  public static android.support.v7.app.ActionBar actionBar;
  public configActionBAR CAB;
  Activity host;

  ViewPager viewpager;
  PageAdapter ft;

  // TODO: Rename and change types and number of parameters
  public static fragmentCifrador newInstance(String param1, String param2) {
    fragmentCifrador fragment = new fragmentCifrador();
    Bundle args = new Bundle();
    args.putString(ARG_PARAM1, param1);
    args.putString(ARG_PARAM2, param2);
    fragment.setArguments(args);
    return fragment;
  }

  public fragmentCifrador() {
    // Required empty public constructor
  }

  @Override
    public void onActivityCreated(@Nullable Bundle savedInstanceState) {
      super.onActivityCreated(savedInstanceState);
      setHasOptionsMenu(true);        //PARA PODER MODIFICAR EL MENU
    }

  @Override
    public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      if (getArguments() != null) {
        mParam1 = getArguments().getString(ARG_PARAM1);
        mParam2 = getArguments().getString(ARG_PARAM2);
      }
    }

  @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {

      View v = inflater.inflate(R.layout.fragment_cifrador, container, false);
      aniadirTabs(v);

      return v;
    }

  private void aniadirTabs(View v) {
   //RECUPERAMOS CONTEXTO APLICACION
   // host = (Activity) activity.getApplicationContext();
   host = (Activity) v.getContext();
   actionBar = ((ActionBarActivity) host).getSupportActionBar();
   CAB = new configActionBAR(host, 2);
   SacarPestanias (v,host);
 }

  public void SacarPestanias (View v,Activity activity){
    viewpager = (ViewPager) v.findViewById(R.id.pager);
    //ft = new PageAdapter(getSupportFragmentManager());
    //Aqui le añadimos los fragments donde nos queremos mover
    ft = new PageAdapter(((android.support.v7.app.ActionBarActivity) activity)
        .getSupportFragmentManager());
    viewpager.setAdapter(ft);
    actionBar.setNavigationMode(android.app.ActionBar.NAVIGATION_MODE_TABS);
    actionBar.addTab(actionBar.newTab().setText(&quot;CASAR&quot;).setTabListener(this));
    actionBar.addTab(actionBar.newTab().setText(&quot;Estadisticas&quot;).setTabListener(this));
    actionBar.addTab(actionBar.newTab().setText(&quot;Editor&quot;).setTabListener(this));

    viewpager.setOnPageChangeListener(new ViewPager.OnPageChangeListener() {
      @Override
        public void onPageSelected(int arg0) {
                actionBar.setSelectedNavigationItem(arg0);
            }
          @Override
             public void onPageScrolled(int arg0, float arg1, int arg2) {
                // TODO Auto-generated method stub
            }

            @Override
              public void onPageScrollStateChanged(int arg0) {
                // TODO Auto-generated method stub
            }
        });
    }

  @Override
    public void onTabSelected(android.support.v7.app.ActionBar.Tab tab, FragmentTransaction fragmentTransaction) {
      viewpager.setCurrentItem(tab.getPosition());
    }

  @Override
    public void onTabUnselected(android.support.v7.app.ActionBar.Tab tab, FragmentTransaction fragmentTransaction) { }

  @Override
    public void onTabReselected(android.support.v7.app.ActionBar.Tab tab, FragmentTransaction fragmentTransaction) { }

  // TODO: Rename method, update argument and hook method into UI event
  public void onButtonPressed(Uri uri) {
    if (mListener != null) {
       mListener.onFragmentInteraction(uri);
    }
  }

  @Override
    public void onAttach(Activity activity) {
      super.onAttach(activity);
      /*  try {
            mListener = (OnFragmentInteractionListener) activity;
        } catch (ClassCastException e) {
            throw new ClassCastException(activity.toString()
                    + &quot; must implement OnFragmentInteractionListener&quot;);*/
    }

  @Override
    public void onDetach() {
      super.onDetach();
      mListener = null;
      actionBar = ((ActionBarActivity) host).getSupportActionBar();
   actionBar.removeAllTabs();
      actionBar.setNavigationMode(android.app.ActionBar.NAVIGATION_MODE_STANDARD); //PARA BORRAR PESTAÑERO
    }

  public interface OnFragmentInteractionListener {
    // TODO: Update argument type and name
    public void onFragmentInteraction(Uri uri);
  }

  @Override
    public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
      super.onCreateOptionsMenu(menu, inflater);
      menu.clear();
      inflater.inflate(R.menu.menu_cifradores, menu);
    }
}
&lt;/pre&gt;
&lt;br /&gt;
&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/AVvXsEhBPHOYqZkG6XuCNLT0MyfB2JQnBFt2j5xQqLVRSvRhikkAz-9mzkPqIpmZXNeH42ZV52YO71NrBGYh5v1juQNnG9xm7Vv-mDCFoF0Ynwl2sEGjxqWaCgBnNWGmFwfnVKBWRqJ62LM7EocC/s1600/screenshot7.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/AVvXsEhBPHOYqZkG6XuCNLT0MyfB2JQnBFt2j5xQqLVRSvRhikkAz-9mzkPqIpmZXNeH42ZV52YO71NrBGYh5v1juQNnG9xm7Vv-mDCFoF0Ynwl2sEGjxqWaCgBnNWGmFwfnVKBWRqJ62LM7EocC/s1600/screenshot7.png&quot; height=&quot;312&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Podeis descargar el código fuente de thebestandroide con sólo compartir en facebook,twitter,linkedin o suscribirte a nuestro canal RSS más abajo.&amp;nbsp;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;script language=&quot;JavaScript&quot;&gt;
function muestra_oculta(id,tipo){
 var resultado=tipo
 var dir = document.location.href;
 var tit = document.title;
 var tit2 = encodeURIComponent(tit);
 var url =&quot;&quot;;
if(resultado==1){
 var url =&quot;http://www.facebook.com/share.php?u=&quot;+dir+&quot;&amp;t=&quot;+tit2
 window.open(url, &#39;TheBestAndroide&#39;);
}
if(resultado==2){
  var url =&quot;http://twitter.com/home?status=Estoy en &quot;+dir+&quot; leyendo &quot;+tit2
  window.open(url, &#39;TheBestAndroide&#39;);
}
if(resultado==3){
 var url =&quot;http://www.linkedin.com/shareArticle?mini=true&amp;url=&quot;+dir+&quot;&amp;title=&quot;+tit2+&quot;&amp;source=http://thebestandroide.blogspot.com.es/&quot;;
  window.open(url, &#39;TheBestAndroide&#39;);
}
if(resultado==4){
  var url =&quot;http://feeds.feedburner.com/Thebestandroide&quot;
  window.open(url, &#39;TheBestAndroide&#39;);
}

if (document.getElementById){ //se obtiene el id
var el = document.getElementById(id); //se define la variable &quot;el&quot; igual a nuestro div
el.style.display = (el.style.display == &#39;none&#39;) ? &#39;block&#39; : &#39;none&#39;; //damos un atributo display:none que oculta el div
}
}
window.onload = function(){/*hace que se cargue la función lo que predetermina que div estará oculto hasta llamar a la función nuevamente*/
muestra_oculta(&#39;contenido_a_mostrar&#39;);/* &quot;contenido_a_mostrar&quot; es el nombre que le dimos al DIV */
}
&lt;/script&gt;

&lt;br /&gt;
&lt;table style=&quot;width: 260px;&quot;&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;img alt=&quot;Compartir&quot; border=&quot;0&quot; height=&quot;50&quot; onclick=&quot;muestra_oculta(&#39;contenido_a_mostrar&#39;,1)&quot; onmouseout=&quot;this.src=&#39;https://dl.dropboxusercontent.com/u/28565502/images/redface.png&#39;;&quot; onmouseover=&quot;this.src=&#39;https://dl.dropboxusercontent.com/u/28565502/images/redfacehover.png&#39;;&quot; src=&quot;https://dl.dropboxusercontent.com/u/28565502/images/redface.png&quot; style=&quot;margin-right: 10px;&quot; width=&quot;50&quot; /&gt;

&lt;img alt=&quot;Compartir&quot; border=&quot;0&quot; height=&quot;50&quot; onclick=&quot;muestra_oculta(&#39;contenido_a_mostrar&#39;,2)&quot; onmouseout=&quot;this.src=&#39;https://dl.dropboxusercontent.com/u/28565502/images/twitterRed.png&#39;;&quot; onmouseover=&quot;this.src=&#39;https://dl.dropboxusercontent.com/u/28565502/images/twitterRedhover.png&#39;;&quot; src=&quot;https://dl.dropboxusercontent.com/u/28565502/images/twitterRed.png&quot; style=&quot;margin-right: 10px;&quot; width=&quot;50&quot; /&gt;

&lt;img alt=&quot;Compartir&quot; border=&quot;0&quot; height=&quot;50&quot; onclick=&quot;muestra_oculta(&#39;contenido_a_mostrar&#39;,3)&quot; onmouseout=&quot;this.src=&#39;https://dl.dropboxusercontent.com/u/28565502/images/LinkedIn-Logo.png&#39;;&quot; onmouseover=&quot;this.src=&#39;https://dl.dropboxusercontent.com/u/28565502/images/LinkedIn-Logohover.png&#39;;&quot; src=&quot;https://dl.dropboxusercontent.com/u/28565502/images/LinkedIn-Logo.png&quot; style=&quot;margin-right: 10px;&quot; width=&quot;50&quot; /&gt;

&lt;img alt=&quot;Compartir&quot; border=&quot;0&quot; height=&quot;50&quot; onclick=&quot;muestra_oculta(&#39;contenido_a_mostrar&#39;,4)&quot; onmouseout=&quot;this.src=&#39;https://dl.dropboxusercontent.com/u/28565502/images/rss.png&#39;;&quot; onmouseover=&quot;this.src=&#39;https://dl.dropboxusercontent.com/u/28565502/images/rsshover.png&#39;;&quot; src=&quot;https://dl.dropboxusercontent.com/u/28565502/images/rss.png&quot; style=&quot;margin-right: 10px;&quot; width=&quot;50&quot; /&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br /&gt;
&lt;div id=&quot;contenido_a_mostrar&quot;&gt;
&lt;a href=&quot;https://dl.dropbox.com/s/v1kv4f69st3haa7/Cifradortexto.rar?dl=0&quot; target=&quot;_blank&quot;&gt;Descargar archivo&lt;/a&gt;.
&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;</description><link>http://thebestandroide.blogspot.com/2015/02/drawer-menu-con-action-bar-y-tabs.html</link><author>noreply@blogger.com (David)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhKoXalujCTLG24YgSWdi2MEfSHshL2WDMJE0RL2L8_pRto-P6AsYKZMJ_n4lC0NrJbexesYEUCS8wcKm1EHxu4tHJNAOFuCzyDCqyy7SZe89iBaY_pC165yqTicspwXp6w2KFnUAokq_qJ/s72-c/nav.jpg" height="72" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-1686662779713559896.post-8638659502640506909</guid><pubDate>Mon, 09 Feb 2015 15:49:00 +0000</pubDate><atom:updated>2015-02-09T16:08:42.225+00:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">android botones fisicos</category><category domain="http://www.blogger.com/atom/ns#">android keyEvent botones</category><category domain="http://www.blogger.com/atom/ns#">android phisical buttons</category><title>Botones dispositivo Android</title><description>&lt;a href=&quot;http://thebestandroide.blogspot.com.es/&quot;&gt;&lt;span style=&quot;color: #a5130f;&quot;&gt;Blog &lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #a5130f;&quot;&gt;&lt;a href=&quot;http://thebestandroide.blogspot.com/2014/06/lista-soluciones.html&quot;&gt; &amp;gt;Lista Soluciones &amp;gt;&lt;/a&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #a5130f;&quot;&gt;&lt;b&gt;Botones dispositivo Android&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;b style=&quot;color: #a5130f;&quot;&gt;&lt;span style=&quot;font-size: x-large;&quot;&gt;Tabla de botones fisicos del dispositivo Android&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&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/AVvXsEhLJ5Fo-dQJazm_3As9UUUsNY_97WSwZrAHkxGK3f1tIh7EJ8hlsFPFy77eDmjQjZKx57TzicyMnrEa76APfD7QnpTxufSHMCL515zA6-sLlo3XVJ1Stj8WUkXYWB2Yl0gudCroPkNpwka8/s1600/img11.jpg&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/AVvXsEhLJ5Fo-dQJazm_3As9UUUsNY_97WSwZrAHkxGK3f1tIh7EJ8hlsFPFy77eDmjQjZKx57TzicyMnrEa76APfD7QnpTxufSHMCL515zA6-sLlo3XVJ1Stj8WUkXYWB2Yl0gudCroPkNpwka8/s1600/img11.jpg&quot; height=&quot;151&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;br /&gt;
A continuación muestro una tabla con 3 columnas, la primera es el nombre del botón, ya sea del emulador o del dispositivo, la segunda es la tecla rápida a introducir con el teclado del ordenador para el acceso a la función como si se pulsara en el dispositivo virtual, mientras que la tercera nos vale para referenciarla en la programación Java,normalmente en el método onOptionsItemSelected  

(ej:  switch (item.getItemId()) { case android.R.id.home return true;)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;table border=&quot;0&quot; cellspacing=&quot;0&quot; cols=&quot;3&quot; frame=&quot;VOID&quot; rules=&quot;NONE&quot;&gt;
 &lt;colgroup&gt;&lt;col width=&quot;259&quot;&gt;&lt;/col&gt;&lt;col width=&quot;190&quot;&gt;&lt;/col&gt;&lt;col width=&quot;265&quot;&gt;&lt;/col&gt;&lt;/colgroup&gt;
 &lt;tbody&gt;
&lt;tr&gt;
   &lt;td align=&quot;CENTER&quot; bgcolor=&quot;#999999&quot; height=&quot;44&quot; sdnum=&quot;1033;1033;General&quot; valign=&quot;TOP&quot; width=&quot;259&quot;&gt;&lt;b&gt;&lt;span style=&quot;color: white; font-family: Arial; font-size: medium;&quot;&gt;Emulated Device Key&lt;/span&gt;&lt;/b&gt;&lt;/td&gt;
   &lt;td align=&quot;CENTER&quot; bgcolor=&quot;#999999&quot; sdnum=&quot;1033;1033;General&quot; style=&quot;border-left: 3px solid #000000; border-right: 3px solid #000000;&quot; valign=&quot;TOP&quot; width=&quot;190&quot;&gt;&lt;b&gt;&lt;span style=&quot;color: white; font-family: Arial; font-size: medium;&quot;&gt;Keyboard Key&lt;/span&gt;&lt;/b&gt;&lt;/td&gt;
   &lt;td align=&quot;CENTER&quot; bgcolor=&quot;#999999&quot; sdnum=&quot;1033;1033;General&quot; valign=&quot;TOP&quot; width=&quot;265&quot;&gt;&lt;b&gt;&lt;span style=&quot;color: white; font-family: Arial; font-size: medium;&quot;&gt;KeyEvent&lt;/span&gt;&lt;/b&gt;&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
   &lt;td align=&quot;LEFT&quot; bgcolor=&quot;#E6B9B8&quot; height=&quot;18&quot; sdnum=&quot;1033;1033;General&quot; valign=&quot;TOP&quot;&gt;&lt;b&gt;&lt;span style=&quot;color: black; font-family: Arial;&quot;&gt;Home&lt;/span&gt;&lt;/b&gt;&lt;/td&gt;
   &lt;td align=&quot;LEFT&quot; bgcolor=&quot;#E6B9B8&quot; sdnum=&quot;1033;1033;General&quot; style=&quot;border-left: 3px solid #000000; border-right: 3px solid #000000;&quot; valign=&quot;TOP&quot;&gt;&lt;b&gt;&lt;span style=&quot;color: black; font-family: Arial;&quot;&gt;HOME&lt;/span&gt;&lt;/b&gt;&lt;/td&gt;
   &lt;td align=&quot;LEFT&quot; bgcolor=&quot;#E6B9B8&quot; sdnum=&quot;1033;1033;General&quot; valign=&quot;MIDDLE&quot;&gt;&lt;b&gt;&lt;span style=&quot;color: black; font-family: Arial;&quot;&gt;&amp;nbsp;KeyEvent.KEYCODE_HOME&lt;/span&gt;&lt;/b&gt;&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
   &lt;td align=&quot;LEFT&quot; bgcolor=&quot;#C0504D&quot; height=&quot;18&quot; sdnum=&quot;1033;1033;General&quot; valign=&quot;TOP&quot;&gt;&lt;b&gt;&lt;span style=&quot;color: white; font-family: Arial;&quot;&gt;Menu (left softkey)&lt;/span&gt;&lt;/b&gt;&lt;/td&gt;
   &lt;td align=&quot;LEFT&quot; bgcolor=&quot;#C0504D&quot; sdnum=&quot;1033;1033;General&quot; style=&quot;border-left: 3px solid #000000; border-right: 3px solid #000000;&quot; valign=&quot;TOP&quot;&gt;&lt;b&gt;&lt;span style=&quot;color: white; font-family: Arial;&quot;&gt;F2&amp;nbsp;or&amp;nbsp;Page-up button&lt;/span&gt;&lt;/b&gt;&lt;/td&gt;
   &lt;td align=&quot;LEFT&quot; bgcolor=&quot;#C0504D&quot; sdnum=&quot;1033;1033;General&quot; valign=&quot;MIDDLE&quot;&gt;&lt;b&gt;&lt;span style=&quot;color: white; font-family: Arial;&quot;&gt;&amp;nbsp;KeyEvent.KEYCODE_MENU&lt;/span&gt;&lt;/b&gt;&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
   &lt;td align=&quot;LEFT&quot; bgcolor=&quot;#E6B9B8&quot; height=&quot;18&quot; sdnum=&quot;1033;1033;General&quot; valign=&quot;TOP&quot;&gt;&lt;b&gt;&lt;span style=&quot;color: black; font-family: Arial;&quot;&gt;Star (right softkey)&lt;/span&gt;&lt;/b&gt;&lt;/td&gt;
   &lt;td align=&quot;LEFT&quot; bgcolor=&quot;#E6B9B8&quot; sdnum=&quot;1033;1033;General&quot; style=&quot;border-left: 3px solid #000000; border-right: 3px solid #000000;&quot; valign=&quot;TOP&quot;&gt;&lt;b&gt;&lt;span style=&quot;color: black; font-family: Arial;&quot;&gt;Shift-F2&amp;nbsp;or&amp;nbsp;Page Down&lt;/span&gt;&lt;/b&gt;&lt;/td&gt;
   &lt;td align=&quot;LEFT&quot; bgcolor=&quot;#E6B9B8&quot; sdnum=&quot;1033;1033;General&quot; valign=&quot;BOTTOM&quot;&gt;&lt;b&gt;&lt;span style=&quot;color: black; font-family: Calibri;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/b&gt;&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
   &lt;td align=&quot;LEFT&quot; bgcolor=&quot;#C0504D&quot; height=&quot;18&quot; sdnum=&quot;1033;1033;General&quot; valign=&quot;TOP&quot;&gt;&lt;b&gt;&lt;span style=&quot;color: white; font-family: Arial;&quot;&gt;Back&lt;/span&gt;&lt;/b&gt;&lt;/td&gt;
   &lt;td align=&quot;LEFT&quot; bgcolor=&quot;#C0504D&quot; sdnum=&quot;1033;1033;General&quot; style=&quot;border-left: 3px solid #000000; border-right: 3px solid #000000;&quot; valign=&quot;TOP&quot;&gt;&lt;b&gt;&lt;span style=&quot;color: white; font-family: Arial;&quot;&gt;ESC&lt;/span&gt;&lt;/b&gt;&lt;/td&gt;
   &lt;td align=&quot;LEFT&quot; bgcolor=&quot;#C0504D&quot; sdnum=&quot;1033;1033;General&quot; valign=&quot;MIDDLE&quot;&gt;&lt;b&gt;&lt;span style=&quot;color: white; font-family: Arial;&quot;&gt;&amp;nbsp;KeyEvent.KEYCODE_BACK&lt;/span&gt;&lt;/b&gt;&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
   &lt;td align=&quot;LEFT&quot; bgcolor=&quot;#E6B9B8&quot; height=&quot;18&quot; sdnum=&quot;1033;1033;General&quot; valign=&quot;TOP&quot;&gt;&lt;b&gt;&lt;span style=&quot;color: black; font-family: Arial;&quot;&gt;Call/dial button&lt;/span&gt;&lt;/b&gt;&lt;/td&gt;
   &lt;td align=&quot;LEFT&quot; bgcolor=&quot;#E6B9B8&quot; sdnum=&quot;1033;1033;General&quot; style=&quot;border-left: 3px solid #000000; border-right: 3px solid #000000;&quot; valign=&quot;TOP&quot;&gt;&lt;b&gt;&lt;span style=&quot;color: black; font-family: Arial;&quot;&gt;F3&lt;/span&gt;&lt;/b&gt;&lt;/td&gt;
   &lt;td align=&quot;LEFT&quot; bgcolor=&quot;#E6B9B8&quot; sdnum=&quot;1033;1033;General&quot; valign=&quot;BOTTOM&quot;&gt;&lt;b&gt;&lt;span style=&quot;color: black; font-family: Calibri;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/b&gt;&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
   &lt;td align=&quot;LEFT&quot; bgcolor=&quot;#C0504D&quot; height=&quot;18&quot; sdnum=&quot;1033;1033;General&quot; valign=&quot;TOP&quot;&gt;&lt;b&gt;&lt;span style=&quot;color: white; font-family: Arial;&quot;&gt;Hangup/end call button&lt;/span&gt;&lt;/b&gt;&lt;/td&gt;
   &lt;td align=&quot;LEFT&quot; bgcolor=&quot;#C0504D&quot; sdnum=&quot;1033;1033;General&quot; style=&quot;border-left: 3px solid #000000; border-right: 3px solid #000000;&quot; valign=&quot;TOP&quot;&gt;&lt;b&gt;&lt;span style=&quot;color: white; font-family: Arial;&quot;&gt;F4&lt;/span&gt;&lt;/b&gt;&lt;/td&gt;
   &lt;td align=&quot;LEFT&quot; bgcolor=&quot;#C0504D&quot; sdnum=&quot;1033;1033;General&quot; valign=&quot;BOTTOM&quot;&gt;&lt;b&gt;&lt;span style=&quot;color: white; font-family: Calibri;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/b&gt;&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
   &lt;td align=&quot;LEFT&quot; bgcolor=&quot;#E6B9B8&quot; height=&quot;18&quot; sdnum=&quot;1033;1033;General&quot; valign=&quot;TOP&quot;&gt;&lt;b&gt;&lt;span style=&quot;color: black; font-family: Arial;&quot;&gt;Search&lt;/span&gt;&lt;/b&gt;&lt;/td&gt;
   &lt;td align=&quot;LEFT&quot; bgcolor=&quot;#E6B9B8&quot; sdnum=&quot;1033;1033;General&quot; style=&quot;border-left: 3px solid #000000; border-right: 3px solid #000000;&quot; valign=&quot;TOP&quot;&gt;&lt;b&gt;&lt;span style=&quot;color: black; font-family: Arial;&quot;&gt;F5&lt;/span&gt;&lt;/b&gt;&lt;/td&gt;
   &lt;td align=&quot;LEFT&quot; bgcolor=&quot;#E6B9B8&quot; sdnum=&quot;1033;1033;General&quot; valign=&quot;MIDDLE&quot;&gt;&lt;b&gt;&lt;span style=&quot;color: black; font-family: Arial;&quot;&gt;KeyEvent.KEYCODE_SEARCH&lt;/span&gt;&lt;/b&gt;&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
   &lt;td align=&quot;LEFT&quot; bgcolor=&quot;#C0504D&quot; height=&quot;18&quot; sdnum=&quot;1033;1033;General&quot; valign=&quot;TOP&quot;&gt;&lt;b&gt;&lt;span style=&quot;color: white; font-family: Arial;&quot;&gt;Power button&lt;/span&gt;&lt;/b&gt;&lt;/td&gt;
   &lt;td align=&quot;LEFT&quot; bgcolor=&quot;#C0504D&quot; sdnum=&quot;1033;1033;General&quot; style=&quot;border-left: 3px solid #000000; border-right: 3px solid #000000;&quot; valign=&quot;TOP&quot;&gt;&lt;b&gt;&lt;span style=&quot;color: white; font-family: Arial;&quot;&gt;F7&lt;/span&gt;&lt;/b&gt;&lt;/td&gt;
   &lt;td align=&quot;LEFT&quot; bgcolor=&quot;#C0504D&quot; sdnum=&quot;1033;1033;General&quot; valign=&quot;MIDDLE&quot;&gt;&lt;b&gt;&lt;span style=&quot;color: white; font-family: Arial;&quot;&gt;KeyEvent.KEYCODE_POWER&lt;/span&gt;&lt;/b&gt;&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
   &lt;td align=&quot;LEFT&quot; bgcolor=&quot;#E6B9B8&quot; height=&quot;18&quot; sdnum=&quot;1033;1033;General&quot; valign=&quot;TOP&quot;&gt;&lt;b&gt;&lt;span style=&quot;color: black; font-family: Arial;&quot;&gt;Audio volume up button&lt;/span&gt;&lt;/b&gt;&lt;/td&gt;
   &lt;td align=&quot;LEFT&quot; bgcolor=&quot;#E6B9B8&quot; sdnum=&quot;1033;1033;General&quot; style=&quot;border-left: 3px solid #000000; border-right: 3px solid #000000;&quot; valign=&quot;TOP&quot;&gt;&lt;b&gt;&lt;span style=&quot;color: black; font-family: Arial;&quot;&gt;KEYPAD_PLUS, Ctrl-F5&lt;/span&gt;&lt;/b&gt;&lt;/td&gt;
   &lt;td align=&quot;LEFT&quot; bgcolor=&quot;#E6B9B8&quot; sdnum=&quot;1033;1033;General&quot; valign=&quot;MIDDLE&quot;&gt;&lt;b&gt;&lt;span style=&quot;color: black; font-family: Arial;&quot;&gt;KeyEvent.KEYCODE_VOLUMEN_UP&lt;/span&gt;&lt;/b&gt;&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
   &lt;td align=&quot;LEFT&quot; bgcolor=&quot;#C0504D&quot; height=&quot;84&quot; sdnum=&quot;1033;1033;General&quot; valign=&quot;TOP&quot;&gt;&lt;b&gt;&lt;span style=&quot;color: white; font-family: Arial;&quot;&gt;Audio volume down button&lt;/span&gt;&lt;/b&gt;&lt;/td&gt;
   &lt;td align=&quot;LEFT&quot; bgcolor=&quot;#C0504D&quot; sdnum=&quot;1033;1033;General&quot; style=&quot;border-left: 3px solid #000000; border-right: 3px solid #000000;&quot; valign=&quot;TOP&quot;&gt;&lt;b&gt;&lt;span style=&quot;color: white; font-family: Arial;&quot;&gt;KEYPAD_MINUS, Ctrl-F6&lt;/span&gt;&lt;/b&gt;&lt;/td&gt;
   &lt;td align=&quot;LEFT&quot; bgcolor=&quot;#C0504D&quot; sdnum=&quot;1033;1033;General&quot; valign=&quot;BOTTOM&quot;&gt;&lt;b&gt;&lt;span style=&quot;color: white; font-family: Calibri;&quot;&gt;KEYCODE_VOLUMEN_DOWN&lt;/span&gt;&lt;/b&gt;&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
   &lt;td align=&quot;LEFT&quot; bgcolor=&quot;#E6B9B8&quot; height=&quot;18&quot; sdnum=&quot;1033;1033;General&quot; valign=&quot;TOP&quot;&gt;&lt;b&gt;&lt;span style=&quot;color: black; font-family: Arial;&quot;&gt;Camera button&lt;/span&gt;&lt;/b&gt;&lt;/td&gt;
   &lt;td align=&quot;LEFT&quot; bgcolor=&quot;#E6B9B8&quot; sdnum=&quot;1033;1033;General&quot; style=&quot;border-left: 3px solid #000000; border-right: 3px solid #000000;&quot; valign=&quot;TOP&quot;&gt;&lt;b&gt;&lt;span style=&quot;color: black; font-family: Arial;&quot;&gt;Ctrl-KEYPAD_5, Ctrl-F3&lt;/span&gt;&lt;/b&gt;&lt;/td&gt;
   &lt;td align=&quot;LEFT&quot; bgcolor=&quot;#E6B9B8&quot; sdnum=&quot;1033;1033;General&quot; valign=&quot;MIDDLE&quot;&gt;&lt;b&gt;&lt;span style=&quot;color: black; font-family: Arial;&quot;&gt;KeyEvent.KEYCODE_CAMERA&lt;/span&gt;&lt;/b&gt;&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
   &lt;td align=&quot;LEFT&quot; bgcolor=&quot;#C0504D&quot; height=&quot;47&quot; sdnum=&quot;1033;1033;General&quot; valign=&quot;TOP&quot;&gt;&lt;b&gt;&lt;span style=&quot;color: white; font-family: Arial;&quot;&gt;Switch to previous layout &lt;br /&gt;orientation (for example, &lt;br /&gt;portrait, landscape)&lt;/span&gt;&lt;/b&gt;&lt;/td&gt;
   &lt;td align=&quot;LEFT&quot; bgcolor=&quot;#C0504D&quot; sdnum=&quot;1033;1033;General&quot; style=&quot;border-left: 3px solid #000000; border-right: 3px solid #000000;&quot; valign=&quot;TOP&quot;&gt;&lt;b&gt;&lt;span style=&quot;color: white; font-family: Arial;&quot;&gt;KEYPAD_7, Ctrl-F11&lt;/span&gt;&lt;/b&gt;&lt;/td&gt;
   &lt;td align=&quot;LEFT&quot; bgcolor=&quot;#C0504D&quot; sdnum=&quot;1033;1033;General&quot; valign=&quot;BOTTOM&quot;&gt;&lt;b&gt;&lt;span style=&quot;color: white; font-family: Calibri;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/b&gt;&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
   &lt;td align=&quot;LEFT&quot; bgcolor=&quot;#E6B9B8&quot; height=&quot;52&quot; sdnum=&quot;1033;1033;General&quot; valign=&quot;TOP&quot;&gt;&lt;b&gt;&lt;span style=&quot;color: black; font-family: Arial;&quot;&gt;Switch to next layout &lt;br /&gt;orientation (for example, portrait, landscape)&lt;/span&gt;&lt;/b&gt;&lt;/td&gt;
   &lt;td align=&quot;LEFT&quot; bgcolor=&quot;#E6B9B8&quot; sdnum=&quot;1033;1033;General&quot; style=&quot;border-left: 3px solid #000000; border-right: 3px solid #000000;&quot; valign=&quot;TOP&quot;&gt;&lt;b&gt;&lt;span style=&quot;color: black; font-family: Arial;&quot;&gt;KEYPAD_9, Ctrl-F12&lt;/span&gt;&lt;/b&gt;&lt;/td&gt;
   &lt;td align=&quot;LEFT&quot; bgcolor=&quot;#E6B9B8&quot; sdnum=&quot;1033;1033;General&quot; valign=&quot;BOTTOM&quot;&gt;&lt;b&gt;&lt;span style=&quot;color: black; font-family: Calibri;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/b&gt;&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
   &lt;td align=&quot;LEFT&quot; bgcolor=&quot;#C0504D&quot; height=&quot;33&quot; sdnum=&quot;1033;1033;General&quot; valign=&quot;TOP&quot;&gt;&lt;b&gt;&lt;span style=&quot;color: white; font-family: Arial;&quot;&gt;Toggle cell networking on/off&lt;/span&gt;&lt;/b&gt;&lt;/td&gt;
   &lt;td align=&quot;LEFT&quot; bgcolor=&quot;#C0504D&quot; sdnum=&quot;1033;1033;General&quot; style=&quot;border-left: 3px solid #000000; border-right: 3px solid #000000;&quot; valign=&quot;TOP&quot;&gt;&lt;b&gt;&lt;span style=&quot;color: white; font-family: Arial;&quot;&gt;F8&lt;/span&gt;&lt;/b&gt;&lt;/td&gt;
   &lt;td align=&quot;LEFT&quot; bgcolor=&quot;#C0504D&quot; sdnum=&quot;1033;1033;General&quot; valign=&quot;BOTTOM&quot;&gt;&lt;b&gt;&lt;span style=&quot;color: white; font-family: Calibri;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/b&gt;&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
   &lt;td align=&quot;LEFT&quot; bgcolor=&quot;#E6B9B8&quot; height=&quot;36&quot; sdnum=&quot;1033;1033;General&quot; valign=&quot;TOP&quot;&gt;&lt;b&gt;&lt;span style=&quot;color: black; font-family: Arial;&quot;&gt;Toggle code profiling&lt;/span&gt;&lt;/b&gt;&lt;/td&gt;
   &lt;td align=&quot;LEFT&quot; bgcolor=&quot;#E6B9B8&quot; sdnum=&quot;1033;1033;General&quot; style=&quot;border-left: 3px solid #000000; border-right: 3px solid #000000;&quot; valign=&quot;TOP&quot;&gt;&lt;b&gt;&lt;span style=&quot;color: black; font-family: Arial;&quot;&gt;F9 (only with&amp;nbsp;-trace&lt;br /&gt;startup option)&lt;/span&gt;&lt;/b&gt;&lt;/td&gt;
   &lt;td align=&quot;LEFT&quot; bgcolor=&quot;#E6B9B8&quot; sdnum=&quot;1033;1033;General&quot; valign=&quot;BOTTOM&quot;&gt;&lt;b&gt;&lt;span style=&quot;color: black; font-family: Calibri;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/b&gt;&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
   &lt;td align=&quot;LEFT&quot; bgcolor=&quot;#C0504D&quot; height=&quot;29&quot; sdnum=&quot;1033;1033;General&quot; valign=&quot;TOP&quot;&gt;&lt;b&gt;&lt;span style=&quot;color: white; font-family: Arial;&quot;&gt;Toggle fullscreen mode&lt;/span&gt;&lt;/b&gt;&lt;/td&gt;
   &lt;td align=&quot;LEFT&quot; bgcolor=&quot;#C0504D&quot; sdnum=&quot;1033;1033;General&quot; style=&quot;border-left: 3px solid #000000; border-right: 3px solid #000000;&quot; valign=&quot;TOP&quot;&gt;&lt;b&gt;&lt;span style=&quot;color: white; font-family: Arial;&quot;&gt;Alt-Enter&lt;/span&gt;&lt;/b&gt;&lt;/td&gt;
   &lt;td align=&quot;LEFT&quot; bgcolor=&quot;#C0504D&quot; sdnum=&quot;1033;1033;General&quot; valign=&quot;BOTTOM&quot;&gt;&lt;b&gt;&lt;span style=&quot;color: white; font-family: Calibri;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/b&gt;&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
   &lt;td align=&quot;LEFT&quot; bgcolor=&quot;#E6B9B8&quot; height=&quot;41&quot; sdnum=&quot;1033;1033;General&quot; valign=&quot;TOP&quot;&gt;&lt;b&gt;&lt;span style=&quot;color: black; font-family: Arial;&quot;&gt;Toggle trackball mode&lt;/span&gt;&lt;/b&gt;&lt;/td&gt;
   &lt;td align=&quot;LEFT&quot; bgcolor=&quot;#E6B9B8&quot; sdnum=&quot;1033;1033;General&quot; style=&quot;border-left: 3px solid #000000; border-right: 3px solid #000000;&quot; valign=&quot;TOP&quot;&gt;&lt;b&gt;&lt;span style=&quot;color: black; font-family: Arial;&quot;&gt;F6&lt;/span&gt;&lt;/b&gt;&lt;/td&gt;
   &lt;td align=&quot;LEFT&quot; bgcolor=&quot;#E6B9B8&quot; sdnum=&quot;1033;1033;General&quot; valign=&quot;BOTTOM&quot;&gt;&lt;b&gt;&lt;span style=&quot;color: black; font-family: Calibri;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/b&gt;&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
   &lt;td align=&quot;LEFT&quot; bgcolor=&quot;#C0504D&quot; height=&quot;54&quot; sdnum=&quot;1033;1033;General&quot; valign=&quot;TOP&quot;&gt;&lt;b&gt;&lt;span style=&quot;color: white; font-family: Arial;&quot;&gt;Enter trackball mode temporarily&lt;br /&gt; (while key is pressed)&lt;/span&gt;&lt;/b&gt;&lt;/td&gt;
   &lt;td align=&quot;LEFT&quot; bgcolor=&quot;#C0504D&quot; sdnum=&quot;1033;1033;General&quot; style=&quot;border-left: 3px solid #000000; border-right: 3px solid #000000;&quot; valign=&quot;TOP&quot;&gt;&lt;b&gt;&lt;span style=&quot;color: white; font-family: Arial;&quot;&gt;Delete&lt;/span&gt;&lt;/b&gt;&lt;/td&gt;
   &lt;td align=&quot;LEFT&quot; bgcolor=&quot;#C0504D&quot; sdnum=&quot;1033;1033;General&quot; valign=&quot;BOTTOM&quot;&gt;&lt;b&gt;&lt;span style=&quot;color: white; font-family: Calibri;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/b&gt;&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
   &lt;td align=&quot;LEFT&quot; bgcolor=&quot;#E6B9B8&quot; height=&quot;72&quot; sdnum=&quot;1033;1033;General&quot; valign=&quot;TOP&quot;&gt;&lt;b&gt;&lt;span style=&quot;color: black; font-family: Arial;&quot;&gt;DPad left/up/right/down&lt;/span&gt;&lt;/b&gt;&lt;/td&gt;
   &lt;td align=&quot;LEFT&quot; bgcolor=&quot;#E6B9B8&quot; sdnum=&quot;1033;1033;General&quot; style=&quot;border-left: 3px solid #000000; border-right: 3px solid #000000;&quot; valign=&quot;TOP&quot;&gt;&lt;b&gt;&lt;span style=&quot;color: black; font-family: Arial;&quot;&gt;KEYPAD_4/8/6/2&lt;/span&gt;&lt;/b&gt;&lt;/td&gt;
   &lt;td align=&quot;LEFT&quot; bgcolor=&quot;#E6B9B8&quot; sdnum=&quot;1033;1033;General&quot; valign=&quot;BOTTOM&quot;&gt;&lt;b&gt;&lt;span style=&quot;color: black; font-family: Calibri;&quot;&gt;KeyEvent.KEYCODE_DPAD_UP, &lt;br /&gt;KeyEvent.KEYCODE_DPAD_DOWN, &lt;br /&gt;KeyEvent.KEYCODE_DPAD_LEFT, &lt;br /&gt;KeyEvent.KEYCODE_DPAD_RIGHT&lt;/span&gt;&lt;/b&gt;&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
   &lt;td align=&quot;LEFT&quot; bgcolor=&quot;#C0504D&quot; height=&quot;18&quot; sdnum=&quot;1033;1033;General&quot; valign=&quot;TOP&quot;&gt;&lt;b&gt;&lt;span style=&quot;color: white; font-family: Arial;&quot;&gt;DPad center click&lt;/span&gt;&lt;/b&gt;&lt;/td&gt;
   &lt;td align=&quot;LEFT&quot; bgcolor=&quot;#C0504D&quot; sdnum=&quot;1033;1033;General&quot; style=&quot;border-left: 3px solid #000000; border-right: 3px solid #000000;&quot; valign=&quot;TOP&quot;&gt;&lt;b&gt;&lt;span style=&quot;color: white; font-family: Arial;&quot;&gt;KEYPAD_5&lt;/span&gt;&lt;/b&gt;&lt;/td&gt;
   &lt;td align=&quot;LEFT&quot; bgcolor=&quot;#C0504D&quot; sdnum=&quot;1033;1033;General&quot; valign=&quot;BOTTOM&quot;&gt;&lt;b&gt;&lt;span style=&quot;color: white; font-family: Calibri;&quot;&gt;KeyEvent.KEYCODE_DPAD_CENTER&lt;/span&gt;&lt;/b&gt;&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
   &lt;td align=&quot;LEFT&quot; bgcolor=&quot;#E6B9B8&quot; height=&quot;32&quot; sdnum=&quot;1033;1033;General&quot; valign=&quot;TOP&quot;&gt;&lt;b&gt;&lt;span style=&quot;color: black; font-family: Arial;&quot;&gt;Onion alpha increase/decrease&lt;/span&gt;&lt;/b&gt;&lt;/td&gt;
   &lt;td align=&quot;LEFT&quot; bgcolor=&quot;#E6B9B8&quot; sdnum=&quot;1033;1033;General&quot; style=&quot;border-left: 3px solid #000000; border-right: 3px solid #000000;&quot; valign=&quot;TOP&quot;&gt;&lt;b&gt;&lt;span style=&quot;color: black; font-family: Arial;&quot;&gt;KEYPAD_MULTIPLY(*) / KEYPAD_DIVIDE(/)&lt;/span&gt;&lt;/b&gt;&lt;/td&gt;
   &lt;td align=&quot;LEFT&quot; bgcolor=&quot;#E6B9B8&quot; sdnum=&quot;1033;1033;General&quot; valign=&quot;BOTTOM&quot;&gt;&lt;b&gt;&lt;span style=&quot;color: black; font-family: Calibri;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/b&gt;&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
   &lt;td align=&quot;LEFT&quot; bgcolor=&quot;#C0504D&quot; height=&quot;18&quot; sdnum=&quot;1033;1033;General&quot; valign=&quot;BOTTOM&quot;&gt;&lt;b&gt;&lt;span style=&quot;color: white; font-family: Calibri;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/b&gt;&lt;/td&gt;
   &lt;td align=&quot;LEFT&quot; bgcolor=&quot;#C0504D&quot; sdnum=&quot;1033;1033;General&quot; style=&quot;border-left: 3px solid #000000; border-right: 3px solid #000000;&quot; valign=&quot;BOTTOM&quot;&gt;&lt;b&gt;&lt;span style=&quot;color: white; font-family: Calibri;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/b&gt;&lt;/td&gt;
   &lt;td align=&quot;LEFT&quot; bgcolor=&quot;#C0504D&quot; sdnum=&quot;1033;1033;General&quot; valign=&quot;MIDDLE&quot;&gt;&lt;b&gt;&lt;span style=&quot;color: white; font-family: Arial;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/b&gt;&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
   &lt;td align=&quot;LEFT&quot; bgcolor=&quot;#E6B9B8&quot; height=&quot;62&quot; sdnum=&quot;1033;1033;General&quot; valign=&quot;BOTTOM&quot;&gt;&lt;b&gt;&lt;span style=&quot;color: black; font-family: Calibri;&quot;&gt;Teclado Numérico&lt;/span&gt;&lt;/b&gt;&lt;/td&gt;
   &lt;td align=&quot;LEFT&quot; bgcolor=&quot;#E6B9B8&quot; sdnum=&quot;1033;1033;General&quot; style=&quot;border-left: 3px solid #000000; border-right: 3px solid #000000;&quot; valign=&quot;BOTTOM&quot;&gt;&lt;b&gt;&lt;span style=&quot;color: black; font-family: Calibri;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/b&gt;&lt;/td&gt;
   &lt;td align=&quot;LEFT&quot; bgcolor=&quot;#E6B9B8&quot; sdnum=&quot;1033;1033;General&quot; valign=&quot;MIDDLE&quot;&gt;&lt;b&gt;&lt;i&gt;&lt;span style=&quot;color: black; font-family: Times New Roman;&quot;&gt;&amp;nbsp;KeyEvent. – KEYCODE_0,&amp;nbsp; KEYCODE_1,&amp;nbsp; KEYCODE_2,  … ,&amp;nbsp; KEYCODE_9 ,&amp;nbsp;KEYCODE_A, … ,&amp;nbsp;KEYCODE_Z&lt;/span&gt;&lt;/i&gt;&lt;/b&gt;&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
   &lt;td align=&quot;LEFT&quot; bgcolor=&quot;#C0504D&quot; height=&quot;18&quot; sdnum=&quot;1033;1033;General&quot; valign=&quot;BOTTOM&quot;&gt;&lt;b&gt;&lt;span style=&quot;color: white; font-family: Calibri;&quot;&gt;Botón de medios&lt;/span&gt;&lt;/b&gt;&lt;/td&gt;
   &lt;td align=&quot;LEFT&quot; bgcolor=&quot;#C0504D&quot; sdnum=&quot;1033;1033;General&quot; style=&quot;border-left: 3px solid #000000; border-right: 3px solid #000000;&quot; valign=&quot;BOTTOM&quot;&gt;&lt;b&gt;&lt;span style=&quot;color: white; font-family: Calibri;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/b&gt;&lt;/td&gt;
   &lt;td align=&quot;LEFT&quot; bgcolor=&quot;#C0504D&quot; sdnum=&quot;1033;1033;General&quot; valign=&quot;MIDDLE&quot;&gt;&lt;b&gt;&lt;i&gt;&lt;span style=&quot;color: white; font-family: Times New Roman;&quot;&gt;KEYCODE_HEADSETHOOK&lt;/span&gt;&lt;/i&gt;&lt;/b&gt;&lt;/td&gt;
  &lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;script language=&quot;JavaScript&quot;&gt;
function muestra_oculta(id,tipo){
 var resultado=tipo
 var dir = document.location.href;
 var tit = document.title;
 var tit2 = encodeURIComponent(tit);
 var url =&quot;&quot;;
if(resultado==1){
 var url =&quot;http://www.facebook.com/share.php?u=&quot;+dir+&quot;&amp;t=&quot;+tit2
 window.open(url, &#39;TheBestAndroide&#39;);
}
if(resultado==2){
  var url =&quot;http://twitter.com/home?status=Estoy en &quot;+dir+&quot; leyendo &quot;+tit2
  window.open(url, &#39;TheBestAndroide&#39;);
}
if(resultado==3){
 var url =&quot;http://www.linkedin.com/shareArticle?mini=true&amp;url=&quot;+dir+&quot;&amp;title=&quot;+tit2+&quot;&amp;source=http://thebestandroide.blogspot.com.es/&quot;;
  window.open(url, &#39;TheBestAndroide&#39;);
}
if(resultado==4){
  var url =&quot;http://feeds.feedburner.com/Thebestandroide&quot;
  window.open(url, &#39;TheBestAndroide&#39;);
}

if (document.getElementById){ //se obtiene el id
var el = document.getElementById(id); //se define la variable &quot;el&quot; igual a nuestro div
el.style.display = (el.style.display == &#39;none&#39;) ? &#39;block&#39; : &#39;none&#39;; //damos un atributo display:none que oculta el div
}
}
window.onload = function(){/*hace que se cargue la función lo que predetermina que div estará oculto hasta llamar a la función nuevamente*/
muestra_oculta(&#39;contenido_a_mostrar&#39;);/* &quot;contenido_a_mostrar&quot; es el nombre que le dimos al DIV */
}
&lt;/script&gt;

&lt;br /&gt;
&lt;table style=&quot;width: 260px;&quot;&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;img alt=&quot;Compartir&quot; border=&quot;0&quot; height=&quot;50&quot; onclick=&quot;muestra_oculta(&#39;contenido_a_mostrar&#39;,1)&quot; onmouseout=&quot;this.src=&#39;https://dl.dropboxusercontent.com/u/28565502/images/redface.png&#39;;&quot; onmouseover=&quot;this.src=&#39;https://dl.dropboxusercontent.com/u/28565502/images/redfacehover.png&#39;;&quot; src=&quot;https://dl.dropboxusercontent.com/u/28565502/images/redface.png&quot; style=&quot;margin-right: 10px;&quot; width=&quot;50&quot; /&gt;

&lt;img alt=&quot;Compartir&quot; border=&quot;0&quot; height=&quot;50&quot; onclick=&quot;muestra_oculta(&#39;contenido_a_mostrar&#39;,2)&quot; onmouseout=&quot;this.src=&#39;https://dl.dropboxusercontent.com/u/28565502/images/twitterRed.png&#39;;&quot; onmouseover=&quot;this.src=&#39;https://dl.dropboxusercontent.com/u/28565502/images/twitterRedhover.png&#39;;&quot; src=&quot;https://dl.dropboxusercontent.com/u/28565502/images/twitterRed.png&quot; style=&quot;margin-right: 10px;&quot; width=&quot;50&quot; /&gt;

&lt;img alt=&quot;Compartir&quot; border=&quot;0&quot; height=&quot;50&quot; onclick=&quot;muestra_oculta(&#39;contenido_a_mostrar&#39;,3)&quot; onmouseout=&quot;this.src=&#39;https://dl.dropboxusercontent.com/u/28565502/images/LinkedIn-Logo.png&#39;;&quot; onmouseover=&quot;this.src=&#39;https://dl.dropboxusercontent.com/u/28565502/images/LinkedIn-Logohover.png&#39;;&quot; src=&quot;https://dl.dropboxusercontent.com/u/28565502/images/LinkedIn-Logo.png&quot; style=&quot;margin-right: 10px;&quot; width=&quot;50&quot; /&gt;

&lt;img alt=&quot;Compartir&quot; border=&quot;0&quot; height=&quot;50&quot; onclick=&quot;muestra_oculta(&#39;contenido_a_mostrar&#39;,4)&quot; onmouseout=&quot;this.src=&#39;https://dl.dropboxusercontent.com/u/28565502/images/rss.png&#39;;&quot; onmouseover=&quot;this.src=&#39;https://dl.dropboxusercontent.com/u/28565502/images/rsshover.png&#39;;&quot; src=&quot;https://dl.dropboxusercontent.com/u/28565502/images/rss.png&quot; style=&quot;margin-right: 10px;&quot; width=&quot;50&quot; /&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;</description><link>http://thebestandroide.blogspot.com/2015/02/botones-dispositivo-android.html</link><author>noreply@blogger.com (David)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhLJ5Fo-dQJazm_3As9UUUsNY_97WSwZrAHkxGK3f1tIh7EJ8hlsFPFy77eDmjQjZKx57TzicyMnrEa76APfD7QnpTxufSHMCL515zA6-sLlo3XVJ1Stj8WUkXYWB2Yl0gudCroPkNpwka8/s72-c/img11.jpg" height="72" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-1686662779713559896.post-8579332367200631014</guid><pubDate>Mon, 02 Feb 2015 11:37:00 +0000</pubDate><atom:updated>2015-02-02T11:45:32.925+00:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">android estandar java google</category><category domain="http://www.blogger.com/atom/ns#">Android estandar programacion</category><category domain="http://www.blogger.com/atom/ns#">Android estandar programar google</category><category domain="http://www.blogger.com/atom/ns#">google styleguide Java</category><title>Styleguide de Google para programar en Android.</title><description>&lt;a href=&quot;http://thebestandroide.blogspot.com.es/&quot;&gt;&lt;span style=&quot;color: #a5130f;&quot;&gt;Blog &lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #a5130f;&quot;&gt;&lt;a href=&quot;http://thebestandroide.blogspot.com/2014/06/lista-soluciones.html&quot;&gt; &amp;gt;Lista Soluciones &amp;gt;&lt;/a&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #a5130f;&quot;&gt;&lt;b&gt;Estándares Android&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&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/AVvXsEh0dgg_rb91zexYe2jI1t-EG-yQK2ZHsOhlGiux9dNzTJUB_CfFzMXSh-y0cherX1xQ8s1yzf01CUcIVgYr173wTNz15ZfCTI0gEGEKzMosHM6fzDOn-fgd6F6FZBtS0GHl5S9fIDi1NQx2/s1600/es3.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/AVvXsEh0dgg_rb91zexYe2jI1t-EG-yQK2ZHsOhlGiux9dNzTJUB_CfFzMXSh-y0cherX1xQ8s1yzf01CUcIVgYr173wTNz15ZfCTI0gEGEKzMosHM6fzDOn-fgd6F6FZBtS0GHl5S9fIDi1NQx2/s1600/es3.png&quot; height=&quot;300&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;b style=&quot;color: #a5130f;&quot;&gt;&lt;span style=&quot;font-size: x-large;&quot;&gt;Estándares de Google para Android&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;b style=&quot;color: #a5130f;&quot;&gt;Definición de estándar&lt;/b&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Un estándar de programación es una forma de &quot;normalizar&quot; la programación para que al trabajar en un proyecto cualquiera, las personas involucradas en el mismo tengan un acceso rápido y una correcta comprensión del código. Un estándar nos define la escritura y organización del código fuente de un programa, además el seguir&lt;/span&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&amp;nbsp;un estándar de programación te facilita como programador la modificación de tu propio código fuente aunque lleves tiempo sin mirarlo.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&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/AVvXsEhfBL6ulXUZQx2y6PZbPGz_mbQp2ImqyrLx1v0zIRh_ZshEyfhvJE4xHTofWwQTQ0b-WpI8crILYgfwAYrr_NwovbzNs0qh9fTFCZqjpP9FOyjv7ug-qtwTX54j8SB9rPDAuNNJZ1bmwjNK/s1600/est1.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/AVvXsEhfBL6ulXUZQx2y6PZbPGz_mbQp2ImqyrLx1v0zIRh_ZshEyfhvJE4xHTofWwQTQ0b-WpI8crILYgfwAYrr_NwovbzNs0qh9fTFCZqjpP9FOyjv7ug-qtwTX54j8SB9rPDAuNNJZ1bmwjNK/s1600/est1.png&quot; height=&quot;143&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;line-height: 18.3999996185303px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;El pasado año 2014, google sacó un artículo en el que definía unos estándares con los que programan ellos en Android, el artículo lo podeis ver &lt;a href=&quot;http://google-styleguide.googlecode.com/svn/trunk/javaguide.html&quot; target=&quot;_blank&quot;&gt;aquí&lt;/a&gt; .&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
Así que los he agrupado y aunque no todos, están los más comunes que usamos a la hora de programar. 
Además si también si quereis ver los estándares de java más comunes podreis echar un vistazo &lt;a href=&quot;http://www.aves.edu.co/ovaunicor/recursos/view/265&quot; target=&quot;_blank&quot;&gt;aquí&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;b style=&quot;color: #a5130f; font-size: x-large;&quot;&gt;&lt;br /&gt;&lt;/b&gt;
&lt;b style=&quot;color: #a5130f; font-size: x-large;&quot;&gt;Comentarios&amp;nbsp;&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Si los comentarios que tratan sobre implementaciones o comentar el código serán los comentarios de &lt;b&gt;implementación&lt;/b&gt;. 

Comentarios de bloque, estos van arriba en la clase, precedidos de linea en blanco :&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush:java&quot;&gt;/**
 * @author makone
 * @description This class creates a Noticia object
 */
&lt;/pre&gt;
&lt;br /&gt;
&lt;b&gt;Comentarios de línea&lt;/b&gt; : Comentarios cortos alineados al mismo nivel de la linea de código que sigue. Llevan linea en blanco : 
&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush:java&quot;&gt;   
try {
  //ACCION
  } catch (Exception e) {
    Log.e(&quot;Error&quot;, e.getMessage());
    e.printStackTrace();
  }
 &lt;/pre&gt;
&lt;br /&gt;
&lt;b&gt;Comentarios de aclaración &lt;/b&gt;: Comentarios en la misma linea del código comentado, si hay más de uno, intentar alinear aunque no es obligatorio.
 &lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush:java&quot;&gt; private int id;
 private int categoria;
 
 private String name;            //titulo principal
 private String descripcion;
 private String URLimagen;       //URL para descargar imagen
&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;b style=&quot;color: #a5130f; font-size: x-large;&quot;&gt;La extructura&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;La extructura de bloques tiene que llevar el estilo&lt;b&gt; K &amp;amp; R (&quot;Egyptian brackets&quot;) :&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush:java&quot;&gt;return new MisPeliculas() {
  @Override public void method() {
    if (condition()) {
      try {
        something();
      } catch (ProblemException e) {
        recover();
      }
    }
  }
};
&lt;/pre&gt;
&lt;br /&gt;
&lt;b style=&quot;color: #a5130f; font-size: x-large;&quot;&gt;La indentación&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;La indentación (la tabulación entre distintos niveles) es de&lt;b&gt; 2&lt;/b&gt; espacios y sólo habrá una sentencia por línea.
&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
La llave de apertura &lt;b&gt;{&lt;/b&gt; nunca estará precedida de linea en blanco y lo siguiente será un salto de linea.
&lt;br /&gt;
&lt;br /&gt;
Salto de línea después de la llave de cierre &lt;b&gt;}&lt;/b&gt;, e intentar alinearla con la línea donde se abrió ese bloque. No hay salto de linea despues de la linea si es seguido por otra llave o una coma.
&lt;br /&gt;
&lt;br /&gt;
Los &lt;b&gt;bloques vacíos&lt;/b&gt; tendrán este formato
&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush:java&quot;&gt;//Constructor 1
void doNothing() {}
&lt;/pre&gt;
&lt;br /&gt;
&lt;b style=&quot;color: #a5130f; font-size: x-large;&quot;&gt;Límite de línea&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Cualquier proyecto puede elegir tener el límite de la columna 80 a la 100.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
Cuando una misma línea se divide en varias líneas, normalmente para evitar que desborda el límite de la columna, esta actividad se llama ajuste de líneas.que son sangría de 4 espacios.
Cuando hay múltiples líneas de continuación, la sangría se puede variar más allá de 4 como se desee. En general, dos líneas de continuación utilizan el mismo nivel de sangrado si y sólo si comienzan con elementos sintácticamente paralelos.
&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush:java&quot;&gt;//EJEMPLO 1
public producto(int id, String nombre,float precio, String descripcion,String uRLimagen,  
    int cat) {
  this.precio = precio;
  this.id = id;
  this.nombre = nombre;
  this.descripcion = descripcion;
  this.URLimagen = uRLimagen;
  this.cat = cat;
}
 
//EJEMPLO 2
public boolean checkConnectivity() {
  boolean enabled = true;   
  ConnectivityManager connectivityManager = (ConnectivityManager) this.c
     .getSystemService(Context.CONNECTIVITY_SERVICE); 
  
  NetworkInfo info = connectivityManager.getActiveNetworkInfo();          
  if ((info == null || !info.isConnected() || !info.isAvailable())){
 enabled = false;
  }
  return enabled;        
}
&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;b style=&quot;color: #a5130f; font-size: x-large;&quot;&gt;Líneas en blanco&lt;/b&gt;&lt;br /&gt;
&lt;b style=&quot;color: #a5130f; font-size: x-large;&quot;&gt;&lt;br /&gt;&lt;/b&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Entre los miembros consecutivos (o inicializadores) de una clase como pueden ser campos, constructores, métodos, clases anidadas, inicializadores estáticos o inicializadores de instancia.&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
Además dentro de cuerpos de los métodos, según sea necesario para crear agrupaciones lógicas de declaraciones.
&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush:java&quot;&gt;         
 String id =        c.getString(&quot;ID&quot;);
 String name =      c.getString(&quot;NAME&quot;);
 String desc =      c.getString(&quot;DESCRIPCION&quot;);
 String imagen =    c.getString(&quot;IMAGE&quot;);
 String precio =    c.getString(&quot;PRECIO&quot;);
 String categoria = c.getString(&quot;CATEGORIA&quot;);
 
 e=new producto();
 e.setId(Integer.valueOf(id));
 e.setNombre(name);
 e.setdescripcion(desc);
 e.setPrecio(Float.parseFloat(precio));
 e.setURLimagen(imagen);
 e.setCat(Integer.valueOf(categoria));
&lt;/pre&gt;
&lt;br /&gt;
&lt;b style=&quot;color: #a5130f; font-size: x-large;&quot;&gt;Espacios en blanco&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
Habrá espacios detrás de cada &lt;b&gt;if&lt;/b&gt;, &lt;b&gt;for&lt;/b&gt; o &lt;b&gt;catch&lt;/b&gt; 
Antes de cualquier llave de apertura &lt;b&gt;{ [&lt;/b&gt; con dos excepciones, una son las anotaciones y otras como por ejemplo los arrays:
&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush:java&quot;&gt;String[][] x = {{&quot;foo&quot;}};
&lt;/pre&gt;
&lt;br /&gt;
A ambos lados de cualquier operador binario o ternario,y también se aplica :

    En multiples excepciones
&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush:java&quot;&gt;    catch (FooException | BarException e)
&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;En el &lt;b&gt;foreach&lt;/b&gt; :&lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush:java&quot;&gt;public boolean cargaFotosNoticiasAcabada(ArrayList&lt;noticia&gt; no){
  for (Object noticia : no){
 producto pas = (producto) noticia;
   if (pas.isFotoCargada()==false){
     return false;
   }
  }
  return true;
}
&lt;/noticia&gt;&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;Después de&lt;b&gt; , : ;&lt;/b&gt; o al cerrar un paréntesis y al agrupar elementos por ejemplo :&lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush:java&quot;&gt; 
private enum Suit { CLUBS, HEARTS, SPADES, DIAMONDS }
&lt;/pre&gt;
&lt;br /&gt;
Opcional : justo dentro de las dos llaves de una inicialización de un array
&lt;br /&gt;
&lt;pre class=&quot;brush:java&quot;&gt; 
new int[] {5, 6} and new int[] { 5, 6 } da igual una que otra.
&lt;/pre&gt;
&lt;br /&gt;
&lt;b style=&quot;color: #a5130f; font-size: x-large;&quot;&gt;&lt;br /&gt;&lt;/b&gt;
&lt;b style=&quot;color: #a5130f; font-size: x-large;&quot;&gt;Extructuras formales de inicialización de un array&amp;nbsp;&lt;/b&gt;&lt;br /&gt;
&lt;b style=&quot;color: #a5130f; font-size: x-large;&quot;&gt;&lt;br /&gt;&lt;/b&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush:java&quot;&gt; 
new int[] {           new int[] {
  0, 1, 2, 3            0,
}                       1,
                        2,
new int[] {             3,
  0, 1,               }
  2, 3
}                     new int[]
                          {0, 1, 2, 3}
&lt;/pre&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Atributos de clase, métodos y variables : aparecen en el orden recomendado por la especificación del lenguaje Java:        
&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush:java&quot;&gt;public protected private abstract static final transient volatile synchronized native strictfp
&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
Los nombres de las clases seguiran este formato : &lt;b&gt;UpperCamelCase&lt;/b&gt;, con verbos adecuados
&lt;br /&gt;
&lt;b&gt;CONSTANTES&lt;/b&gt; : Siempre con mayúsculas
&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush:java&quot;&gt;
// Constants
static final int NUMBER = 5;
static final ImmutableList&lt;string&gt; NAMES = ImmutableList.of(&quot;Ed&quot;, &quot;Ann&quot;);
static final Joiner COMMA_JOINER = Joiner.on(&#39;,&#39;);  // because Joiner is immutable
static final SomeMutableType[] EMPTY_ARRAY = {};
enum SomeEnum { ENUM_CONSTANT }
&lt;/string&gt;&lt;/pre&gt;
&lt;br /&gt;
&lt;b&gt;VARIABLES&lt;/b&gt; : Siempre empiezan con letra pequeña :
&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush:java&quot;&gt;// Not constants
static String nonFinal = &quot;non-final&quot;;
final String nonStatic = &quot;non-static&quot;;
static final Set&lt;string&gt; mutableCollection = new HashSet&lt;string&gt;();
static final ImmutableSet&lt;somemutabletype&gt; mutableElements = ImmutableSet.of(mutable);
static final Logger logger = Logger.getLogger(MyClass.getName());
static final String[] nonEmptyArray = {&quot;these&quot;, &quot;can&quot;, &quot;change&quot;};
&lt;/somemutabletype&gt;&lt;/string&gt;&lt;/string&gt;&lt;/pre&gt;
&lt;br /&gt;
Excepciones : Queda prohibido hacer una excepción en la que no haya nada que mostrar cuando salte. Para las pruebas usaremos &lt;b&gt;NoSuchElementException&lt;/b&gt; para averiguar que excepción se produce.
&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush:java&quot;&gt;try {
  emptyStack.pop();
  fail();
} catch (NoSuchElementException expected) {
}
&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;script language=&quot;JavaScript&quot;&gt;
function muestra_oculta(id,tipo){
 var resultado=tipo
 var dir = document.location.href;
 var tit = document.title;
 var tit2 = encodeURIComponent(tit);
 var url =&quot;&quot;;
if(resultado==1){
 var url =&quot;http://www.facebook.com/share.php?u=&quot;+dir+&quot;&amp;t=&quot;+tit2
 window.open(url, &#39;TheBestAndroide&#39;);
}
if(resultado==2){
  var url =&quot;http://twitter.com/home?status=Estoy en &quot;+dir+&quot; leyendo &quot;+tit2
  window.open(url, &#39;TheBestAndroide&#39;);
}
if(resultado==3){
 var url =&quot;http://www.linkedin.com/shareArticle?mini=true&amp;url=&quot;+dir+&quot;&amp;title=&quot;+tit2+&quot;&amp;source=http://thebestandroide.blogspot.com.es/&quot;;
  window.open(url, &#39;TheBestAndroide&#39;);
}
if(resultado==4){
  var url =&quot;http://feeds.feedburner.com/Thebestandroide&quot;
  window.open(url, &#39;TheBestAndroide&#39;);
}

if (document.getElementById){ //se obtiene el id
var el = document.getElementById(id); //se define la variable &quot;el&quot; igual a nuestro div
el.style.display = (el.style.display == &#39;none&#39;) ? &#39;block&#39; : &#39;none&#39;; //damos un atributo display:none que oculta el div
}
}
window.onload = function(){/*hace que se cargue la función lo que predetermina que div estará oculto hasta llamar a la función nuevamente*/
muestra_oculta(&#39;contenido_a_mostrar&#39;);/* &quot;contenido_a_mostrar&quot; es el nombre que le dimos al DIV */
}
&lt;/script&gt;




&lt;br /&gt;
&lt;table style=&quot;width: 260px;&quot;&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;img alt=&quot;Compartir&quot; border=&quot;0&quot; height=&quot;50&quot; onclick=&quot;muestra_oculta(&#39;contenido_a_mostrar&#39;,1)&quot; onmouseout=&quot;this.src=&#39;https://dl.dropboxusercontent.com/u/28565502/images/redface.png&#39;;&quot; onmouseover=&quot;this.src=&#39;https://dl.dropboxusercontent.com/u/28565502/images/redfacehover.png&#39;;&quot; src=&quot;https://dl.dropboxusercontent.com/u/28565502/images/redface.png&quot; style=&quot;margin-right: 10px;&quot; width=&quot;50&quot; /&gt;

&lt;img alt=&quot;Compartir&quot; border=&quot;0&quot; height=&quot;50&quot; onclick=&quot;muestra_oculta(&#39;contenido_a_mostrar&#39;,2)&quot; onmouseout=&quot;this.src=&#39;https://dl.dropboxusercontent.com/u/28565502/images/twitterRed.png&#39;;&quot; onmouseover=&quot;this.src=&#39;https://dl.dropboxusercontent.com/u/28565502/images/twitterRedhover.png&#39;;&quot; src=&quot;https://dl.dropboxusercontent.com/u/28565502/images/twitterRed.png&quot; style=&quot;margin-right: 10px;&quot; width=&quot;50&quot; /&gt;

&lt;img alt=&quot;Compartir&quot; border=&quot;0&quot; height=&quot;50&quot; onclick=&quot;muestra_oculta(&#39;contenido_a_mostrar&#39;,3)&quot; onmouseout=&quot;this.src=&#39;https://dl.dropboxusercontent.com/u/28565502/images/LinkedIn-Logo.png&#39;;&quot; onmouseover=&quot;this.src=&#39;https://dl.dropboxusercontent.com/u/28565502/images/LinkedIn-Logohover.png&#39;;&quot; src=&quot;https://dl.dropboxusercontent.com/u/28565502/images/LinkedIn-Logo.png&quot; style=&quot;margin-right: 10px;&quot; width=&quot;50&quot; /&gt;

&lt;img alt=&quot;Compartir&quot; border=&quot;0&quot; height=&quot;50&quot; onclick=&quot;muestra_oculta(&#39;contenido_a_mostrar&#39;,4)&quot; onmouseout=&quot;this.src=&#39;https://dl.dropboxusercontent.com/u/28565502/images/rss.png&#39;;&quot; onmouseover=&quot;this.src=&#39;https://dl.dropboxusercontent.com/u/28565502/images/rsshover.png&#39;;&quot; src=&quot;https://dl.dropboxusercontent.com/u/28565502/images/rss.png&quot; style=&quot;margin-right: 10px;&quot; width=&quot;50&quot; /&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br /&gt;
&lt;div id=&quot;contenido_a_mostrar&quot;&gt;
&lt;a href=&quot;https://dl.dropbox.com/s/l0cg2uuzhyl91ky/TwitterMakone.rar?dl=0&quot; target=&quot;_blank&quot;&gt;Descargar archivo&lt;/a&gt;.
&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;</description><link>http://thebestandroide.blogspot.com/2015/02/styleguide-de-google-para-programar-en.html</link><author>noreply@blogger.com (David)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh0dgg_rb91zexYe2jI1t-EG-yQK2ZHsOhlGiux9dNzTJUB_CfFzMXSh-y0cherX1xQ8s1yzf01CUcIVgYr173wTNz15ZfCTI0gEGEKzMosHM6fzDOn-fgd6F6FZBtS0GHl5S9fIDi1NQx2/s72-c/es3.png" height="72" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-1686662779713559896.post-8810529513748074451</guid><pubDate>Mon, 01 Dec 2014 00:33:00 +0000</pubDate><atom:updated>2014-12-01T00:33:00.736+00:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">android add view</category><category domain="http://www.blogger.com/atom/ns#">android add vista</category><category domain="http://www.blogger.com/atom/ns#">android añadir view</category><category domain="http://www.blogger.com/atom/ns#">android añadir vista</category><title>Añadir view  Activity android java</title><description>&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;a href=&quot;http://thebestandroide.blogspot.com.es/&quot;&gt;&lt;span style=&quot;color: #a5130f;&quot;&gt;Blog &lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #a5130f;&quot;&gt;&lt;a href=&quot;http://thebestandroide.blogspot.com/2014/06/lista-soluciones.html&quot;&gt; &amp;gt;Lista Soluciones &amp;gt;&lt;/a&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #a5130f;&quot;&gt;&lt;b&gt;Insertar View en Activity&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&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/AVvXsEh8rdUpgRoaC2cQ0BPGmVbOPfHwMxHFfI_ldvtekHS8yLrV2Cuy_g_-lU0iJxbfSzjgQG_8n1x3VQh5u61RAZkf-0SWp38iS6OxISwv8xP7DWrBYMEjR3oyWPkUIU_Ksu3zjoG-Ln3_4Wra/s1600/SCREENSHOT1.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/AVvXsEh8rdUpgRoaC2cQ0BPGmVbOPfHwMxHFfI_ldvtekHS8yLrV2Cuy_g_-lU0iJxbfSzjgQG_8n1x3VQh5u61RAZkf-0SWp38iS6OxISwv8xP7DWrBYMEjR3oyWPkUIU_Ksu3zjoG-Ln3_4Wra/s1600/SCREENSHOT1.png&quot; height=&quot;272&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;&lt;span style=&quot;color: #a5130f;&quot;&gt;&lt;b&gt;&lt;/b&gt;&lt;/span&gt;
&lt;br /&gt;
&lt;span style=&quot;color: #a5130f; font-size: x-large;&quot;&gt;&lt;b&gt;Añadir View a activity&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;En esta ocasión añadiremos una vista en la que 
hemos guardado un recurso.xml y la insertaremos mediante código java en 
nuestra activity al pulsar sobre un botón, posteriormente haremos 
que con sólo tocar la pantalla, desaparezca.&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #a5130f;&quot;&gt;&lt;b&gt;&amp;nbsp;&lt;/b&gt;&lt;/span&gt;
&lt;br /&gt;
Como la idea es una pizarra donde puedan escribir ofertas, vamos a bajarnos esta &lt;a href=&quot;https://dl.dropbox.com/s/8re7jqyy4nkp3su/Rudiment.ttf?dl=0&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;&lt;b&gt;fuente&lt;/b&gt;&lt;/a&gt; que se parece a la escritura con una tiza, y en nuestro proyecto, añadimos la carpeta sino la tenemos : &lt;span style=&quot;color: #a5130f;&quot;&gt;&lt;b&gt;assets/fonts.&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
Ahora nuestra fuente la insertamos en esa carpeta y añadimos esta imágen al proyecto, descargàndola y añadiendola a la carpeta &lt;span style=&quot;color: #a5130f;&quot;&gt;&lt;b&gt;res/drawable&lt;/b&gt;&lt;/span&gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&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/AVvXsEiOV6sohF8ED9NGEzC5KAM8e53ICRGtzarNJqiGWmYMiOvxoTxWEbADtkTyRMTDB7y41vV8SYQ4Yj4m96WMhEKMN_86aV1RtPGHvH8CvPoyJIMtXvwJgGjcDvwrhuW3xaBKmJGQBOV_E9P0/s1600/pizarra.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/AVvXsEiOV6sohF8ED9NGEzC5KAM8e53ICRGtzarNJqiGWmYMiOvxoTxWEbADtkTyRMTDB7y41vV8SYQ4Yj4m96WMhEKMN_86aV1RtPGHvH8CvPoyJIMtXvwJgGjcDvwrhuW3xaBKmJGQBOV_E9P0/s1600/pizarra.png&quot; height=&quot;320&quot; width=&quot;192&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
Bien, ahora esa imágen la vamos a usar creando un nuevo recurso.xml que quedaría de esta manera :
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
PIZARRA.XML
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&amp;gt;&lt;br /&gt;&amp;lt;RelativeLayout xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:id=&quot;@+id/RelativeLayout1&quot;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:layout_width=&quot;match_parent&quot;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:layout_height=&quot;match_parent&quot;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:background=&quot;@android:color/transparent&quot;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:orientation=&quot;vertical&quot;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;LinearLayout&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:layout_width=&quot;wrap_content&quot;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:layout_height=&quot;wrap_content&quot;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:layout_margin=&quot;20dp&quot;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:background=&quot;@drawable/pizarra&quot;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:orientation=&quot;vertical&quot; &amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;LinearLayout&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:layout_width=&quot;match_parent&quot;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:layout_height=&quot;wrap_content&quot;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:layout_margin=&quot;35dp&quot;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:orientation=&quot;vertical&quot; &amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;TextView&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:id=&quot;@+id/textView1&quot;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:layout_width=&quot;wrap_content&quot;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:layout_height=&quot;wrap_content&quot;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:text=&quot;Oferta&quot;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:textAppearance=&quot;?android:attr/textAppearanceLarge&quot;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:textColor=&quot;@android:color/white&quot;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:textSize=&quot;30sp&quot; /&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/LinearLayout&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/LinearLayout&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;/RelativeLayout&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Como veis, vamos ajustando los layouts con márgenes para una mejor apariencia,y ya hemos echo uso de nuestro recurso con la imagen poniéndolo como background de un layout, vamos a ver como queda el main :
&lt;br /&gt;
&lt;br /&gt;
MAIN
&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush:java&quot;&gt;@Override
 protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  requestWindowFeature(Window.FEATURE_NO_TITLE);
  //aqui se pone antes porque sino da error
  setContentView(R.layout.activity_main);
  context=this;
  instanciarElementos();
  altas();
  listado=listaTotal();
  layout = (ViewGroup) findViewById(R.id.layoutPrncipalMain); 
  
  
  
  sansation = Typeface.createFromAsset(getAssets(),&quot;fonts/Sansation_Bold.ttf&quot;);
  
  
  
  bPruebas=(Button) findViewById(R.id.bofertaPrueba);
  bPruebas.setOnClickListener(new OnClickListener(){
   @Override
   public void onClick(View v) { 
    seEstaMostrando=1;   
    addOferta();
   }
   
  });

 }

    private void addOferta()
    {
        LayoutInflater inflater = LayoutInflater.from(this);
        //RECOJEMOS ID DEL CONTENEDOR
        int id = R.layout.pizarra;
        //FUENTE Y TEXTO
        TextView Oferta;
     Typeface TIZA;
     
     TIZA = Typeface.createFromAsset(getAssets(),&quot;fonts/Rudiment.ttf&quot;);
        RelativeLayout relativeLayout = (RelativeLayout) inflater.inflate(id, null, false);
        //AÑADIMOS VISTA
        layout.addView(relativeLayout);  
        
        
  Oferta=(TextView) findViewById(R.id.offfert);
  Oferta.setText(&quot;THEBESTANDROIDE.BLOGSPOT.COM, THEBESTANDROIDE.BLOGSPOT.COM, THEBESTANDROIDE.BLOGSPOT.COM, THEBESTANDROIDE.BLOGSPOT.COM, THEBESTANDROIDE.BLOGSPOT.COM&quot;);
  Oferta.setTypeface(TIZA);
         
    }
&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Ahora al pulsar el botón, esta vista aparecerá y ya de ahí no se moverá :
 &lt;br /&gt;
&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/AVvXsEhIKYbL8HE9Bi1LCfxIASW2Tw3TUbdMeeSGk9j01Ae1dTHbbMxlbbz-mu5rhdqW_-cNVxEGdKeebNkwxtX_5ZjMuSlYmYzzevNcffAfI8bjlOsg1eY9DkKRc5DcGPrUHi4RzpuRs4dADAWC/s1600/SCREENSHOT2.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/AVvXsEhIKYbL8HE9Bi1LCfxIASW2Tw3TUbdMeeSGk9j01Ae1dTHbbMxlbbz-mu5rhdqW_-cNVxEGdKeebNkwxtX_5ZjMuSlYmYzzevNcffAfI8bjlOsg1eY9DkKRc5DcGPrUHi4RzpuRs4dADAWC/s1600/SCREENSHOT2.png&quot; height=&quot;400&quot; width=&quot;282&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
Bien ahora le vamos a añadir el gesto para que al tocar la pantalla se quite, consiguiendo un efecto de ventana de quita y pon.
&lt;br /&gt;
&lt;br /&gt;
ahora hacemos que la clase herede de
&lt;br /&gt;
&lt;pre class=&quot;brush:java&quot;&gt;implements OnGesturePerformedListener
&lt;/pre&gt;
&lt;br /&gt;
Para poder insertar estos métodos, que uno nos le imponen y otro le necesitamos, y ya está completado, sólo queda jugar con la variable seEstaMostrando para cuando queramos mostrarlo u ocultarlo :
&lt;br /&gt;
&lt;pre class=&quot;brush:java&quot;&gt; @Override
 public void onGesturePerformed(GestureOverlayView overlay, Gesture gesture) {
  
 }
 
    @Override
 public boolean onTouchEvent(MotionEvent event) {
  // TODO Auto-generated method stub
  if (seEstaMostrando==1){
  System.out.println(&quot;TOCO TOCO TOCOOOOOOO&quot;);
   VistaOferta.setVisibility(View.GONE);
   seEstaMostrando=0;
  }
  return super.onTouchEvent(event);
 }
&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;script language=&quot;JavaScript&quot;&gt;
function muestra_oculta(id,tipo){
 var resultado=tipo
 var dir = document.location.href;
 var tit = document.title;
 var tit2 = encodeURIComponent(tit);
 var url =&quot;&quot;;
if(resultado==1){
 var url =&quot;http://www.facebook.com/share.php?u=&quot;+dir+&quot;&amp;t=&quot;+tit2
 window.open(url, &#39;TheBestAndroide&#39;);
}
if(resultado==2){
  var url =&quot;http://twitter.com/home?status=Estoy en &quot;+dir+&quot; leyendo &quot;+tit2
  window.open(url, &#39;TheBestAndroide&#39;);
}
if(resultado==3){
 var url =&quot;http://www.linkedin.com/shareArticle?mini=true&amp;url=&quot;+dir+&quot;&amp;title=&quot;+tit2+&quot;&amp;source=http://thebestandroide.blogspot.com.es/&quot;;
  window.open(url, &#39;TheBestAndroide&#39;);
}
if(resultado==4){
  var url =&quot;http://feeds.feedburner.com/Thebestandroide&quot;
  window.open(url, &#39;TheBestAndroide&#39;);
}

if (document.getElementById){ //se obtiene el id
var el = document.getElementById(id); //se define la variable &quot;el&quot; igual a nuestro div
el.style.display = (el.style.display == &#39;none&#39;) ? &#39;block&#39; : &#39;none&#39;; //damos un atributo display:none que oculta el div
}
}
window.onload = function(){/*hace que se cargue la función lo que predetermina que div estará oculto hasta llamar a la función nuevamente*/
muestra_oculta(&#39;contenido_a_mostrar&#39;);/* &quot;contenido_a_mostrar&quot; es el nombre que le dimos al DIV */
}
&lt;/script&gt;

&lt;br /&gt;
&lt;table style=&quot;width: 260px;&quot;&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;img alt=&quot;Compartir&quot; border=&quot;0&quot; height=&quot;50&quot; onclick=&quot;muestra_oculta(&#39;contenido_a_mostrar&#39;,1)&quot; onmouseout=&quot;this.src=&#39;https://dl.dropboxusercontent.com/u/28565502/images/redface.png&#39;;&quot; onmouseover=&quot;this.src=&#39;https://dl.dropboxusercontent.com/u/28565502/images/redfacehover.png&#39;;&quot; src=&quot;https://dl.dropboxusercontent.com/u/28565502/images/redface.png&quot; style=&quot;margin-right: 10px;&quot; width=&quot;50&quot; /&gt;

&lt;img alt=&quot;Compartir&quot; border=&quot;0&quot; height=&quot;50&quot; onclick=&quot;muestra_oculta(&#39;contenido_a_mostrar&#39;,2)&quot; onmouseout=&quot;this.src=&#39;https://dl.dropboxusercontent.com/u/28565502/images/twitterRed.png&#39;;&quot; onmouseover=&quot;this.src=&#39;https://dl.dropboxusercontent.com/u/28565502/images/twitterRedhover.png&#39;;&quot; src=&quot;https://dl.dropboxusercontent.com/u/28565502/images/twitterRed.png&quot; style=&quot;margin-right: 10px;&quot; width=&quot;50&quot; /&gt;

&lt;img alt=&quot;Compartir&quot; border=&quot;0&quot; height=&quot;50&quot; onclick=&quot;muestra_oculta(&#39;contenido_a_mostrar&#39;,3)&quot; onmouseout=&quot;this.src=&#39;https://dl.dropboxusercontent.com/u/28565502/images/LinkedIn-Logo.png&#39;;&quot; onmouseover=&quot;this.src=&#39;https://dl.dropboxusercontent.com/u/28565502/images/LinkedIn-Logohover.png&#39;;&quot; src=&quot;https://dl.dropboxusercontent.com/u/28565502/images/LinkedIn-Logo.png&quot; style=&quot;margin-right: 10px;&quot; width=&quot;50&quot; /&gt;

&lt;img alt=&quot;Compartir&quot; border=&quot;0&quot; height=&quot;50&quot; onclick=&quot;muestra_oculta(&#39;contenido_a_mostrar&#39;,4)&quot; onmouseout=&quot;this.src=&#39;https://dl.dropboxusercontent.com/u/28565502/images/rss.png&#39;;&quot; onmouseover=&quot;this.src=&#39;https://dl.dropboxusercontent.com/u/28565502/images/rsshover.png&#39;;&quot; src=&quot;https://dl.dropboxusercontent.com/u/28565502/images/rss.png&quot; style=&quot;margin-right: 10px;&quot; width=&quot;50&quot; /&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br /&gt;
&lt;div id=&quot;contenido_a_mostrar&quot;&gt;
&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;</description><link>http://thebestandroide.blogspot.com/2014/12/anadir-view-activity-android-java.html</link><author>noreply@blogger.com (David)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh8rdUpgRoaC2cQ0BPGmVbOPfHwMxHFfI_ldvtekHS8yLrV2Cuy_g_-lU0iJxbfSzjgQG_8n1x3VQh5u61RAZkf-0SWp38iS6OxISwv8xP7DWrBYMEjR3oyWPkUIU_Ksu3zjoG-Ln3_4Wra/s72-c/SCREENSHOT1.png" height="72" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-1686662779713559896.post-7823177197122136043</guid><pubDate>Mon, 01 Dec 2014 00:30:00 +0000</pubDate><atom:updated>2014-12-13T16:01:07.313+00:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">android no cambiar landscape</category><category domain="http://www.blogger.com/atom/ns#">Android orientacion vertical</category><category domain="http://www.blogger.com/atom/ns#">android orientation portrait</category><category domain="http://www.blogger.com/atom/ns#">android orientation vertical portrait</category><category domain="http://www.blogger.com/atom/ns#">thebestandroide orientacion</category><title>Aplicacion android con orientacion vetical (portrait) solo</title><description>&lt;a href=&quot;http://thebestandroide.blogspot.com.es/&quot;&gt;&lt;span style=&quot;color: #a5130f;&quot;&gt;Blog &lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #a5130f;&quot;&gt;&lt;a href=&quot;http://thebestandroide.blogspot.com/2014/06/lista-soluciones.html&quot;&gt; &amp;gt;Lista Soluciones &amp;gt;&lt;/a&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #a5130f;&quot;&gt;&lt;b&gt;Orientación sólo vertical (Portrait)&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;span style=&quot;font-size: x-large;&quot;&gt;Vamos a configurar nuestra aplicación android para que se ejecute sólo con orientación &lt;b&gt;vertical&lt;/b&gt; o &lt;b&gt;portrait&lt;/b&gt;.&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&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/AVvXsEhlqNgrOwf7KrSGt8pRCJGEu3n__RxU9ykbNZxebiyWHLVlBp3_67vAErPdlj5-EuQaWfCi5Vk4k_3HFX3_-2C5a_5Im3HFnb1zXMYRbg_XOU_23tZifwCSfVKV7z6zt5A40EGSyeDjuCAb/s1600/phoneportraitvlandscape.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/AVvXsEhlqNgrOwf7KrSGt8pRCJGEu3n__RxU9ykbNZxebiyWHLVlBp3_67vAErPdlj5-EuQaWfCi5Vk4k_3HFX3_-2C5a_5Im3HFnb1zXMYRbg_XOU_23tZifwCSfVKV7z6zt5A40EGSyeDjuCAb/s1600/phoneportraitvlandscape.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;span style=&quot;font-size: x-large;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;Esto se hace de una forma muy sencilla, vamos a nuestro AndroidManifiest.xml y añadimos esta línea:&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;container&quot;&gt;
&lt;div class=&quot;line number1 index0 alt2&quot;&gt;
&lt;code class=&quot;xml plain&quot;&gt;&amp;lt;?&lt;/code&gt;&lt;b&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;code class=&quot;xml keyword&quot;&gt;xml&lt;/code&gt;&lt;/span&gt;&lt;/b&gt; &lt;code class=&quot;xml color1&quot;&gt;version&lt;/code&gt;&lt;code class=&quot;xml plain&quot;&gt;=&lt;/code&gt;&lt;code class=&quot;xml string&quot;&gt;&quot;1.0&quot;&lt;/code&gt; &lt;code class=&quot;xml color1&quot;&gt;encoding&lt;/code&gt;&lt;code class=&quot;xml plain&quot;&gt;=&lt;/code&gt;&lt;code class=&quot;xml string&quot;&gt;&quot;utf-8&quot;&lt;/code&gt;&lt;code class=&quot;xml plain&quot;&gt;?&amp;gt;&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number2 index1 alt1&quot;&gt;
&lt;code class=&quot;xml plain&quot;&gt;&amp;lt;&lt;/code&gt;&lt;b&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;code class=&quot;xml keyword&quot;&gt;manifest&lt;/code&gt;&lt;/span&gt;&lt;/b&gt;&lt;code class=&quot;xml plain&quot;&gt;&amp;gt;&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number3 index2 alt2&quot;&gt;
&lt;code class=&quot;xml spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;xml plain&quot;&gt;&amp;lt;&lt;/code&gt;&lt;b&gt;&lt;span style=&quot;color: red;&quot;&gt;&lt;code class=&quot;xml keyword&quot;&gt;application&lt;/code&gt;&lt;/span&gt;&lt;/b&gt;&lt;code class=&quot;xml plain&quot;&gt;&amp;gt;&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number4 index3 alt1&quot;&gt;
&lt;code class=&quot;xml spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;xml plain&quot;&gt;&amp;lt;&lt;/code&gt;&lt;code class=&quot;xml keyword&quot;&gt;activity&lt;/code&gt; &lt;b&gt;&lt;span style=&quot;color: lime;&quot;&gt;&lt;code class=&quot;xml color1&quot;&gt;android:name&lt;/code&gt;&lt;/span&gt;&lt;/b&gt;&lt;code class=&quot;xml plain&quot;&gt;=&lt;/code&gt;&lt;code class=&quot;xml string&quot;&gt;&quot;mi.paquete.MiActivity&quot;&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number5 index4 alt2&quot;&gt;
&lt;code class=&quot;xml spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;b&gt;&lt;span style=&quot;color: lime;&quot;&gt;android:screenOrientation&lt;/span&gt;&lt;/b&gt;=&quot;portrait&quot;&lt;/code&gt; &lt;code class=&quot;xml plain&quot;&gt;/&amp;gt;&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number6 index5 alt1&quot;&gt;
&lt;code class=&quot;xml spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;xml plain&quot;&gt;&amp;lt;/&lt;/code&gt;&lt;b&gt;&lt;span style=&quot;color: red;&quot;&gt;&lt;code class=&quot;xml keyword&quot;&gt;application&lt;/code&gt;&lt;/span&gt;&lt;/b&gt;&lt;code class=&quot;xml plain&quot;&gt;&amp;gt;&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number7 index6 alt2&quot;&gt;
&lt;code class=&quot;xml plain&quot;&gt;&amp;lt;/&lt;/code&gt;&lt;b&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;code class=&quot;xml keyword&quot;&gt;manifest&lt;/code&gt;&lt;/span&gt;&lt;/b&gt;&lt;code class=&quot;xml plain&quot;&gt;&amp;gt;&lt;/code&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;span style=&quot;font-size: x-large;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;Pero oJoOoOo !! También se puede hacer desde la clase java de la actividad, en el onCreate :&amp;nbsp;&lt;/span&gt; &lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush:java&quot;&gt;setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
Y ya está, esta función podemos implementarla también si queremos en alguna ocasión manejar algo en el cambio de orientación :&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush:java&quot;&gt;@Override
public void onConfigurationChanged(Configuration newConfig) {
    super.onConfigurationChanged(newConfig);
 
    // Checks the orientation of the screen
    if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE) {
        Toast.makeText(this, &quot;landscape&quot;, Toast.LENGTH_SHORT).show();
    } else if (newConfig.orientation == Configuration.ORIENTATION_PORTRAIT){
        Toast.makeText(this, &quot;portrait&quot;, Toast.LENGTH_SHORT).show();
    }
}
&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Más info, en el sitio oficial &lt;a href=&quot;http://developer.android.com/guide/topics/resources/runtime-changes.html&quot; target=&quot;_blank&quot;&gt;aquí&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;script language=&quot;JavaScript&quot;&gt;
function muestra_oculta(id,tipo){
 var resultado=tipo
 var dir = document.location.href;
 var tit = document.title;
 var tit2 = encodeURIComponent(tit);
 var url =&quot;&quot;;
if(resultado==1){
 var url =&quot;http://www.facebook.com/share.php?u=&quot;+dir+&quot;&amp;t=&quot;+tit2
 window.open(url, &#39;TheBestAndroide&#39;);
}
if(resultado==2){
  var url =&quot;http://twitter.com/home?status=Estoy en &quot;+dir+&quot; leyendo &quot;+tit2
  window.open(url, &#39;TheBestAndroide&#39;);
}
if(resultado==3){
 var url =&quot;http://www.linkedin.com/shareArticle?mini=true&amp;url=&quot;+dir+&quot;&amp;title=&quot;+tit2+&quot;&amp;source=http://thebestandroide.blogspot.com.es/&quot;;
  window.open(url, &#39;TheBestAndroide&#39;);
}
if(resultado==4){
  var url =&quot;http://feeds.feedburner.com/Thebestandroide&quot;
  window.open(url, &#39;TheBestAndroide&#39;);
}

if (document.getElementById){ //se obtiene el id
var el = document.getElementById(id); //se define la variable &quot;el&quot; igual a nuestro div
el.style.display = (el.style.display == &#39;none&#39;) ? &#39;block&#39; : &#39;none&#39;; //damos un atributo display:none que oculta el div
}
}
window.onload = function(){/*hace que se cargue la función lo que predetermina que div estará oculto hasta llamar a la función nuevamente*/
muestra_oculta(&#39;contenido_a_mostrar&#39;);/* &quot;contenido_a_mostrar&quot; es el nombre que le dimos al DIV */
}
&lt;/script&gt;

&lt;br /&gt;
&lt;table style=&quot;width: 260px;&quot;&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;img alt=&quot;Compartir&quot; border=&quot;0&quot; height=&quot;50&quot; onclick=&quot;muestra_oculta(&#39;contenido_a_mostrar&#39;,1)&quot; onmouseout=&quot;this.src=&#39;https://dl.dropboxusercontent.com/u/28565502/images/redface.png&#39;;&quot; onmouseover=&quot;this.src=&#39;https://dl.dropboxusercontent.com/u/28565502/images/redfacehover.png&#39;;&quot; src=&quot;https://dl.dropboxusercontent.com/u/28565502/images/redface.png&quot; style=&quot;margin-right: 10px;&quot; width=&quot;50&quot; /&gt;

&lt;img alt=&quot;Compartir&quot; border=&quot;0&quot; height=&quot;50&quot; onclick=&quot;muestra_oculta(&#39;contenido_a_mostrar&#39;,2)&quot; onmouseout=&quot;this.src=&#39;https://dl.dropboxusercontent.com/u/28565502/images/twitterRed.png&#39;;&quot; onmouseover=&quot;this.src=&#39;https://dl.dropboxusercontent.com/u/28565502/images/twitterRedhover.png&#39;;&quot; src=&quot;https://dl.dropboxusercontent.com/u/28565502/images/twitterRed.png&quot; style=&quot;margin-right: 10px;&quot; width=&quot;50&quot; /&gt;

&lt;img alt=&quot;Compartir&quot; border=&quot;0&quot; height=&quot;50&quot; onclick=&quot;muestra_oculta(&#39;contenido_a_mostrar&#39;,3)&quot; onmouseout=&quot;this.src=&#39;https://dl.dropboxusercontent.com/u/28565502/images/LinkedIn-Logo.png&#39;;&quot; onmouseover=&quot;this.src=&#39;https://dl.dropboxusercontent.com/u/28565502/images/LinkedIn-Logohover.png&#39;;&quot; src=&quot;https://dl.dropboxusercontent.com/u/28565502/images/LinkedIn-Logo.png&quot; style=&quot;margin-right: 10px;&quot; width=&quot;50&quot; /&gt;

&lt;img alt=&quot;Compartir&quot; border=&quot;0&quot; height=&quot;50&quot; onclick=&quot;muestra_oculta(&#39;contenido_a_mostrar&#39;,4)&quot; onmouseout=&quot;this.src=&#39;https://dl.dropboxusercontent.com/u/28565502/images/rss.png&#39;;&quot; onmouseover=&quot;this.src=&#39;https://dl.dropboxusercontent.com/u/28565502/images/rsshover.png&#39;;&quot; src=&quot;https://dl.dropboxusercontent.com/u/28565502/images/rss.png&quot; style=&quot;margin-right: 10px;&quot; width=&quot;50&quot; /&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br /&gt;
&lt;div id=&quot;contenido_a_mostrar&quot;&gt;
&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;</description><link>http://thebestandroide.blogspot.com/2014/12/aplicacion-android-con-orientacion.html</link><author>noreply@blogger.com (David)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhlqNgrOwf7KrSGt8pRCJGEu3n__RxU9ykbNZxebiyWHLVlBp3_67vAErPdlj5-EuQaWfCi5Vk4k_3HFX3_-2C5a_5Im3HFnb1zXMYRbg_XOU_23tZifwCSfVKV7z6zt5A40EGSyeDjuCAb/s72-c/phoneportraitvlandscape.png" height="72" width="72"/><thr:total>4</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-1686662779713559896.post-1121796876224712491</guid><pubDate>Fri, 07 Nov 2014 16:44:00 +0000</pubDate><atom:updated>2014-11-08T13:02:50.841+00:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">android como escribo tweet</category><category domain="http://www.blogger.com/atom/ns#">android twittear</category><category domain="http://www.blogger.com/atom/ns#">android twitter</category><category domain="http://www.blogger.com/atom/ns#">twittear android</category><category domain="http://www.blogger.com/atom/ns#">twittear aplicacion android</category><title>Mi aplicación Android con Twitter : Escribir un tweet</title><description>&lt;a href=&quot;http://thebestandroide.blogspot.com.es/&quot;&gt;&lt;span style=&quot;color: #a5130f;&quot;&gt;Blog &lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #a5130f;&quot;&gt;&lt;a href=&quot;http://thebestandroide.blogspot.com.es/2014/10/comunicacion-con-servidores-en.html&quot;&gt; &amp;gt;Comunicación con servidor &amp;gt;&lt;/a&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #a5130f;&quot;&gt;&lt;b&gt;Enviar Tweet desde aplicación Android&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
Continuamos con el apartado &lt;span style=&quot;color: #a5130f;&quot;&gt;&lt;b&gt;Mi aplicación Android con Twitter&lt;/b&gt;&lt;/span&gt;, vamos a ver como generar un &lt;b&gt;Tweet&lt;/b&gt; desde nuestra aplicación.&lt;br /&gt;
&lt;span style=&quot;font-size: x-large;&quot;&gt;&amp;nbsp; &lt;/span&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;span style=&quot;font-size: x-large;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgAvhqHHaBJun4bekd7ts6UvGeSbZtc-84VFofmsJJ5p-6dRDTvoRWS-9RfQccjNi3EFfK1gLXrj1_aiW5AndlloQtbNhUAnabVvBTz4e6m7wL4yVvRPI5HZmqu1Byc1Ec8eLTnAuLHbRnE/s1600/cabecera2.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/AVvXsEgAvhqHHaBJun4bekd7ts6UvGeSbZtc-84VFofmsJJ5p-6dRDTvoRWS-9RfQccjNi3EFfK1gLXrj1_aiW5AndlloQtbNhUAnabVvBTz4e6m7wL4yVvRPI5HZmqu1Byc1Ec8eLTnAuLHbRnE/s1600/cabecera2.jpg&quot; height=&quot;320&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;span style=&quot;color: #a5130f; font-size: x-large;&quot;&gt;&lt;b&gt;Mandar un tweet desde nuestra aplicación Android&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #a5130f;&quot;&gt;&lt;b&gt;&amp;nbsp;&lt;/b&gt;&lt;/span&gt; 
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;El proyecto que os expongo tiene las librerías y las clases necesarias para poder mandar un tweet &lt;u&gt;&lt;b&gt;sin &lt;/b&gt;Twitter instalado&lt;/u&gt; en el dispositivo, es decir desde esta aplicación se verifica la aplicación que previamente se ha instalado en twitter y que se comenta en este&lt;span style=&quot;color: #a5130f;&quot;&gt;&lt;b&gt; &lt;span style=&quot;color: black;&quot;&gt;&lt;a href=&quot;http://thebestandroide.blogspot.com.es/2014/11/crear-aplicacion-twitter-para-android.html&quot; target=&quot;_blank&quot;&gt;post&lt;/a&gt;&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;. &lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&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/AVvXsEj4uERRK84LIgRn9TyZ3lrM9vU2CyKpsuqISAaWQ0UhMeLCWE6ygCdp3fkDV5n1lwZSZbFp9e6YpQBMxIz5g9asZH4bFiOPb2l3xNM8aOuWkXKDAxRkYBArDh4sbW7tch-lG9qs9mYGE_D9/s1600/cabecera1.jpg&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;br /&gt;&lt;/a&gt;&lt;/div&gt;
&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/AVvXsEivaGnXVvM-TwNnCMyUYjWw0lpgKiMbU4-7jCEVowxUUwtVMHsWhFiXvUZ4YRt-30FaML87WDZhhvQt3YcgQ1rVzlE6NzWeed3DpVuOpziQ2djCsL375XyyZiNhkUd7NS6ESCN2NHXMr5PI/s1600/cabecera1.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/AVvXsEivaGnXVvM-TwNnCMyUYjWw0lpgKiMbU4-7jCEVowxUUwtVMHsWhFiXvUZ4YRt-30FaML87WDZhhvQt3YcgQ1rVzlE6NzWeed3DpVuOpziQ2djCsL375XyyZiNhkUd7NS6ESCN2NHXMr5PI/s1600/cabecera1.png&quot; height=&quot;360&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: x-large;&quot;&gt;La función de esta aplicación va permitirnos conectarnos realizar una conexión &lt;/span&gt;&lt;span style=&quot;font-size: x-large;&quot;&gt;&lt;span style=&quot;color: #a5130f;&quot;&gt;&lt;b&gt;http a twitter mandando las claves que previamente teníamos en la cabecera de la petición.&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: x-large;&quot;&gt;&lt;span style=&quot;color: #a5130f;&quot;&gt;&lt;b&gt;&amp;nbsp;&lt;/b&gt;&lt;/span&gt; &lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: x-large;&quot;&gt;&lt;span style=&quot;color: #a5130f;&quot;&gt;&lt;b&gt;1. Instalar librerías y permiso a la app de internet&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Tendremos que darle a la aplicación permisos para que pueda conectarse a Internet&lt;/span&gt;.&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Nos va a hacer falta usar varias librerias, unas que tienen que ver con el framework de twitter, otras para la autentificación y otra para la conexión http : &lt;/span&gt;&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;a href=&quot;https://dl.dropbox.com/s/mq1reeyazayjamn/httpclient-4.0.1.jar?dl=0&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;httpclient-4.0.1.jar &lt;/a&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;a href=&quot;https://dl.dropbox.com/s/o5wto1a86uvio2z/signpost-core-1.2.1.1.jar?dl=0&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;signpost-core-1.2.1.1.jar&lt;/a&gt;&amp;nbsp;
&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;a href=&quot;https://dl.dropbox.com/s/axqax6wmw7ens5p/signpost-commonshttp4-1.2.1.1.jar?dl=0&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;signpost-commonshttp4-1.2.1.1.jar &lt;/a&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;a href=&quot;https://dl.dropbox.com/s/hrkulzgv5xrmuwb/twitter4j-core-4.0.2.jar?dl=0&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;twitter4j-core-4.0.2.jar&lt;/a&gt; &lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;O también os he preparado un rar con todas ellas juntas que podreis encontrar &lt;a href=&quot;https://www.dropbox.com/s/vivbgzplcrtje3a/librerias.rar?dl=0&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;&lt;span style=&quot;color: #a5130f;&quot;&gt;&lt;b&gt;aquí&lt;/b&gt;&lt;/span&gt;&lt;/a&gt;.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&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/AVvXsEj4uERRK84LIgRn9TyZ3lrM9vU2CyKpsuqISAaWQ0UhMeLCWE6ygCdp3fkDV5n1lwZSZbFp9e6YpQBMxIz5g9asZH4bFiOPb2l3xNM8aOuWkXKDAxRkYBArDh4sbW7tch-lG9qs9mYGE_D9/s1600/cabecera1.jpg&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/AVvXsEj4uERRK84LIgRn9TyZ3lrM9vU2CyKpsuqISAaWQ0UhMeLCWE6ygCdp3fkDV5n1lwZSZbFp9e6YpQBMxIz5g9asZH4bFiOPb2l3xNM8aOuWkXKDAxRkYBArDh4sbW7tch-lG9qs9mYGE_D9/s1600/cabecera1.jpg&quot; height=&quot;300&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&lt;span style=&quot;font-size: x-large;&quot;&gt;&lt;span style=&quot;color: #a5130f;&quot;&gt;&lt;b&gt;2. Creación de interfad, inicio sesión configuración clases y conexión a Twitter&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: x-large;&quot;&gt;&lt;span style=&quot;color: #a5130f;&quot;&gt;&lt;b&gt;&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;
&lt;br /&gt;
Creamos un proyecto nuevo, y vamos a darle la interfaz de usuario, pero antes agregamos estos recursos :&lt;br /&gt;
&lt;br /&gt;
&lt;i&gt;&lt;span style=&quot;font-size: large;&quot;&gt;Carpeta values...&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;b&gt;colores.xml :&lt;/b&gt;&lt;/span&gt;&lt;br /&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;nbsp;&amp;nbsp; &amp;lt;color name=&quot;negro&quot; &amp;gt;#000000&amp;lt;/color&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;lt;color name=&quot;blanco&quot;&amp;gt;#ffffff&amp;lt;/color&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;lt;color name=&quot;colorTweet&quot;&amp;gt;#908686&amp;lt;/color&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;color name=&quot;colorFace&quot;&amp;gt;#3b5997&amp;lt;/color&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;lt;color name=&quot;colorTwitter&quot;&amp;gt;#1ab2e8&amp;lt;/color&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;lt;color name=&quot;RojoError&quot;&amp;gt;#e81a29&amp;lt;/color&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &lt;br /&gt;
&amp;lt;/resources&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;i&gt;&lt;span style=&quot;font-size: large;&quot;&gt;Carpeta drawable...&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;b&gt;botontwitter&lt;/b&gt; : Apariencia del botón al enviar tweets&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&amp;gt;&lt;br /&gt;
&amp;lt;selector xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot; &amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;item android:state_pressed=&quot;true&quot;&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;shape&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;!-- color de fondo --&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;solid android:color=&quot;@android:color/white&quot;/&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;!-- curvatura esquinas&amp;nbsp; --&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;corners android:radius=&quot;12dp&quot;/&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;!-- padding para separar entre elementos contenidos y el borde --&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;padding android:left=&quot;10dp&quot;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; android:right=&quot;10dp&quot;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; android:top=&quot;10dp&quot;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; android:bottom=&quot;10dp&quot;/&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/shape&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/item&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;b&gt;twitter_check&lt;/b&gt; : recurso xml que cambia de forma automática la imagen del checkbox&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&amp;gt;&lt;br /&gt;
&amp;lt;selector xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;item &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; android:state_checked=&quot;true&quot; &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; android:state_window_focused=&quot;true&quot;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; android:state_enabled=&quot;true&quot;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; android:drawable=&quot;@drawable/twitter_cnn&quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;item &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; android:state_checked=&quot;false&quot; &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; android:state_window_focused=&quot;true&quot;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; android:state_enabled=&quot;true&quot;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:drawable=&quot;@drawable/twitter_desc&quot; /&amp;gt;&lt;br /&gt;
&amp;lt;/selector&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Este ultimo recurso usa 2 imágenes que hay que arrastrar al proyecto, así que cada uno se lo personalice como quiera,y una vez tenemos esto, vamos con el activity_main.xml : &lt;br /&gt;
&lt;br /&gt;
&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/AVvXsEiWYm0qXVn7wUBeZbgHAL6gB1w389HDTGxY_dU9OZY8YJp_zwCeAaF06cZbWpn6aeK6k2IsiI0rJlXtUEIGIKEneuRH0gVYznfmq6tVB6PJxZDRT_GQ6eON8nhGVFO9SY_u9TxJzSsrbNvy/s1600/screenshot0.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/AVvXsEiWYm0qXVn7wUBeZbgHAL6gB1w389HDTGxY_dU9OZY8YJp_zwCeAaF06cZbWpn6aeK6k2IsiI0rJlXtUEIGIKEneuRH0gVYznfmq6tVB6PJxZDRT_GQ6eON8nhGVFO9SY_u9TxJzSsrbNvy/s1600/screenshot0.png&quot; height=&quot;344&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;RelativeLayout xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; android:id=&quot;@+id/TWITTTEAR&quot;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; android:layout_width=&quot;match_parent&quot;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; android:layout_height=&quot;match_parent&quot;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; android:orientation=&quot;vertical&quot; &amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;lt;LinearLayout&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:layout_width=&quot;fill_parent&quot;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:layout_height=&quot;wrap_content&quot;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:orientation=&quot;vertical&quot; &amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;CheckBox&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:id=&quot;@+id/twitterCheckConnection&quot;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:layout_width=&quot;wrap_content&quot;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:layout_height=&quot;wrap_content&quot;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:layout_marginLeft=&quot;5dp&quot;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:text=&quot;Conectado&quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;CheckBox&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; android:id=&quot;@+id/twitterCheck&quot;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; android:layout_width=&quot;wrap_content&quot;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; android:layout_height=&quot;wrap_content&quot;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; android:layout_marginLeft=&quot;5dp&quot;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; android:clickable=&quot;true&quot;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; android:focusable=&quot;true&quot;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; android:text=&quot;Conectado usuario&quot;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; android:textColor=&quot;@color/colorTwitter&quot;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; android:textSize=&quot;14sp&quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/LinearLayout&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;lt;LinearLayout&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:layout_width=&quot;fill_parent&quot;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:layout_height=&quot;wrap_content&quot;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:layout_alignParentBottom=&quot;true&quot;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:layout_alignParentLeft=&quot;true&quot;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:orientation=&quot;vertical&quot; &amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;EditText&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:id=&quot;@+id/tweet&quot;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:layout_width=&quot;match_parent&quot;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:layout_height=&quot;wrap_content&quot;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:maxLines=&quot;3&quot;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:textColor=&quot;@color/colorTweet&quot; &amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;requestFocus /&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/EditText&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;LinearLayout&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:layout_width=&quot;fill_parent&quot;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:layout_height=&quot;wrap_content&quot;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:layout_marginTop=&quot;10dp&quot; &amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;TextView&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:id=&quot;@+id/contarCaracteresTwitter&quot;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:layout_width=&quot;wrap_content&quot;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:layout_height=&quot;wrap_content&quot;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:layout_gravity=&quot;center_vertical&quot;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:layout_marginBottom=&quot;10dp&quot;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:layout_marginLeft=&quot;20dp&quot;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:text=&quot;0&quot;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:textColor=&quot;@color/colorTwitter&quot;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:textSize=&quot;20sp&quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;LinearLayout&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:layout_width=&quot;fill_parent&quot;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:layout_height=&quot;wrap_content&quot;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:orientation=&quot;vertical&quot; &amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;Button&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:id=&quot;@+id/enviarTweet&quot;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; style=&quot;?android:attr/buttonStyleSmall&quot;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:layout_width=&quot;wrap_content&quot;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:layout_height=&quot;wrap_content&quot;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:layout_gravity=&quot;right&quot;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:layout_marginBottom=&quot;5dp&quot;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:layout_marginRight=&quot;10dp&quot;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:background=&quot;@drawable/botontwitter&quot;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:text=&quot;Enviar&quot;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:textColor=&quot;@color/blanco&quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/LinearLayout&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/LinearLayout&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;lt;/LinearLayout&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;lt;LinearLayout&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:layout_width=&quot;fill_parent&quot;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:layout_height=&quot;280dp&quot;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:layout_alignParentLeft=&quot;false&quot;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:layout_alignParentTop=&quot;false&quot;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:layout_centerHorizontal=&quot;true&quot;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:layout_centerVertical=&quot;true&quot;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:orientation=&quot;vertical&quot; &amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;ListView&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:id=&quot;@+id/listView1&quot;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:layout_width=&quot;match_parent&quot;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:layout_height=&quot;wrap_content&quot; &amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/ListView&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;lt;/LinearLayout&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/RelativeLayout&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Y este es nuestro main de momento :&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush:java&quot;&gt;public class MainActivity extends Activity {
 //CLAVES
 private static final String twitter_consumer_key = &quot;AQUI TU CONSUMER_KEY&quot;;
 private static final String twitter_secret_key = &quot;AQUI TU TWITTER_SECRET_KEY&quot;;

 //Elementos
 private CheckBox connectionCheck;
 private CheckBox userCheck;
 private ListView lista;
 private Button BotonEnviarTweet;
 private EditText tweet;
 private TextView Ncaracteres;
 
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        //INSTANCIAMOS ELEMENTOS
        instanciarElementos();
         //INICIAMOS VARIABLES
       mTwitter = new TwitterApp(this, twitter_consumer_key,twitter_secret_key);
       mTwitter.setListener(mTwLoginDialogListener);
        //BOTON PARA ENVIAR TWEETS
        BotonEnviarTweet.setOnClickListener(new OnClickListener(){
   @Override
   public void onClick(View v) {
    // TODO Auto-generated method stub
    
   }
        });
        //CHECKBOX CONECTAR
        registerCheck.setOnClickListener(new OnClickListener() {
   @Override
   public void onClick(View v) {

   }
  });
        //CHECKBOX USER
        connectionCheck.setOnClickListener(new OnClickListener() {
   @Override
   public void onClick(View v) {

   }
  });
              
    }
   public void instanciarElementos(){
     //Elementos
     registerCheck = (CheckBox) findViewById(R.id.twitterCheckConnection);
     connectionCheck = (CheckBox) findViewById(R.id.twitterCheck);
     lista  =  (ListView) findViewById(R.id.listViewTweets);
     BotonEnviarTweet = (Button) findViewById(R.id.enviarTweet);
     tweet =  (EditText) findViewById(R.id.tweet);
     Ncaracteres =(TextView) findViewById(R.id.contarCaracteresTwitter);
    }
}
&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Seguimos con otra clase : &lt;b&gt;TwitterSession&lt;/b&gt;.&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Esta clase contiene los datos de registro en twitter, como la gestión de las preferencias para guardar los datos para identificarte en Twitter.
&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush:java&quot;&gt;public class TwitterSession {
 private SharedPreferences sharedPref;
 private Editor editor;
 
 private static final String TWEET_AUTH_KEY = &quot;auth_key&quot;;
 private static final String TWEET_AUTH_SECRET_KEY = &quot;auth_secret_key&quot;;
 private static final String TWEET_USER_NAME = &quot;user_name&quot;;
 private static final String SHARED = &quot;Twitter_Preferences&quot;;
 
 public TwitterSession(Context context) {
  sharedPref= context.getSharedPreferences(SHARED, Context.MODE_PRIVATE);
  editor= sharedPref.edit();
 }
 
 public void storeAccessToken(AccessToken accessToken, String username) {
  editor.putString(TWEET_AUTH_KEY, accessToken.getToken());
  editor.putString(TWEET_AUTH_SECRET_KEY, accessToken.getTokenSecret());
  editor.putString(TWEET_USER_NAME, username);
  
  editor.commit();
 }
 
 public void resetAccessToken() {
  editor.putString(TWEET_AUTH_KEY, null);
  editor.putString(TWEET_AUTH_SECRET_KEY, null);
  editor.putString(TWEET_USER_NAME, null);
  
  editor.commit();
 }
 
 public String getUsername() {
  return sharedPref.getString(TWEET_USER_NAME, &quot;&quot;);
 }
 
 public AccessToken getAccessToken() {
  String token   = sharedPref.getString(TWEET_AUTH_KEY, null);
  String tokenSecret  = sharedPref.getString(TWEET_AUTH_SECRET_KEY, null);
  
  if (token != null &amp;amp;&amp;amp; tokenSecret != null) 
   return new AccessToken(token, tokenSecret);
  else
   return null;
 }
}
&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Ahora vamos a insertar una nueva clase :&lt;b&gt; TwitterApp&lt;/b&gt;.&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;En ella vemos como se gestiona la llamada http, el registro mediante la cabecera en Twitter y la recogida de la respuesta.
&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush:java&quot;&gt;//CLASE CON LOS PARAMETROS PARA CONECTAR EN TWITTER
public class TwitterApp {
 
 private Twitter mTwitter;
 private TwitterSession mSession;
 private AccessToken mAccessToken;
 private CommonsHttpOAuthConsumer mHttpOauthConsumer;
 private OAuthProvider mHttpOauthprovider;
 private String mConsumerKey;
 private String mSecretKey;
 private ProgressDialog mProgressDlg;
 private TwDialogListener mListener;
 private Context context;
 private boolean mInit = true;
 
 public static final String CALLBACK_URL = &quot;twitterapp://connect&quot;;
 private static final String TAG = &quot;TwitterApp&quot;;
 
 //CONSTRUCTOR
 public TwitterApp(Context context, String consumerKey, String secretKey) {
  this.context= context;
  
  //INSTANCIA TWITTER
  mTwitter = new TwitterFactory().getInstance();
  mSession= new TwitterSession(context);
  mProgressDlg= new ProgressDialog(context);
  
  mProgressDlg.requestWindowFeature(Window.FEATURE_NO_TITLE);
  
  //DATOS ACCESO TWITTER
  setmConsumerKey(consumerKey);
  setmSecretKey(secretKey);
  //REALIZAMOS LA CONEXION CON RESPUESTA
  mHttpOauthConsumer = new CommonsHttpOAuthConsumer(getmConsumerKey(), getmSecretKey());
  mHttpOauthprovider = new DefaultOAuthProvider(&quot;https://api.twitter.com/oauth/request_token &quot;,
              &quot;https://api.twitter.com/oauth/access_token&quot;,
              &quot;https://api.twitter.com/oauth/authorize&quot;);
  
  mAccessToken= mSession.getAccessToken();
  
  configureToken();
 }
 //DEVUELVE EL LISTENER PARA EL ALERTDIALOG
 public void setListener(TwDialogListener listener) {
  mListener = listener;
 }
 
 //funcion para iniciar sesion la primera vez
 private void configureToken() {
  if (mAccessToken != null) {
   if (mInit) {
    mTwitter.setOAuthConsumer(getmConsumerKey(), getmSecretKey());
    mInit = false;
   }
   mTwitter.setOAuthAccessToken(mAccessToken);
  }
 }
 
 public boolean estasConectado() {
  if(mAccessToken == null){
   return false;
  }
   return true;
 }
 
 public void resetAccessToken() {
  if (mAccessToken != null) {
   mSession.resetAccessToken();
  
   mAccessToken = null;
  }
 }
 
 public String getUsername() {
  return mSession.getUsername();
 }
 
 public void updateStatus(String status) throws Exception {
  try {
   mTwitter.updateStatus(status);
  } catch (TwitterException e) {
   throw e;
  }
 }
 
 public void authorize() {
  mProgressDlg.setMessage(&quot;Initializing ...&quot;);
  mProgressDlg.show();
  //NUEVO HILO CON EL ALERT PARA QUE SE ABRA LA VENTANA
  new Thread() {
   @Override
   public void run() {
    String authUrl = &quot;&quot;;
    int what = 1;
    
    try {
     //hacemos la llamada al navegador
     authUrl = mHttpOauthprovider.retrieveRequestToken(mHttpOauthConsumer, CALLBACK_URL); 
     what = 0;
     Log.d(TAG, &quot;Request token url &quot; + authUrl);
    } catch (Exception e) {
     //EL PROCESO HA FALLADO
     Log.d(TAG, &quot;Failed to get request token&quot;);
     e.printStackTrace();
    }
    
    mHandler.sendMessage(mHandler.obtainMessage(what, 1, 0, authUrl));
   }
  }.start();
 }
 //
 public void processToken(String callbackUrl)  {
  mProgressDlg.setMessage(&quot;Finalizing ...&quot;);
  mProgressDlg.show();
  
  final String verifier = getVerifier(callbackUrl);

  new Thread() {
   @Override
   public void run() {
    int what = 1;
    
    try {
     mHttpOauthprovider.retrieveAccessToken(mHttpOauthConsumer, verifier);
     mAccessToken = new AccessToken(mHttpOauthConsumer.getToken(), mHttpOauthConsumer.getTokenSecret());
     Log.d(TAG, &quot;Token: &quot; + mAccessToken.getToken());
     configureToken();
     User user = mTwitter.verifyCredentials();
           mSession.storeAccessToken(mAccessToken, user.getName());
           what = 0;
    } catch (Exception e){
     Log.d(TAG, &quot;Error getting access token&quot;);
     e.printStackTrace();
    }
    
    mHandler.sendMessage(mHandler.obtainMessage(what, 2, 0));
   }
  }.start();
 }
 //RECOJEMOS LA RESPUESTA
 @SuppressWarnings(&quot;deprecation&quot;)
 private String getVerifier(String callbackUrl) {
  String verifier  = &quot;&quot;;
  
  try {
   callbackUrl = callbackUrl.replace(&quot;twitterapp&quot;, &quot;http&quot;);
   
   URL url   = new URL(callbackUrl);
   String query  = url.getQuery();
  
   String array[] = query.split(&quot;&amp;amp;&quot;);

   for (String parameter : array) {
              String v[] = parameter.split(&quot;=&quot;);
              
              if (URLDecoder.decode(v[0]).equals(oauth.signpost.OAuth.OAUTH_VERIFIER)) {
               verifier = URLDecoder.decode(v[1]);
               break;
              }
         }
  } catch (MalformedURLException e) {
   e.printStackTrace();
  }
  
  return verifier;
 }
 
 private void showLoginDialog(String url) {
  final TwDialogListener listener = new TwDialogListener() {
   @Override
   public void onComplete(String value) {
    processToken(value);
   }
   
   @Override
   public void onError(String value) {
    mListener.onError(&quot;Failed opening authorization page&quot;);
   }
  };
  
  new TwitterDialog(context, url, listener).show();
 }
 
 public String getmConsumerKey() {
  return mConsumerKey;
 }
 public void setmConsumerKey(String mConsumerKey) {
  this.mConsumerKey = mConsumerKey;
 }

 public String getmSecretKey() {
  return mSecretKey;
 }
 public void setmSecretKey(String mSecretKey) {
  this.mSecretKey = mSecretKey;
 }

 private Handler mHandler = new Handler() {
  @Override
  public void handleMessage(Message msg) {
   mProgressDlg.dismiss();
   
   if (msg.what == 1) {
    if (msg.arg1 == 1)
     mListener.onError(&quot;Error getting request token&quot;);
    else
     mListener.onError(&quot;Error getting access token&quot;);
   } else {
    if (msg.arg1 == 1)
     showLoginDialog((String) msg.obj);
    else
     mListener.onComplete(&quot;&quot;);
   }
  }
 };
 
 public interface TwDialogListener {
  public void onComplete(String value);  
  
  public void onError(String value);
 }
}
&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Esta clase también usa una interfad como listener, esto es para que cuando esté abierto el WebView dentro del dialog, podamos interactuar con ella posteriormente de forma automática vuelve el foco a la activity.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;La clase &lt;b&gt;TwitterDialog&lt;/b&gt;, que usa un alertDialog y se introduce un webView dentro, personaliza la cabecera del dialog y usa de apoyo una clase que hereda de WebViewClient, que es la que nos vale para interactuar con el webView que hay dentro del dialog.
&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush:java&quot;&gt;public class TwitterDialog extends Dialog {
    static final FrameLayout.LayoutParams FILL = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
                               ViewGroup.LayoutParams.MATCH_PARENT);
    static final int MARGIN = 4;
    static final int PADDING = 2;

    private String mUrl;
    private TwDialogListener mListener;
    private ProgressDialog mDialog;
    private WebView mWebView;
    private LinearLayout mContent;
    private TextView mTitulo;

    private static final String TAG = &quot;Twitter-WebView&quot;;
    
    public TwitterDialog(Context context, String url, TwDialogListener listener) {
        super(context);
        
        mUrl= url;
        mListener=listener;
    }

 @SuppressWarnings(&quot;deprecation&quot;)
 @Override
 //ESTA CLASE CARGA UN WEBVIEW EN UN DIALOG
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        mDialog = new ProgressDialog(getContext());
        mDialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
        mDialog.setMessage(&quot;Cargando...&quot;);
        mContent = new LinearLayout(getContext());
        mContent.setOrientation(LinearLayout.VERTICAL);
        setUpTitle();
        setUpWebView();
        
        Display display = getWindow().getWindowManager().getDefaultDisplay();
  Point outSize= new Point();
  
  int width= 0;
  int height= 0;
  
  double[] dimensions = new double[2];
          
  if (Build.VERSION.SDK_INT &amp;gt;= Build.VERSION_CODES.HONEYCOMB_MR2) {
   display.getSize(outSize);
   
   width = outSize.x;
   height = outSize.y;
  } else {
   width = display.getWidth();
   height = display.getHeight();
  }
  
  if (width &amp;lt; height) {
   dimensions[0] = 0.87 * width;
         dimensions[1] = 0.82 * height;
  } else {
   dimensions[0] = 0.75 * width;
   dimensions[1] = 0.75 * height;         
  }
        
        addContentView(mContent, new FrameLayout.LayoutParams((int) dimensions[0], (int) dimensions[1]));
    }
 //QUITA EL TITULO DEL DIALOG Y CONFIGURA UN TEXTVIEW 
 //QUE APARECERÁ COMO TÍTULO
    private void setUpTitle() {
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        
        Drawable icon = getContext().getResources().getDrawable(R.drawable.twitter_desc);
        
        mTitulo = new TextView(getContext());
        
        mTitulo.setText(&quot;Twitter&quot;);
        mTitulo.setTextColor(Color.WHITE);
        mTitulo.setTypeface(Typeface.DEFAULT_BOLD);
        mTitulo.setBackgroundColor(0xFFbbd7e9);
        mTitulo.setPadding(MARGIN + PADDING, MARGIN, MARGIN, MARGIN);
        mTitulo.setCompoundDrawablePadding(MARGIN + PADDING);
        mTitulo.setCompoundDrawablesWithIntrinsicBounds(icon, null, null, null);
        
        mContent.addView(mTitulo);
    }

    @SuppressLint(&quot;SetJavaScriptEnabled&quot;)
 private void setUpWebView() {
     CookieSyncManager.createInstance(getContext()); 
        CookieManager cookieManager = CookieManager.getInstance();
        cookieManager.removeAllCookie();
        
        mWebView = new WebView(getContext());
        
        mWebView.setVerticalScrollBarEnabled(false);
        mWebView.setHorizontalScrollBarEnabled(false);
        mWebView.setWebViewClient(new TwitterWebViewClient());
        mWebView.getSettings().setJavaScriptEnabled(true);
        mWebView.loadUrl(mUrl);
        mWebView.setLayoutParams(FILL);
        
        mContent.addView(mWebView);
    }

    //CLASE QUE HEREDA DE WEBVIEWCLIENT Y LLEVA LA GESTION DE LA WEBVIEW SW CREDENCIALES
    private class TwitterWebViewClient extends WebViewClient {
     //METODO PARA CARGAR LA WEB
        @Override
        public boolean shouldOverrideUrlLoading(WebView view, String url) {
         Log.d(TAG, &quot;Redirecting URL &quot; + url);
         
         if (url.startsWith(TwitterApp.CALLBACK_URL)) {
          mListener.onComplete(url);
          
          TwitterDialog.this.dismiss();
          
          return true;
         }  else if (url.startsWith(&quot;authorize&quot;)) {
          return false;
         }
            return true;
        }
        //SI LA PAGINA DA ERROR
        @Override
        public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
         Log.d(TAG, &quot;Page error: &quot; + description);
            super.onReceivedError(view, errorCode, description, failingUrl);
            mListener.onError(description);
            TwitterDialog.this.dismiss();
        }

        @Override
        public void onPageStarted(WebView view, String url, Bitmap favicon) {
            Log.d(TAG, &quot;Loading URL: &quot; + url);
            super.onPageStarted(view, url, favicon);
            mDialog.show();
        }

        @Override
        public void onPageFinished(WebView view, String url) {
            super.onPageFinished(view, url);
            String title = mWebView.getTitle();
            if (title != null &amp;amp;&amp;amp; title.length() &amp;gt; 0) {
                mTitulo.setText(title);
            }
            mDialog.dismiss();
        }

    }
}
&lt;/pre&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Y ahora implementamos en el main 2 funciones, que dependiendo si se está registrado o no, saca el dialog con el webview para insertar las credenciales, o por otro lado si se está registrado, se prepara para enviar el tweet.
&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush:java&quot;&gt;     private void onTwitterClick() {
  //SI YA ESTAS CONECTADO A TWITTER
  if (mTwitter.estasConectado()) {
   final AlertDialog.Builder builder = new AlertDialog.Builder(this);
   //MESAJE CON LA CONFIRMACION DE LA DESCONEXION
   builder.setMessage(&quot;Delete current Twitter connection?&quot;)
          .setCancelable(false)
          .setPositiveButton(&quot;Yes&quot;, new DialogInterface.OnClickListener() {
              @SuppressLint(&quot;ResourceAsColor&quot;) 
              public void onClick(DialogInterface dialog, int id) {
               mTwitter.resetAccessToken();
               
               //ACTUALIZAMOS CHECKBOX
               registerCheck.setChecked(false);
               registerCheck.setText(&quot; Not connected &quot;);
               registerCheck.setTextColor(R.color.colorTweet);
              }
          })
          //EN EL CASO DE QUE SE PULSE NO, VOLVEMOS A LA PRIMERA PANTALLA
          .setNegativeButton(&quot;No&quot;, new DialogInterface.OnClickListener() {
              public void onClick(DialogInterface dialog, int id) {
                   dialog.cancel();
                   registerCheck.setChecked(true);
              }
          });
   final AlertDialog alert = builder.create();
   
   alert.show();
   //SINO ESTAS CONECTADO MANDAMOS A AUTHORIZE, DONDE APARECE
   //PARA ENVIAR LAS CREDENCIALES DE AUTENTIFICACION
  } else {
   registerCheck.setChecked(false);
   //Cargamos loading... mas credenciales de twitter
   mTwitter.authorize();
  }
 }

 @SuppressLint(&quot;ResourceAsColor&quot;) 
 private final TwDialogListener mTwLoginDialogListener = new TwDialogListener() {
  @Override
  public void onComplete(String value) {
   //YA CONECTADO PIDE EL NOMBRE A LA RESPUESTA HTTP
   String username = mTwitter.getUsername();
   username= (username.equals(&quot;&quot;)) ? &quot;No Name&quot; : username;
   
   registerCheck.setText(&quot;  Conectado (&quot; + username + &quot;)&quot;);
   registerCheck.setChecked(true);
   registerCheck.setTextColor(R.color.colorTweet);
   Toast.makeText(MainActivity.this, &quot;Connected to Twitter as &quot; + username, Toast.LENGTH_LONG).show();
   //startActivity(new Intent(MainActivity.this, TestPost.class));
  }
  
  @Override
  public void onError(String value) {
   
   registerCheck.setChecked(false);
   Toast.makeText(MainActivity.this, &quot;Twitter connection failed&quot;, Toast.LENGTH_LONG).show();
  }
 };
///////Y AHORA DENTRO DEL ONCLICK DEL CHECKBOX, LLAMAR A LA FUNCION  
onTwitterClick();
&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
Con esto debería funcionar, según se ejecuta el main, pulsamos sobre el checkbox y como resultado nos dará un dialog en el que se ha incrustado el webView, y un par de dialogs mas,además de haber personalizado la cabecera, ahí es donde tenemos que introducir nuestras credenciales.&lt;br /&gt;
&lt;br /&gt;
&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/AVvXsEipnY4CEVJh0xnibqWjm5UZl3R1rS4dWYb88ecdDeLtF64dwwXqHUF0L8ZMpjWHlNhYypPDQfTduNri5pBYOV3dc932E39j2AJY6kwMbhii25uVaWhw67jZSwwJA8c0opDBmmZolbZW8oTR/s1600/screenshot1.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/AVvXsEipnY4CEVJh0xnibqWjm5UZl3R1rS4dWYb88ecdDeLtF64dwwXqHUF0L8ZMpjWHlNhYypPDQfTduNri5pBYOV3dc932E39j2AJY6kwMbhii25uVaWhw67jZSwwJA8c0opDBmmZolbZW8oTR/s1600/screenshot1.png&quot; height=&quot;268&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&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/AVvXsEiRmvPE9lKlmuhz7hdrNcZUYv3762DOH_c3KcF2oQJ8kiunNAj-qPqaArkG2hZ3VEigf1S7j97M0uqOEbz699ZxhAz0YV5Aq3uZBq0Gs4oZdWw_H9bwSMsDYjQE9XxMmbB95fsxR5Akc6NZ/s1600/screenshot2.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/AVvXsEiRmvPE9lKlmuhz7hdrNcZUYv3762DOH_c3KcF2oQJ8kiunNAj-qPqaArkG2hZ3VEigf1S7j97M0uqOEbz699ZxhAz0YV5Aq3uZBq0Gs4oZdWw_H9bwSMsDYjQE9XxMmbB95fsxR5Akc6NZ/s1600/screenshot2.png&quot; height=&quot;271&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&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/AVvXsEhwkYygGmzu-34iE7vriRSizolAHCx2ZvjqTARUcFZq1uEm4q-0qtXhcdNsQHabn2HAcg65SpHwdjHie082R_kQ_R58-2g4aW2AZzrhWBuQLta7cemovbJ7acseWcDAXW8ryY9-1WF6wN4G/s1600/screenshot3.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/AVvXsEhwkYygGmzu-34iE7vriRSizolAHCx2ZvjqTARUcFZq1uEm4q-0qtXhcdNsQHabn2HAcg65SpHwdjHie082R_kQ_R58-2g4aW2AZzrhWBuQLta7cemovbJ7acseWcDAXW8ryY9-1WF6wN4G/s1600/screenshot3.png&quot; height=&quot;271&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&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/AVvXsEgbnd3kBr26V6xdtCoPMIF_Dbe3qycIMczkuxhTjpR1tn-Wjt-rk41_h6UkbKxJbsAu4ko6NfRg5KXizRV579PW6Hp6D87BxH4XGnXzwKr5G8uJuu55cLy1ZkPajXzIpTL4FFOYXBBcT500/s1600/screenshot4.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/AVvXsEgbnd3kBr26V6xdtCoPMIF_Dbe3qycIMczkuxhTjpR1tn-Wjt-rk41_h6UkbKxJbsAu4ko6NfRg5KXizRV579PW6Hp6D87BxH4XGnXzwKr5G8uJuu55cLy1ZkPajXzIpTL4FFOYXBBcT500/s1600/screenshot4.png&quot; height=&quot;270&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Y si no hay problemas de conexión, este es el resultado :&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&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/AVvXsEggxCbGctry-uezB09lEseO9ZIJS7seBBqE4YvrDkBFKBbybfG0HUQgVDE33uVfiLH0rR8Lj5XJWV1xQQCe-fZEKfqep_qLViK3HZNMftlxnJCvke1ntGl01GY-LBm51ZDiaVr7BqGQROYK/s1600/screenshot5.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/AVvXsEggxCbGctry-uezB09lEseO9ZIJS7seBBqE4YvrDkBFKBbybfG0HUQgVDE33uVfiLH0rR8Lj5XJWV1xQQCe-fZEKfqep_qLViK3HZNMftlxnJCvke1ntGl01GY-LBm51ZDiaVr7BqGQROYK/s1600/screenshot5.png&quot; height=&quot;271&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Bien, lo bueno de que se manejen preferencias, es que ahora si nos salimos de la aplicación y volvemos a entrar, abrá que repetir todo el proceso de autentificación, aunque los datos personales de la cuenta ya están almacenados, entonces hay que optimizar eso, aprobechando el hilo del onCreate después de las instancias al botón y los checkbox, ponemos una condición :&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush:java&quot;&gt; //SI HAY CONEXION SE PULSA EL CHECKBOX
  if (mTwitter.estasConectado()) {
   registerCheck.setChecked(true);
   
   String username = mTwitter.getUsername();
   username= (username.equals(&quot;&quot;)) ? &quot;Unknown&quot; : username;
   //Se actualiza el estado con el nombre
   registerCheck.setText(&quot;  Twitter (&quot; + username + &quot;)&quot;);
   registerCheck.setTextColor(Color.WHITE);
   
  }else{
   onTwitterClick();
  }
&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Así, si ejecutas el proyecto otra vez, saltas el paso de las credenciales y se autentifica automáticamente&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
Sólo si están guardadas con anterioridad. Por supuesto como en el propio twitter, al quitar el check, te va a preguntar si quieres desconectar, que a efectos prácticos es como el cerrar sesión del twitter normal, se borran las preferencias y listo.

&lt;br /&gt;
&lt;br /&gt;
&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/AVvXsEgMPkOAPewWXh1e7oYnebPdhKV-cyk2U5NTgyyCTZFXDqUajJiMIVXOON8iJTVi-lBzC2wYj6tkehzl-KwN5UpjT51Vm603gRnoDO3fEJsnvrfTuJ5ODGxkOkvD30zAyEIw1inJ6lfG9aTI/s1600/screenshot6.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/AVvXsEgMPkOAPewWXh1e7oYnebPdhKV-cyk2U5NTgyyCTZFXDqUajJiMIVXOON8iJTVi-lBzC2wYj6tkehzl-KwN5UpjT51Vm603gRnoDO3fEJsnvrfTuJ5ODGxkOkvD30zAyEIw1inJ6lfG9aTI/s1600/screenshot6.png&quot; height=&quot;270&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Como hemos tocado el código varias veces de la actividad principal, lo pongo entero para que no haya lugar a dudas :
&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush:java&quot;&gt;public class MainActivity extends  Activity {
 private TwitterApp mTwitter;
 private CheckBox mTwitterBtn;

 
 @Override
 public void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_main);

  //INICIAMOS VARIABLES
  mTwitter = new TwitterApp(this, twitter_consumer_key,twitter_secret_key);
  mTwitter.setListener(mTwLoginDialogListener);
  //Checkbox para conectar A TWITTER
  mTwitterBtn = (CheckBox) findViewById(R.id.twitterCheck);
  mTwitterBtn.setOnClickListener(new OnClickListener() {
   @Override
   public void onClick(View v) {
    onTwitterClick();
   }
  });
  //AÑADI LAS LINEAS A UNA FUNCIÓN  
  ConectarPorDefecto()
  
  Button goBtn = (Button) findViewById(R.id.button1);
  goBtn.setOnClickListener(new OnClickListener() {
   @Override
   public void onClick(View v) {
    startActivity(new Intent(MainActivity.this, TestPost.class));
   }
  });
 }
     private void ConectarPorDefecto(){
     //SI HAY CONEXION SE PULSA EL CHECKBOX
  if (mTwitter.estasConectado()) {
   registerCheck.setChecked(true);
   
   String username = mTwitter.getUsername();
   username= (username.equals(&quot;&quot;)) ? &quot;Unknown&quot; : username;
   //Se actualiza el estado con el nombre
   registerCheck.setText(&quot;  Twitter (&quot; + username + &quot;)&quot;);
   registerCheck.setTextColor(Color.WHITE);
   
  }else{
   onTwitterClick();
  }
    }
 
 
 
 private void onTwitterClick() {
  //SI YA ESTAS CONECTADO A TWITTER
  if (mTwitter.estasConectado()) {
   final AlertDialog.Builder builder = new AlertDialog.Builder(this);
   //MESAJE CON LA CONFIRMACION DE LA DESCONEXION
   builder.setMessage(&quot;Delete current Twitter connection?&quot;)
          .setCancelable(false)
          .setPositiveButton(&quot;Yes&quot;, new DialogInterface.OnClickListener() {
              @SuppressLint(&quot;ResourceAsColor&quot;) 
              public void onClick(DialogInterface dialog, int id) {
               mTwitter.resetAccessToken();
               
               //ACTUALIZAMOS CHECKBOX
               mTwitterBtn.setChecked(false);
               mTwitterBtn.setText(&quot; Not connected &quot;);
               mTwitterBtn.setTextColor(R.color.colorTweet);
              }
          })
          //EN EL CASO DE QUE SE PULSE NO, VOLVEMOS A LA PRIMERA PANTALLA
          .setNegativeButton(&quot;No&quot;, new DialogInterface.OnClickListener() {
              public void onClick(DialogInterface dialog, int id) {
                   dialog.cancel();
                   
                   mTwitterBtn.setChecked(true);
              }
          });
   final AlertDialog alert = builder.create();
   
   alert.show();
   //SINO ESTAS CONECTADO MANDAMOS A AUTHORIZE, DONDE APARECE
   //PARA ENVIAR LAS CREDENCIALES DE AUTENTIFICACION
  } else {
   mTwitterBtn.setChecked(false);
   //Cargamos loading... mas credenciales de twitter
   mTwitter.authorize();
  }
 }

 private final TwDialogListener mTwLoginDialogListener = new TwDialogListener() {
  @Override
  public void onComplete(String value) {
   String username = mTwitter.getUsername();
   username  = (username.equals(&quot;&quot;)) ? &quot;No Name&quot; : username;
  
   mTwitterBtn.setText(&quot;  Conectado como  (&quot; + username + &quot;)&quot;);
   mTwitterBtn.setChecked(true);
   mTwitterBtn.setTextColor(Color.WHITE);
   Toast.makeText(MainActivity.this, &quot;Connected to Twitter as &quot; + username, Toast.LENGTH_LONG).show();
   startActivity(new Intent(MainActivity.this, TestPost.class));
  }
  
  @Override
  public void onError(String value) {
   mTwitterBtn.setChecked(false);
   
   Toast.makeText(MainActivity.this, &quot;Twitter connection failed&quot;, Toast.LENGTH_LONG).show();
  }
 };
}
&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: x-large;&quot;&gt;&lt;span style=&quot;color: #a5130f;&quot;&gt;&lt;b&gt;3. Validar nuestro Tweet a enviar&amp;nbsp;&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Vamos ya a lo que es, escribir el&lt;span style=&quot;color: #a5130f;&quot;&gt;&lt;b&gt; tweet&lt;/b&gt;&lt;/span&gt;. Tenemos que meter una etiqueta en el &lt;b&gt;inputText&lt;/b&gt; para asegurarnos que si se quiere twittear, siempre se marque la etiqueta, y por otra parte en nuestro &lt;b&gt;TextView&lt;/b&gt;, el que tiene la funcionalidad de contar los caracteres, para validar el tweet, ya que no puede estar a 0 o pasarse de 140 caracteres en total.&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
El conteo de los caracteres es regresivo, es decir, no empieza en 0, sino en 140 y se va restando el numero de caracteres que cuando sea inferior a 0, tomará un color rojo.
En nuestro onCreate, al final del todo :

&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Y en el onclick del botón azul de enviartweet :&lt;/span&gt;&amp;nbsp;
&lt;span style=&quot;font-size: large;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush:java&quot;&gt; tweet.addTextChangedListener(new TextWatcher() {
   int caracteres=0;
   @SuppressLint(&quot;ResourceAsColor&quot;) @Override
   public void onTextChanged(CharSequence s, int start, int before, int count) {
    caracteres=140-(tweet.getText().length() );
    Ncaracteres.setText(String.valueOf(caracteres));
    if(caracteres &amp;lt; 0){
    Ncaracteres.setTextColor(Ncaracteres.getContext().getResources().getColor(R.color.RojoError));
    }else{         Ncaracteres.setTextColor(Ncaracteres.getContext().getResources().getColor(R.color.colorTwitter));   
    }
   }
   @Override
   public void beforeTextChanged(CharSequence s, int start, int count,
     int after) {
    // TODO Auto-generated method stub
   }
   @Override
   public void afterTextChanged(Editable s) {
    // TODO Auto-generated method stub 
   }
  });
&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Añadimos en nuestra función instanciarElementos :
&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush:java&quot;&gt;     // YA METO TEXTO EN EL INPUTTEXT
        tweet.setText(&quot; #thebestandroide&quot;);
        //APAREZCA EL NUMERO CARACTERES POR DEFECTO
        Ncaracteres.setText(String.valueOf(140-(tweet.getText().length()) ) );

&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Y en el onclick del botón azul de enviartweet :
&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush:java&quot;&gt;    if(validarTweet(String.valueOf(tweet.getText()))){
     Toast.makeText(MainActivity.this, &quot;Hasta dentro!&quot;,Toast.LENGTH_SHORT).show();
    }else{
     Toast.makeText(MainActivity.this, &quot;Tweet incorrecto&quot;,Toast.LENGTH_SHORT).show();
     }
&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
Si quereis ver más claro el tema de contar caracteres de un EditText, podeis verlo en este antiguo &lt;a href=&quot;http://thebestandroide.blogspot.com.es/2014/03/contar-caracteres-inputtext-en-un.html&quot; target=&quot;_blank&quot;&gt;&lt;span style=&quot;color: #a5130f; font-size: small;&quot;&gt;&lt;b&gt;post&lt;/b&gt;&lt;/span&gt;&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;
&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/AVvXsEgo-ZpCJI3OjprG0adZ-sJp8W8KsrmhlmIR_DbkoF8G-IcnPnDupEHPnJIbDiXDix_iepWlvRbJwSHSF3PShFsY39DTXCrhWK7bBgRjmivn3ng2bf8nYH0-K6qJbp4uk8pPuWAc1hGmrM6b/s1600/conn.gif&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/AVvXsEgo-ZpCJI3OjprG0adZ-sJp8W8KsrmhlmIR_DbkoF8G-IcnPnDupEHPnJIbDiXDix_iepWlvRbJwSHSF3PShFsY39DTXCrhWK7bBgRjmivn3ng2bf8nYH0-K6qJbp4uk8pPuWAc1hGmrM6b/s1600/conn.gif&quot; height=&quot;225&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: x-large;&quot;&gt;&lt;span style=&quot;color: #a5130f;&quot;&gt;&lt;b&gt;4. Posteando un tweet&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Ya sólo nos queda conectarnos y enviar el&amp;nbsp; &lt;span style=&quot;color: #a5130f;&quot;&gt;&lt;b&gt;tweet&lt;/b&gt;&lt;/span&gt;, ya que aunque tengamos la session abierta, hace falta conectar con Twitter para enviar el Tweet. Está misión la lleva a cabo el método &lt;b&gt;authorize()&lt;/b&gt; de la clase &lt;b&gt;TwitterApp&lt;/b&gt;.&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
Ya que esta todo dispuesto, he cambiado &lt;u&gt;uno de los checkbox por un textview&lt;/u&gt; porque así es más sencillo, pongo la clase main entera para que no haya lugar a dudas :
&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush:java&quot;&gt;public class MainActivity extends Activity {
 //CLAVES
 private static final String twitter_consumer_key = &quot;tu_consumer_key&quot;;
 private static final String twitter_secret_key = &quot;tu__secret_key&quot;;

 //Elementos
 private CheckBox registerCheck;
 private ListView lista;
 private Button BotonEnviarTweet;
 private EditText tweet;
 private TextView Ncaracteres;
 private TextView Conectado;
 
 //VARIABLES 
 private TwitterApp mTwitter;
 
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        //INSTANCIAMOS ELEMENTOS
        instanciarElementos();
      //INICIAMOS VARIABLES
       mTwitter = new TwitterApp(this, twitter_consumer_key,twitter_secret_key);
       mTwitter.setListener(mTwLoginDialogListener);
       
       
        //BOTON PARA ENVIAR TWEETS
        BotonEnviarTweet.setOnClickListener(new OnClickListener(){
   @Override
   public void onClick(View v) {
    // TODO Auto-generated method stub
    if(validarTweet(String.valueOf(tweet.getText()))){
     if (mTwitter.estasConectado()){
      Twittear(String.valueOf(tweet.getText()));
     }else{
      mTwitter.authorize();
      Conectado.setText(&quot; Conectando...&quot;);
      Toast.makeText(MainActivity.this, &quot;Estamos conectando, por favor reenvie!&quot;,Toast.LENGTH_SHORT).show();
      
     }
    
    }else{
     Toast.makeText(MainActivity.this, &quot;Tweet incorrecto&quot;,Toast.LENGTH_SHORT).show();
     }
   }
        });
        //CHECKBOX CONECTAR
        registerCheck.setOnClickListener(new OnClickListener() {
   @Override
   public void onClick(View v) {
    onTwitterClick();
   }
  });
        tweet.addTextChangedListener(new TextWatcher() {
   int caracteres=0;
   @SuppressLint(&quot;ResourceAsColor&quot;)
   @Override
   public void onTextChanged(CharSequence s, int start, int before, int count) {
    caracteres=140-(tweet.getText().length() );
    Ncaracteres.setText(String.valueOf(caracteres));
    if(caracteres &amp;lt; 0){
     Ncaracteres.setTextColor(Ncaracteres.getContext().getResources().getColor(R.color.RojoError));

    }else{
     Ncaracteres.setTextColor(Ncaracteres.getContext().getResources().getColor(R.color.colorTwitter));   
    }
   }
   @Override
   public void beforeTextChanged(CharSequence s, int start, int count,
     int after) {
    // TODO Auto-generated method stub
   }
   @Override
   public void afterTextChanged(Editable s) {
    // TODO Auto-generated method stub 
   }
  });
  //CONECTAMOS POR DEFECTO
        ConectarPorDefecto();
    }
   private boolean validarTweet(String tweet){
    if(tweet.length()&amp;gt;140){
     return false;
    }else if(tweet.compareTo(&quot;&quot;)==0){
     return false;
    }else{
     return true;
    }

   }
    private void ConectarPorDefecto(){
     //SI HAY CONEXION SE PULSA EL CHECKBOX
  if (mTwitter.estasConectado()) {
   registerCheck.setChecked(true);
   
   String username = mTwitter.getUsername();
   username= (username.equals(&quot;&quot;)) ? &quot;Unknown&quot; : username;
   //Se actualiza el estado con el nombre
   registerCheck.setText(&quot;  Twitter (&quot; + username + &quot;)&quot;);
   
   
  }else{
   onTwitterClick();
  }
    }
    //FUNCION QUE HACE UN HILO PARA CONECTAR CON TWITTER Y POSTEAR EL TWEET
 private void Twittear(final String review) {
  new Thread() {
   @Override
   public void run() {
    int what = 0;
    
    try {
     mTwitter.updateStatus(review);
    } catch (Exception e) {
     what = 1;
     Log.e(&quot;Error Tweet NO Enviado!! excepcion&quot;+e, &quot;FAIL&quot;);
    }
    mHandler.sendMessage(mHandler.obtainMessage(what));
   }
  }.start();
 }
 //HANDLER QUE RECOGE EL MENSAJE
 private Handler mHandler = new Handler() {
   @Override
   public void handleMessage(Message msg) {
    String text = (msg.what == 0) ? &quot;Posted to Twitter&quot; : &quot;Post to Twitter failed&quot;;
    Toast.makeText(MainActivity.this, text, Toast.LENGTH_SHORT).show();
   }
  };
    //CONEXION A TWITTER
    private void onTwitterClick() {
  //SI YA ESTAS CONECTADO A TWITTER
  if (mTwitter.estasConectado()) {
   final AlertDialog.Builder builder = new AlertDialog.Builder(this);
   //MESAJE CON LA CONFIRMACION DE LA DESCONEXION
   builder.setMessage(&quot;Delete Twitter Session?&quot;)
          .setCancelable(false)
          .setPositiveButton(&quot;Yes&quot;, new DialogInterface.OnClickListener() {
              @SuppressLint(&quot;ResourceAsColor&quot;) 
              public void onClick(DialogInterface dialog, int id) {
               mTwitter.resetAccessToken();
               
               //ACTUALIZAMOS CHECKBOX
               registerCheck.setChecked(false);
               registerCheck.setText(&quot; Not connected &quot;);
               registerCheck.setTextColor(R.color.colorTweet);
              }
          })
          //EN EL CASO DE QUE SE PULSE NO, VOLVEMOS A LA PRIMERA PANTALLA
          .setNegativeButton(&quot;No&quot;, new DialogInterface.OnClickListener() {
              public void onClick(DialogInterface dialog, int id) {
                   dialog.cancel();
                   registerCheck.setChecked(true);
              }
          });
   final AlertDialog alert = builder.create();
   
   alert.show();
   //SINO ESTAS CONECTADO MANDAMOS A AUTHORIZE, DONDE APARECE
   //PARA ENVIAR LAS CREDENCIALES DE AUTENTIFICACION
  } else {
   registerCheck.setChecked(false);
   //Cargamos loading... mas credenciales de twitter
   mTwitter.authorize();
  }
 }

 @SuppressLint(&quot;ResourceAsColor&quot;) 
 private final TwDialogListener mTwLoginDialogListener = new TwDialogListener() {
  @Override
  public void onComplete(String value) {
   //YA CONECTADO PIDE EL NOMBRE A LA RESPUESTA HTTP
   String username = mTwitter.getUsername();
   username= (username.equals(&quot;&quot;)) ? &quot;No Name&quot; : username;
   
   Conectado.setText(&quot; &quot;+username);
   registerCheck.setText(&quot; Conectado&quot;);
   registerCheck.setChecked(true);
   registerCheck.setTextColor(R.color.colorTweet);
   Toast.makeText(MainActivity.this, &quot;Connected to Twitter as &quot; + username, Toast.LENGTH_LONG).show();
   //startActivity(new Intent(MainActivity.this, TestPost.class));
  }
  
  @Override
  public void onError(String value) {
   
   registerCheck.setChecked(false);
   Toast.makeText(MainActivity.this, &quot;Twitter connection failed&quot;, Toast.LENGTH_LONG).show();
  }
 };
 
 
    public void instanciarElementos(){
     //Elementos
     registerCheck = (CheckBox) findViewById(R.id.twitterCheckConnection);
     lista  =  (ListView) findViewById(R.id.listViewTweets);
     BotonEnviarTweet = (Button) findViewById(R.id.enviarTweet);
     tweet =  (EditText) findViewById(R.id.tweet);
     Ncaracteres =(TextView) findViewById(R.id.contarCaracteresTwitter);
     Conectado =(TextView) findViewById(R.id.conectado);
  Conectado.setText(&quot; No user&quot;);
     // YA METO TEXTO EN EL INPUTTEXT
        tweet.setText(&quot; @BestAndroide&quot;);
        //APAREZCA EL NUMERO CARACTERES POR DEFECTO
        Ncaracteres.setText(String.valueOf(140-(tweet.getText().length()) ) );
        
    }
}
&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Aquí vemos el resultado :&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
Para conectarte con las credenciales :&lt;br /&gt;
&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/AVvXsEgo-ZpCJI3OjprG0adZ-sJp8W8KsrmhlmIR_DbkoF8G-IcnPnDupEHPnJIbDiXDix_iepWlvRbJwSHSF3PShFsY39DTXCrhWK7bBgRjmivn3ng2bf8nYH0-K6qJbp4uk8pPuWAc1hGmrM6b/s1600/conn.gif&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/AVvXsEgo-ZpCJI3OjprG0adZ-sJp8W8KsrmhlmIR_DbkoF8G-IcnPnDupEHPnJIbDiXDix_iepWlvRbJwSHSF3PShFsY39DTXCrhWK7bBgRjmivn3ng2bf8nYH0-K6qJbp4uk8pPuWAc1hGmrM6b/s1600/conn.gif&quot; height=&quot;225&quot; width=&quot;400&quot; /&gt;&amp;nbsp;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
Para escribir un tweet :&lt;/div&gt;
&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/AVvXsEgRgj0lxW_BH91qBLfBz_GVAeXvZGd5e848sXz0mYLggwOfuft1iXbILefOZjqRlhZb6y1PKg69nkIITamzbHLL9Q6a2Gi3tr8-LHSpmYzLQndlGfMIHEz3qLtuBqBMeA8K9NLBD8JyyVIX/s1600/ttit.gif&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/AVvXsEgRgj0lxW_BH91qBLfBz_GVAeXvZGd5e848sXz0mYLggwOfuft1iXbILefOZjqRlhZb6y1PKg69nkIITamzbHLL9Q6a2Gi3tr8-LHSpmYzLQndlGfMIHEz3qLtuBqBMeA8K9NLBD8JyyVIX/s1600/ttit.gif&quot; height=&quot;225&quot; width=&quot;400&quot; /&gt;&amp;nbsp;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Y si entramos de nuevo, no se nos demandará que ingresemos las credenciales si hemos dejado la session abierta, de lo contrario sí.
&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
Podeis descargar el código fuente de thebestandroide con sólo compartir en facebook,twitter,linkedin o suscribirte a nuestro canal RSS más abajo.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;script language=&quot;JavaScript&quot;&gt;
function muestra_oculta(id,tipo){
 var resultado=tipo
 var dir = document.location.href;
 var tit = document.title;
 var tit2 = encodeURIComponent(tit);
 var url =&quot;&quot;;
if(resultado==1){
 var url =&quot;http://www.facebook.com/share.php?u=&quot;+dir+&quot;&amp;t=&quot;+tit2
 window.open(url, &#39;TheBestAndroide&#39;);
}
if(resultado==2){
  var url =&quot;http://twitter.com/home?status=Estoy en &quot;+dir+&quot; leyendo &quot;+tit2
  window.open(url, &#39;TheBestAndroide&#39;);
}
if(resultado==3){
 var url =&quot;http://www.linkedin.com/shareArticle?mini=true&amp;url=&quot;+dir+&quot;&amp;title=&quot;+tit2+&quot;&amp;source=http://thebestandroide.blogspot.com.es/&quot;;
  window.open(url, &#39;TheBestAndroide&#39;);
}
if(resultado==4){
  var url =&quot;http://feeds.feedburner.com/Thebestandroide&quot;
  window.open(url, &#39;TheBestAndroide&#39;);
}

if (document.getElementById){ //se obtiene el id
var el = document.getElementById(id); //se define la variable &quot;el&quot; igual a nuestro div
el.style.display = (el.style.display == &#39;none&#39;) ? &#39;block&#39; : &#39;none&#39;; //damos un atributo display:none que oculta el div
}
}
window.onload = function(){/*hace que se cargue la función lo que predetermina que div estará oculto hasta llamar a la función nuevamente*/
muestra_oculta(&#39;contenido_a_mostrar&#39;);/* &quot;contenido_a_mostrar&quot; es el nombre que le dimos al DIV */
}
&lt;/script&gt;

&lt;br /&gt;
&lt;table style=&quot;width: 260px;&quot;&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;img alt=&quot;Compartir&quot; border=&quot;0&quot; height=&quot;50&quot; onclick=&quot;muestra_oculta(&#39;contenido_a_mostrar&#39;,1)&quot; onmouseout=&quot;this.src=&#39;https://dl.dropboxusercontent.com/u/28565502/images/redface.png&#39;;&quot; onmouseover=&quot;this.src=&#39;https://dl.dropboxusercontent.com/u/28565502/images/redfacehover.png&#39;;&quot; src=&quot;https://dl.dropboxusercontent.com/u/28565502/images/redface.png&quot; style=&quot;margin-right: 10px;&quot; width=&quot;50&quot; /&gt;

&lt;img alt=&quot;Compartir&quot; border=&quot;0&quot; height=&quot;50&quot; onclick=&quot;muestra_oculta(&#39;contenido_a_mostrar&#39;,2)&quot; onmouseout=&quot;this.src=&#39;https://dl.dropboxusercontent.com/u/28565502/images/twitterRed.png&#39;;&quot; onmouseover=&quot;this.src=&#39;https://dl.dropboxusercontent.com/u/28565502/images/twitterRedhover.png&#39;;&quot; src=&quot;https://dl.dropboxusercontent.com/u/28565502/images/twitterRed.png&quot; style=&quot;margin-right: 10px;&quot; width=&quot;50&quot; /&gt;

&lt;img alt=&quot;Compartir&quot; border=&quot;0&quot; height=&quot;50&quot; onclick=&quot;muestra_oculta(&#39;contenido_a_mostrar&#39;,3)&quot; onmouseout=&quot;this.src=&#39;https://dl.dropboxusercontent.com/u/28565502/images/LinkedIn-Logo.png&#39;;&quot; onmouseover=&quot;this.src=&#39;https://dl.dropboxusercontent.com/u/28565502/images/LinkedIn-Logohover.png&#39;;&quot; src=&quot;https://dl.dropboxusercontent.com/u/28565502/images/LinkedIn-Logo.png&quot; style=&quot;margin-right: 10px;&quot; width=&quot;50&quot; /&gt;

&lt;img alt=&quot;Compartir&quot; border=&quot;0&quot; height=&quot;50&quot; onclick=&quot;muestra_oculta(&#39;contenido_a_mostrar&#39;,4)&quot; onmouseout=&quot;this.src=&#39;https://dl.dropboxusercontent.com/u/28565502/images/rss.png&#39;;&quot; onmouseover=&quot;this.src=&#39;https://dl.dropboxusercontent.com/u/28565502/images/rsshover.png&#39;;&quot; src=&quot;https://dl.dropboxusercontent.com/u/28565502/images/rss.png&quot; style=&quot;margin-right: 10px;&quot; width=&quot;50&quot; /&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br /&gt;
&lt;div id=&quot;contenido_a_mostrar&quot;&gt;
&lt;a href=&quot;https://dl.dropbox.com/s/l0cg2uuzhyl91ky/TwitterMakone.rar?dl=0&quot; target=&quot;_blank&quot;&gt;Descargar archivo&lt;/a&gt;.
&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;</description><link>http://thebestandroide.blogspot.com/2014/11/mi-aplicacion-android-con-twitter.html</link><author>noreply@blogger.com (David)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgAvhqHHaBJun4bekd7ts6UvGeSbZtc-84VFofmsJJ5p-6dRDTvoRWS-9RfQccjNi3EFfK1gLXrj1_aiW5AndlloQtbNhUAnabVvBTz4e6m7wL4yVvRPI5HZmqu1Byc1Ec8eLTnAuLHbRnE/s72-c/cabecera2.jpg" height="72" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-1686662779713559896.post-5552393654130222021</guid><pubDate>Wed, 05 Nov 2014 13:35:00 +0000</pubDate><atom:updated>2014-11-07T17:45:44.661+00:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">android feed twitter</category><category domain="http://www.blogger.com/atom/ns#">android twitter</category><category domain="http://www.blogger.com/atom/ns#">android twitter feed</category><category domain="http://www.blogger.com/atom/ns#">android twitter lector etiquetas</category><category domain="http://www.blogger.com/atom/ns#">aplicación Android Twitter</category><category domain="http://www.blogger.com/atom/ns#">feed twitter android</category><category domain="http://www.blogger.com/atom/ns#">twitter feed etiqueta</category><title>Mi aplicación Android con Twitter : Feed de twitter</title><description>&lt;a href=&quot;http://thebestandroide.blogspot.com.es/&quot;&gt;&lt;span style=&quot;color: #a5130f;&quot;&gt;Blog &lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #a5130f;&quot;&gt;&lt;a href=&quot;http://thebestandroide.blogspot.com.es/2014/10/comunicacion-con-servidores-en.html&quot;&gt; &amp;gt;&lt;span style=&quot;color: black;&quot;&gt;Comunicación con servidor &amp;gt;&lt;/span&gt;&lt;/a&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #a5130f;&quot;&gt;&lt;a href=&quot;http://thebestandroide.blogspot.com.es/2014/06/android-rotar-imageview-xml.html&quot;&gt;&lt;b&gt;Feed de Tweets en Android&lt;/b&gt;&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;
&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/AVvXsEjAWNFkEJ5NK5Vf7Asu0JFLyWD6u_lTk2ujE_5YC-EW8rskqYkq1YTLdx7m-r9EtGWybS8jIyJWs7m5RVXZqKVAyKCjmYhE_oWhyTY-vILqbzJSotodRnZiTOO8P25G2_edrfl66P1OuUqV/s1600/Twitter_Android.jpeg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;br /&gt;&lt;/a&gt;&lt;/div&gt;
&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/AVvXsEga2lcmMFNdP7hUhY3JJm09wqzEbj8RHq-vJJr5OwggzCxzjE9tGjZ5Z_e6dD7ihJrz7-bidotd2ygVwTOe73VsocYtAZwfjvIr-Wbk1pFyigXmIOOGoNsgpKNc4uJKRFqG_Y5XE__ei2Uh/s1600/asdf.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/AVvXsEga2lcmMFNdP7hUhY3JJm09wqzEbj8RHq-vJJr5OwggzCxzjE9tGjZ5Z_e6dD7ihJrz7-bidotd2ygVwTOe73VsocYtAZwfjvIr-Wbk1pFyigXmIOOGoNsgpKNc4uJKRFqG_Y5XE__ei2Uh/s1600/asdf.png&quot; height=&quot;296&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Continuamos con el post numero dos de la sección &lt;span style=&quot;color: #a5130f;&quot;&gt;&lt;b&gt;Mi Aplicación Android con Twiter&lt;/b&gt; &lt;/span&gt;, en este caso tenemos aquí un feed de twitt´s con la palabra que introduzcamos en nuestra aplicación.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: #a5130f; font-size: x-large;&quot;&gt;&lt;b&gt;Mi aplicación Android con twitter :&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #a5130f; font-size: x-large;&quot;&gt;&lt;b&gt;Feed de una etiqueta.&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Twitter es uno de esos servicios, con diferentes APIs para acceder a los tweets y los distintos apartados de su plataforma.
Vamos a capturar la entrada del usuario y crear el URL para su uso en una solicitud HTTP a la URL de búsqueda de Twitter :
&lt;/span&gt;&lt;br /&gt;
&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/AVvXsEguwrkP5348G1QvfzN_unQDJ7oBxi18c12BsjtVt08nTxSt8zkGZviQaRh1YhmRYaLli_uKNI2x0Cf-Jg0vIMr1Ctx_57eoM-bg6isdxMCx-OgCBd2-2WG0RUAu1LYPQOwu5Q1e1_qVHTst/s1600/twitter-for-android1.jpg&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/AVvXsEguwrkP5348G1QvfzN_unQDJ7oBxi18c12BsjtVt08nTxSt8zkGZviQaRh1YhmRYaLli_uKNI2x0Cf-Jg0vIMr1Ctx_57eoM-bg6isdxMCx-OgCBd2-2WG0RUAu1LYPQOwu5Q1e1_qVHTst/s1600/twitter-for-android1.jpg&quot; height=&quot;264&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
Antes de seguir, he de decir que me ha costado bastante sacar este código, no todo es mío, he de agradecer la aportación de varios colegas en &lt;a href=&quot;https://github.com/&quot; target=&quot;_blank&quot;&gt;&lt;b&gt;Gilthub&lt;/b&gt;&lt;/a&gt;, que no tenía mucha fé en esta plataforma pero resulta super útil.&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;El tratamiento es complicadillo y se requiere tiempo para estudiar el código, sino se tienen conocimientos&lt;u&gt; avanzados de Java&lt;/u&gt;, será imposible tratar el código de manera correcta.También hay que decir que antes de estar liado con esto,hay que saber si se tienen las claves de autentificación en Twitter,&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;¿Cómo las conseguimos?&lt;span style=&quot;color: #a5130f;&quot;&gt;&lt;span style=&quot;font-size: x-large;&quot;&gt;&lt;b&gt;&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #a5130f; font-size: x-large;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;a href=&quot;http://thebestandroide.blogspot.com.es/2014/11/crear-aplicacion-twitter-para-android.html&quot; target=&quot;_blank&quot;&gt;Aquí&lt;/a&gt;&lt;/span&gt;&lt;/span&gt;&lt;b&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;.&lt;/span&gt;&lt;/span&gt; &lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Voy a comentar brevemente la función de la aplicación :&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Nosotros tenemos un EditText donde introduciremos la etiqueta que queremos buscar, y al darle al botón realizará las operaciones necesarias para poder conectarnos a &lt;b&gt;Twitter&lt;/b&gt; con nuestras &lt;b&gt;CUSTOM_KEY&lt;/b&gt; y &lt;b&gt;SECRET_KEY&lt;/b&gt;, una vez autentificados, tendremos los privilegios necesarios para poder listar los tweets mediante un objeto JSON de una determinada etiqueta.&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
Antes de nada hay que descargarse bastantes librerías, importarlas al proyecto y parsearlas al mismo mediante &lt;b&gt;Java Build Path&lt;/b&gt; (botón derecho sobre el proyecto, propiedades). Estas librerías son las que necesitamos para usar JSON y otras para interactuar con el framework de Twitter. Destaco que estoy en la version Android 5.&lt;br /&gt;
&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;https://dl.dropbox.com/s/2wb8zbw7fjl8dlj/gson-2.3.jar?dl=0&quot; target=&quot;_blank&quot;&gt;gson-2.3.jarhttpclient-4.0.1.jar&lt;/a&gt;&amp;nbsp;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://dl.dropbox.com/s/87xtzdeov3969nc/jackson-core-2.3.0.jar?dl=0&quot; target=&quot;_blank&quot;&gt;jackson-core-2.3.0.jar&lt;/a&gt;&amp;nbsp;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://dl.dropbox.com/s/kxam8ya62j1de5p/json_simple-1.1.jar?dl=0&quot; target=&quot;_blank&quot;&gt;json_simpe-1.1.jar&lt;/a&gt;&amp;nbsp;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://dl.dropbox.com/s/e6yzw08ylwb8828/json-smart-1.1.1.jar?dl=0&quot; target=&quot;_blank&quot;&gt;json-smart-1.1.1.jar&amp;nbsp;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://dl.dropbox.com/s/r6jiwavz48z6q8k/twitter4j-core-4.0.2.jar?dl=0&quot; target=&quot;_blank&quot;&gt;twitter4j-core-4.0.2.jar&lt;/a&gt;&amp;nbsp;&lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;
Las he comprimido en un .rar y las podeis descargar desde &lt;a href=&quot;https://www.dropbox.com/s/cxupyhoadsc8l56/librerias.rar?dl=0&quot; target=&quot;_blank&quot;&gt;aquí&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;
DESCARGAR LIBRERIAS PARA JSON DESDE &lt;a href=&quot;http://search.maven.org/#artifactdetails%7Ccom.google.code.gson%7Cgson%7C2.3%7Cjar&quot; target=&quot;_blank&quot;&gt;AQUI&lt;/a&gt;&amp;nbsp; Y &lt;a href=&quot;https://code.google.com/p/ksoap2-android/&quot; target=&quot;_blank&quot;&gt;AQUI&lt;/a&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&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/AVvXsEiRoCp3YvdksLVrBLyhKVcZ9791QjKOglnZxVH0DWoKw7ySysHAFCGA1jvEEuRlePTVSLEj8kd9V7b3OXJuJl28VHx4KR28M4ktzZR_UIQVEJtu9fjCdoza9b2oon6gpHAFjIiGJOA4E5ZH/s1600/feed.gif&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/AVvXsEiRoCp3YvdksLVrBLyhKVcZ9791QjKOglnZxVH0DWoKw7ySysHAFCGA1jvEEuRlePTVSLEj8kd9V7b3OXJuJl28VHx4KR28M4ktzZR_UIQVEJtu9fjCdoza9b2oon6gpHAFjIiGJOA4E5ZH/s1600/feed.gif&quot; height=&quot;320&quot; width=&quot;292&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
También hay que dar permisos de Internet a la aplicación.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush:java&quot;&gt;    &amp;lt;uses-permission android:name=&quot;android.permission.INTERNET&quot;/&amp;gt;
    &amp;lt;uses-permission android:name=&quot;android.permission.ACCESS_NETWORK_STATE&quot;/&amp;gt;  &lt;uses-permission android:name=&quot;android.permission.INTERNET&quot;&gt;&amp;nbsp;&lt;/uses-permission&gt;&lt;/pre&gt;
&lt;br /&gt;
&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/AVvXsEiMXaziE-3MUACYuIBnQC1wnMl_NSJhT2JbyKZ_UzJMGGqoGEM429aiKCYmukn_UXoW6ze3WxCpMOBjgyJx5Zm9jC1ztr2K4gNpw8lRD30D8bLisXN4dmMuv9WOl6XlQ0e4-xYmNfWQilJK/s1600/screenshot1.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/AVvXsEiMXaziE-3MUACYuIBnQC1wnMl_NSJhT2JbyKZ_UzJMGGqoGEM429aiKCYmukn_UXoW6ze3WxCpMOBjgyJx5Zm9jC1ztr2K4gNpw8lRD30D8bLisXN4dmMuv9WOl6XlQ0e4-xYmNfWQilJK/s1600/screenshot1.png&quot; height=&quot;286&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;relativelayout android:layout_height=&quot;match_parent&quot; android:layout_width=&quot;match_parent&quot; tools:context=&quot;com.example.tweetfeed.MainActivity&quot; xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot; xmlns:tools=&quot;http://schemas.android.com/tools&quot;&gt;&lt;linearlayout android:layout_height=&quot;wrap_content&quot; android:layout_width=&quot;fill_parent&quot; android:orientation=&quot;vertical&quot;&gt;&lt;textview android:id=&quot;@+id/intro_txt&quot; android:layout_gravity=&quot;center&quot; android:layout_height=&quot;wrap_content&quot; android:layout_width=&quot;wrap_content&quot; android:text=&quot;Twitter search term&quot; android:textsize=&quot;20sp&quot; android:textstyle=&quot;italic&quot;&gt;&lt;edittext android:background=&quot;#ffff66&quot; android:hint=&quot;Search...&quot; android:id=&quot;@+id/search_edit&quot; android:inputtype=&quot;text&quot; android:layout_height=&quot;wrap_content&quot; android:layout_margin=&quot;5dp&quot; android:layout_width=&quot;fill_parent&quot; android:padding=&quot;10dp&quot;&gt;&lt;/edittext&gt;&lt;/textview&gt;&lt;/linearlayout&gt;&lt;/relativelayout&gt; &amp;lt;RelativeLayout xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; xmlns:tools=&quot;http://schemas.android.com/tools&quot;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; android:layout_width=&quot;match_parent&quot;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; android:layout_height=&quot;match_parent&quot;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; tools:context=&quot;com.example.tweetfeed.MainActivity&quot; &amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;LinearLayout&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:layout_width=&quot;fill_parent&quot;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:layout_height=&quot;wrap_content&quot;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:orientation=&quot;vertical&quot; &amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;TextView&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:id=&quot;@+id/intro_txt&quot;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:layout_width=&quot;wrap_content&quot;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:layout_height=&quot;wrap_content&quot;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:layout_gravity=&quot;center&quot;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:text=&quot;Twitter search term&quot;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:textSize=&quot;20sp&quot;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:textStyle=&quot;italic&quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;EditText&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:id=&quot;@+id/search_edit&quot;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:layout_width=&quot;fill_parent&quot;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:layout_height=&quot;wrap_content&quot;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:layout_margin=&quot;5dp&quot;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:background=&quot;#ffff66&quot;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:hint=&quot;Search...&quot;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:inputType=&quot;text&quot;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:padding=&quot;10dp&quot; &amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;requestFocus /&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/EditText&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;Button&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:id=&quot;@+id/busqueda&quot;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:layout_width=&quot;wrap_content&quot;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:layout_height=&quot;wrap_content&quot;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:layout_gravity=&quot;center&quot;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:layout_margin=&quot;5dp&quot;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:onClick=&quot;searchTwitter&quot;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:text=&quot;Buscar&quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;ListView&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:id=&quot;@+id/list&quot;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:layout_width=&quot;wrap_content&quot;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:layout_height=&quot;wrap_content&quot; &amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/ListView&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/LinearLayout&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/RelativeLayout&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Y de momento en el onCreate() hacemos referencia a los objetos como de costumbre :
&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush:java&quot;&gt; public void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_main);
  act = this;
  listalist = (ListView) findViewById(R.id.list);

      palabra = (EditText) findViewById(R.id.search_edit);
         buscar= (Button) findViewById(R.id.busqueda);
         buscar.setOnClickListener(new OnClickListener(){
    @Override
    public void onClick(View v) {

     TERMINO=palabra.getText().toString();
     LISTA = new ArrayList&lt;tweet&gt;();
    }
         });
 }
&lt;/tweet&gt;&lt;/pre&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Si ejecutamos el proyecto veremos que no ocurre nada, ya que ahora vamos a implementar una serie de clases necesarias para lograr nuestro objetivo : &lt;b&gt;Un feed de tweets.&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
También agregamos otros recursos, como el item_twitter para la apariencia de cada tweet :
En la carpeta drawable :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&amp;gt;&lt;br /&gt;
&amp;lt;shape xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;!-- color de fondo --&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;solid android:color=&quot;#ffffff&quot;/&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;!-- curvatura esquinas&amp;nbsp; --&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;corners android:radius=&quot;10dp&quot;/&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;!-- padding para separar entre elementos contenidos y el borde --&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;padding android:left=&quot;8dp&quot;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; android:right=&quot;8dp&quot;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; android:top=&quot;4dp&quot;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; android:bottom=&quot;8dp&quot;/&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;!-- borde --&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;stroke&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; android:width=&quot;3dp&quot;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; android:color=&quot;@color/colorTwitter&quot;/&amp;gt;&lt;br /&gt;
&amp;lt;/shape&amp;gt; &lt;br /&gt;
&lt;br /&gt;
Y en la carpeta layout, la fila que insertaremos con datos distintos :&lt;br /&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;http://schemas.android.com/apk/res/android&quot;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; android:layout_width=&quot;fill_parent&quot;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; android:layout_height=&quot;wrap_content&quot;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; android:background=&quot;@drawable/cuadrotwitter&quot;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; android:orientation=&quot;vertical&quot; &amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;LinearLayout&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:id=&quot;@+id/contenedorTwitter&quot;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:layout_width=&quot;match_parent&quot;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:layout_height=&quot;wrap_content&quot;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:background=&quot;#ffffff&quot; &amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;ImageView&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:id=&quot;@+id/JSONAvatar&quot;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:layout_width=&quot;wrap_content&quot;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:layout_height=&quot;wrap_content&quot;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:layout_margin=&quot;5dp&quot;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:src=&quot;@drawable/ic_launcher&quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;LinearLayout&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:layout_width=&quot;fill_parent&quot;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:layout_height=&quot;wrap_content&quot;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:layout_margin=&quot;5dp&quot;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:orientation=&quot;vertical&quot; &amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;TextView&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:id=&quot;@+id/JSONusertwitter&quot;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:layout_width=&quot;wrap_content&quot;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:layout_height=&quot;wrap_content&quot;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:text=&quot;User&quot;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:textColor=&quot;@color/colorTwitter&quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;TextView&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:id=&quot;@+id/JSONTweet&quot;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:layout_width=&quot;wrap_content&quot;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:layout_height=&quot;wrap_content&quot;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:text=&quot;tweet&quot;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:textAppearance=&quot;?android:attr/textAppearanceMedium&quot;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:textColor=&quot;@color/colorTweet&quot; /&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/LinearLayout&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/LinearLayout&amp;gt;&lt;br /&gt;
&amp;lt;/LinearLayout&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;b&gt;TwitterUser&lt;/b&gt; : Clase con parámetros identicos a los que nos dan, complementa a la siguiente clase &lt;b&gt;Tweet&lt;/b&gt;, que toma también parámetros de twitter, lo que pasa que esta última se centra un poco más en parámetros del sistema, a diferencia con la anterior, que está definida para los parámetros de cada usuario.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush:java&quot;&gt;public class TwitterUser {

 @SerializedName(&quot;screen_name&quot;)
 private String screenName;
 
 @SerializedName(&quot;name&quot;)
 private String name;
 
 @SerializedName(&quot;profile_image_url&quot;)
 private String profileImageUrl;

 public String getProfileImageUrl() {
  return profileImageUrl;
 }

 public String getScreenName() {
  return screenName;
 }

 public void setProfileImageUrl(String profileImageUrl) {
  this.profileImageUrl = profileImageUrl;
 }

 public void setScreenName(String screenName) {
  this.screenName = screenName;
 }

 public String getName() {
  return name;
 }

 public void setName(String name) {
  this.name = name;
 }
}

public class Tweet {

 @SerializedName(&quot;created_at&quot;)
 private String DateCreated;

 @SerializedName(&quot;id&quot;)
 private String Id;

 @SerializedName(&quot;text&quot;)
 private String Text;

 @SerializedName(&quot;in_reply_to_status_id&quot;)
 private String InReplyToStatusId;

 @SerializedName(&quot;in_reply_to_user_id&quot;)
 private String InReplyToUserId;

 @SerializedName(&quot;in_reply_to_screen_name&quot;)
 private String InReplyToScreenName;

 @SerializedName(&quot;user&quot;)
 private TwitterUser User;

 public String getDateCreated() {
  return DateCreated;
 }
 
 public String getId() {
  return Id;
 }

 public String getInReplyToScreenName() {
  return InReplyToScreenName;
 }

 public String getInReplyToStatusId() {
  return InReplyToStatusId;
 }

 public String getInReplyToUserId() {
  return InReplyToUserId;
 }

 public String getText() {
  return Text;
 }

 public void setDateCreated(String dateCreated) {
  DateCreated = dateCreated;
 }

 public void setId(String id) {
  Id = id;
 }

 public void setInReplyToScreenName(String inReplyToScreenName) {
  InReplyToScreenName = inReplyToScreenName;
 }
 
 public void setInReplyToStatusId(String inReplyToStatusId) {
  InReplyToStatusId = inReplyToStatusId;
 }
 
 public void setInReplyToUserId(String inReplyToUserId) {
  InReplyToUserId = inReplyToUserId;
 }
 
 public void setText(String text) {
  Text = text;
 }

 public void setUser(TwitterUser user) {
  User = user;
 }

 public TwitterUser getUser() {
  return User;
 }

 @Override
 public String  toString(){
  return getText();
 }
}

&lt;/pre&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;b&gt;Clase Twitter&lt;/b&gt; : Esta clase nos sirve de apoyo para recoger los valores que nos va a devolver el objeto JSON
&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush:java&quot;&gt;public class Twitter extends ArrayList&lt;tweet&gt; {
 private static final long serialVersionUID = 1L;
}
&lt;/tweet&gt;&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;b&gt;Clase Authenticated :&lt;/b&gt; Es la que nos va guardar las variables de conexión necesarias para twitter :
&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush:java&quot;&gt;public class Authenticated {
 String token_type;
 String access_token;
}
&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Vamos ahora con el tema &quot;complicadillo&quot;; A partir de la versión 3 de Android, las operaciones como recoger datos desde internet, se consideran operaciones costosas, entonces Android dió por echo que necesitábamos hacer uso de otro hilo, para que la aplicación no se quedase colgada.&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;He echo este programa con 3 formas de hilos, uno para &lt;b&gt;autentificarnos en Twitter y parsear mediante JSON los datos&lt;/b&gt;, otro para &lt;b&gt;insertarlos en el ListView&lt;/b&gt; y otro en el propio adapter para que mediante la URL del avatar de twitter, &lt;b&gt;se descarguen las fotos y se muestren&lt;/b&gt;.&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Se puede hacer sin el hilo para insertar los datos en el adapter, pero lo he puesto para ser más técnico :
&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&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/AVvXsEh6qZLRJ-otmjdBOeH0tCNFYBKSYJajDycAMMBX2rAtKk59cO-FbtakJdDpb4-K3afl5Z8IJWssZ7zmWZNa6XWYrWEYkzgI54q6tqvRX6CBLa7qvpEj4HMmukJJMmoG515UcGLVxg8LUDpl/s1600/ESQUEMA.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/AVvXsEh6qZLRJ-otmjdBOeH0tCNFYBKSYJajDycAMMBX2rAtKk59cO-FbtakJdDpb4-K3afl5Z8IJWssZ7zmWZNa6XWYrWEYkzgI54q6tqvRX6CBLa7qvpEj4HMmukJJMmoG515UcGLVxg8LUDpl/s1600/ESQUEMA.png&quot; height=&quot;297&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush:java&quot;&gt;//FUNCION QUE ENCAPSULA TODOS LOS DATOS Y SE LLAMA EN EL ONCLICK DEL BOTÓN QUE ANTERIORMENTE HEMOS PUESTO EN EL onCreate()
 public void downloadTweets() {
  ConnectivityManager connMgr = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
  NetworkInfo networkInfo = connMgr.getActiveNetworkInfo();
  
  if (networkInfo != null &amp;amp;&amp;amp; networkInfo.isConnected()) {
   new DownloadTwitterTask(act).execute(TERMINO);
  } else {
   Log.v(LOG_TAG, &quot;No network connection available.&quot;);
  }
 }

//HILO PARA AGREGAR LOS ITEMS AL ADAPTADOR
private class CargarListViewTask extends AsyncTask&lt;void baseadapter=&quot;&quot; void=&quot;&quot;&gt;{
    Activity a;
 
 public CargarListViewTask(Activity a) {
  // TODO Auto-generated constructor stub
  this.a=a;
 }
 protected void onPreExecute() {
        // TODO Auto-generated method stub
        super.onPreExecute();
    }
 @Override
 protected BaseAdapter doInBackground(Void... params) {
  TweetItemAdapter adaptador = new TweetItemAdapter(LISTA,a);
  return adaptador;
 }
 @Override
 protected void onPostExecute(BaseAdapter adaptador) {
  super.onPostExecute(adaptador);
  listalist.setAdapter(adaptador);
        //pDialog.dismiss();
 }
 
 
}
 //Usamos ASINCTASK PARA OBTENER LOS TWETTS
 private class DownloadTwitterTask extends AsyncTask&lt;string string=&quot;&quot; void=&quot;&quot;&gt; {
  final static String CONSUMER_KEY = &quot;AQUI TU CONSUMER_KEY&quot;;
  final static String CONSUMER_SECRET = &quot;AQUI TU CONSUMER_SECRET&quot;;

  final static String TwitterTokenURL = &quot;https://api.twitter.com/oauth2/token&quot;;
  final static String TwitterStreamURL = &quot;https://api.twitter.com/1.1/statuses/user_timeline.json?screen_name=&quot;;
  Activity activity;
  public DownloadTwitterTask(Activity actividad) {
   this.activity=actividad;
  }

  @Override
  protected String doInBackground(String... screenNames) {
   String result = null;
   if (screenNames.length &amp;gt; 0) {
    result = getTwitterStream(screenNames[0]);
   }
   return result;
  }
  // AQUI ES DONDE CONVERTIMOS LOS DATOS DEL JSON EN ARRAYLIST
  @Override
  protected void onPostExecute(String result) {
   Twitter twits = jsonToTwitter(result);
   
   for (Tweet tweet : twits) {
    Log.i(&quot;DATOS&quot;, tweet.getText());
    Tweet NEWtWitt=tweet;
    //INSERTAMOS EN LISTA
    LISTA.add(NEWtWitt);
   }
   System.out.println(&quot;LISTA CONTENIDO, numero tweets : &quot;+LISTA.size());
   new CargarListViewTask(activity).execute();
  }

  // FUNCION DE APOYO QUE CONVIERTE EL STRING ENTERO POR REGISTRO EN DATOS DE UN ARRAYLIST
  private Twitter jsonToTwitter(String result) {
   Twitter twits = null;
   if (result != null &amp;amp;&amp;amp; result.length() &amp;gt; 0) {
    try {
     Gson gson = new Gson();
     twits = gson.fromJson(result, Twitter.class);
    } catch (IllegalStateException ex) {
     // just eat the exception
    }
   }
   return twits;
  }

  // FUNCION DE APOYO QUE CONVIERTE LA AUTENTIFICACION JSON EN AUTENTIFICACION TIPO AUTHENTICATED
  private Authenticated jsonToAuthenticated(String rawAuthorization) {
   Authenticated auth = null;
   if (rawAuthorization != null &amp;amp;&amp;amp; rawAuthorization.length() &amp;gt; 0) {
    try {
     Gson gson = new Gson();
     auth = gson.fromJson(rawAuthorization, Authenticated.class);
    } catch (IllegalStateException ex) {
     // just eat the exception
    }
   }
   return auth;
  }
  //FUNCION DE APOYO QUE HACE UNA PETICION HTTP PARA QUE PUEDA LEER JSON
  private String getResponseBody(HttpRequestBase request) {
   StringBuilder sb = new StringBuilder();
   try {
    DefaultHttpClient httpClient = new DefaultHttpClient(new BasicHttpParams());
    HttpResponse response = httpClient.execute(request);
    int statusCode = response.getStatusLine().getStatusCode();
    String reason = response.getStatusLine().getReasonPhrase();

    if (statusCode == 200) {

     HttpEntity entity = response.getEntity();
     InputStream inputStream = entity.getContent();

     BufferedReader bReader = new BufferedReader(new InputStreamReader(inputStream, &quot;UTF-8&quot;), 8);
     String line = null;
     while ((line = bReader.readLine()) != null) {
      sb.append(line);
     }
    } else {
     sb.append(reason);
    }
   } catch (UnsupportedEncodingException ex) {
   } catch (ClientProtocolException ex1) {
   } catch (IOException ex2) {
   }
   return sb.toString();
  }
 //FUNCION DE APOYO PARA REALIZAR LA PETICION POST CON SU RESPECTIVA AUTENTIFICACION Y DESPUÉS LA GET PARA 
 //OBTENER LOS DATOS EN JSON
  private String getTwitterStream(String screenName) {
   String results = null;

   // CONECTAMOS CON LAS CLAVES
   try {
    String urlApiKey = URLEncoder.encode(CONSUMER_KEY, &quot;UTF-8&quot;);
    String urlApiSecret = URLEncoder.encode(CONSUMER_SECRET, &quot;UTF-8&quot;);
    // COMBINAMOS LAS CLAVES PARA SU USO
    String combined = urlApiKey + &quot;:&quot; + urlApiSecret;
    // Base64 encode the string
    String base64Encoded = Base64.encodeToString(combined.getBytes(), Base64.NO_WRAP);
    //OBTENEMOS EL OBJETO token
    HttpPost httpPost = new HttpPost(TwitterTokenURL);
    httpPost.setHeader(&quot;Authorization&quot;, &quot;Basic &quot; + base64Encoded);
    httpPost.setHeader(&quot;Content-Type&quot;, &quot;application/x-www-form-urlencoded;charset=UTF-8&quot;);
    httpPost.setEntity(new StringEntity(&quot;grant_type=client_credentials&quot;));
    String rawAuthorization = getResponseBody(httpPost);
    Authenticated auth = jsonToAuthenticated(rawAuthorization);
    // Applications should verify that the value associated with the
    // token_type key of the returned object is bearer
    if (auth != null &amp;amp;&amp;amp; auth.token_type.equals(&quot;bearer&quot;)) {
     // NOS AUTENTIFICAMOS Y HACEMOS LA PETICION GET
     HttpGet httpGet = new HttpGet(TwitterStreamURL + screenName);
     // CONSTRUIMOS UN HTTP NORMAL Y LE INSERTAMOS LA AUTORIZACION REQUERIDA POR TWITTER
     httpGet.setHeader(&quot;Authorization&quot;, &quot;Bearer &quot; + auth.access_token);
     httpGet.setHeader(&quot;Content-Type&quot;, &quot;application/json&quot;);
     // update the results with the body of the response
     results = getResponseBody(httpGet);
    }
   } catch (UnsupportedEncodingException ex) {
   } catch (IllegalStateException ex1) {
   }
   return results;
  }
 }
}
&lt;/string&gt;&lt;/void&gt;&lt;/pre&gt;
&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/AVvXsEgdHt8MVwny40GcyihfUqawf5o2fUCsTVhcAnddnhd59VIflthTR8fOh4u-WOnY2J7ZsrbkSkCcaRcZxVsoCfuAgqfNe7L6h6b1quT5VRfsS2311f8GtREotF_-GEOg3fEHwZoRr0DtHZHZ/s1600/intro.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/AVvXsEgdHt8MVwny40GcyihfUqawf5o2fUCsTVhcAnddnhd59VIflthTR8fOh4u-WOnY2J7ZsrbkSkCcaRcZxVsoCfuAgqfNe7L6h6b1quT5VRfsS2311f8GtREotF_-GEOg3fEHwZoRr0DtHZHZ/s1600/intro.png&quot; height=&quot;320&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Ya sólo nos queda el adapter, que es un adapter sencillo, sólo que hemos extendido un hilo para que como anteriormente he comentado cargar las imágenes a través de una URL :&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush:java&quot;&gt;public class TweetItemAdapter extends BaseAdapter {
 
 private ArrayList&lt;tweet&gt; tweets;
 private Activity a;

 public TweetItemAdapter(ArrayList&lt;tweet&gt; tweets,Activity actividad) {
  super();
  this.tweets = tweets;
  this.a=actividad;
 }

 @SuppressLint(&quot;NewApi&quot;) @Override
 public View getView(int position, View convertView, ViewGroup parent) {
  
  View v = convertView;
  if (v == null) {
   LayoutInflater vi = (LayoutInflater)a.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
   v = vi.inflate(R.layout.tweet_item, null);
  }

  Tweet tweet = (Tweet) tweets.get(position);
   
   if (tweet != null) {
    TextView user = (TextView) v.findViewById(R.id.JSONusertwitter);
    TextView mensaje = (TextView) v.findViewById(R.id.JSONTweet);
    ImageView image = (ImageView) v.findViewById(R.id.JSONAvatar);
    
    if (user != null) {
     user.setText(tweet.getUser().getName());
    }
    if(mensaje != null) {
     mensaje.setText(tweet.getText().toString());
    }
    if(image != null) {
     new DownloadImageTask(image).execute(tweet.getUser().getProfileImageUrl());

     
    }
   }

   return v;
 }

 @Override
 public int getCount() {
  // TODO Auto-generated method stub
  return tweets.size();
 }

 @Override
 public Object getItem(int position) {
  // TODO Auto-generated method stub
  return position;
 }

 @Override
 public long getItemId(int position) {
  // TODO Auto-generated method stub
  return 0;
 }
 
class DownloadImageTask extends AsyncTask&lt;string bitmap=&quot;&quot; void=&quot;&quot;&gt; {
  ImageView bmImage;

  public DownloadImageTask(ImageView bmImage) {
   this.bmImage = bmImage;
  }

  @Override
  protected Bitmap doInBackground(String... urls) {
   String urldisplay = urls[0];
   Bitmap mIcon11 = null;
   try {
    InputStream in = new java.net.URL(urldisplay).openStream();
    mIcon11 = BitmapFactory.decodeStream(in);
   } catch (Exception e) {
    Log.e(&quot;Error&quot;, e.getMessage());
    e.printStackTrace();
   }
   return mIcon11;
  }

  @Override
  protected void onPostExecute(Bitmap result) {
   bmImage.setImageBitmap(result);
  }
 }
}
&lt;/string&gt;&lt;/tweet&gt;&lt;/tweet&gt;&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
Y vamos con ello, el resultado lo podreis ver aquí :
&lt;br /&gt;
&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/AVvXsEiRoCp3YvdksLVrBLyhKVcZ9791QjKOglnZxVH0DWoKw7ySysHAFCGA1jvEEuRlePTVSLEj8kd9V7b3OXJuJl28VHx4KR28M4ktzZR_UIQVEJtu9fjCdoza9b2oon6gpHAFjIiGJOA4E5ZH/s1600/feed.gif&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/AVvXsEiRoCp3YvdksLVrBLyhKVcZ9791QjKOglnZxVH0DWoKw7ySysHAFCGA1jvEEuRlePTVSLEj8kd9V7b3OXJuJl28VHx4KR28M4ktzZR_UIQVEJtu9fjCdoza9b2oon6gpHAFjIiGJOA4E5ZH/s1600/feed.gif&quot; height=&quot;320&quot; width=&quot;292&quot; /&gt;&lt;/a&gt;&lt;/div&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/AVvXsEi-BfIXXI_AC1jkqzCRzX-I6YhWXqjXy0vp8xelBfEHnaCGVOsn2VHp8Vtx_n7uf0des1q7YjRZw9kt9YnVvx1nUmzgs0tutiZFSU1XA3eW_pfNrUeZWOiSruiKw98gZgYIF4l5W1HtW5Xh/s1600/TwitterFeed.mp4&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;br /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Podeis descargar el código fuente de thebestandroide con sólo compartir en facebook, twitter, linkedin o suscribirte a nuestro canal RSS más abajo.&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;NOTA : Hay que pasar por el &lt;a href=&quot;http://thebestandroide.blogspot.com.es/2014/11/crear-aplicacion-twitter-para-android.html&quot; target=&quot;_blank&quot;&gt;&lt;b&gt;primer post &lt;/b&gt;&lt;/a&gt;para conseguir las claves.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
 &lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;http://thebestandroide.blogspot.com.es/2014/11/mi-aplicacion-android-con-twitter.html&quot; target=&quot;_blank&quot;&gt;&lt;span style=&quot;font-size: x-large;&quot;&gt;&lt;b&gt;¿Como twittear desde mi aplicación?&lt;/b&gt;&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;script language=&quot;JavaScript&quot;&gt;
function muestra_oculta(id,tipo){
 var resultado=tipo
 var dir = document.location.href;
 var tit = document.title;
 var tit2 = encodeURIComponent(tit);
 var url =&quot;&quot;;
if(resultado==1){
 var url =&quot;http://www.facebook.com/share.php?u=&quot;+dir+&quot;&amp;t=&quot;+tit2
 window.open(url, &#39;TheBestAndroide&#39;);
}
if(resultado==2){
  var url =&quot;http://twitter.com/home?status=Estoy en &quot;+dir+&quot; leyendo &quot;+tit2
  window.open(url, &#39;TheBestAndroide&#39;);
}
if(resultado==3){
 var url =&quot;http://www.linkedin.com/shareArticle?mini=true&amp;url=&quot;+dir+&quot;&amp;title=&quot;+tit2+&quot;&amp;source=http://thebestandroide.blogspot.com.es/&quot;;
  window.open(url, &#39;TheBestAndroide&#39;);
}
if(resultado==4){
  var url =&quot;http://feeds.feedburner.com/Thebestandroide&quot;
  window.open(url, &#39;TheBestAndroide&#39;);
}

if (document.getElementById){ //se obtiene el id
var el = document.getElementById(id); //se define la variable &quot;el&quot; igual a nuestro div
el.style.display = (el.style.display == &#39;none&#39;) ? &#39;block&#39; : &#39;none&#39;; //damos un atributo display:none que oculta el div
}
}
window.onload = function(){/*hace que se cargue la función lo que predetermina que div estará oculto hasta llamar a la función nuevamente*/
muestra_oculta(&#39;contenido_a_mostrar&#39;);/* &quot;contenido_a_mostrar&quot; es el nombre que le dimos al DIV */
}
&lt;/script&gt;

&lt;br /&gt;
&lt;table style=&quot;width: 260px;&quot;&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;img alt=&quot;Compartir&quot; border=&quot;0&quot; height=&quot;50&quot; onclick=&quot;muestra_oculta(&#39;contenido_a_mostrar&#39;,1)&quot; onmouseout=&quot;this.src=&#39;https://dl.dropboxusercontent.com/u/28565502/images/redface.png&#39;;&quot; onmouseover=&quot;this.src=&#39;https://dl.dropboxusercontent.com/u/28565502/images/redfacehover.png&#39;;&quot; src=&quot;https://dl.dropboxusercontent.com/u/28565502/images/redface.png&quot; style=&quot;margin-right: 10px;&quot; width=&quot;50&quot; /&gt;

&lt;img alt=&quot;Compartir&quot; border=&quot;0&quot; height=&quot;50&quot; onclick=&quot;muestra_oculta(&#39;contenido_a_mostrar&#39;,2)&quot; onmouseout=&quot;this.src=&#39;https://dl.dropboxusercontent.com/u/28565502/images/twitterRed.png&#39;;&quot; onmouseover=&quot;this.src=&#39;https://dl.dropboxusercontent.com/u/28565502/images/twitterRedhover.png&#39;;&quot; src=&quot;https://dl.dropboxusercontent.com/u/28565502/images/twitterRed.png&quot; style=&quot;margin-right: 10px;&quot; width=&quot;50&quot; /&gt;

&lt;img alt=&quot;Compartir&quot; border=&quot;0&quot; height=&quot;50&quot; onclick=&quot;muestra_oculta(&#39;contenido_a_mostrar&#39;,3)&quot; onmouseout=&quot;this.src=&#39;https://dl.dropboxusercontent.com/u/28565502/images/LinkedIn-Logo.png&#39;;&quot; onmouseover=&quot;this.src=&#39;https://dl.dropboxusercontent.com/u/28565502/images/LinkedIn-Logohover.png&#39;;&quot; src=&quot;https://dl.dropboxusercontent.com/u/28565502/images/LinkedIn-Logo.png&quot; style=&quot;margin-right: 10px;&quot; width=&quot;50&quot; /&gt;

&lt;img alt=&quot;Compartir&quot; border=&quot;0&quot; height=&quot;50&quot; onclick=&quot;muestra_oculta(&#39;contenido_a_mostrar&#39;,4)&quot; onmouseout=&quot;this.src=&#39;https://dl.dropboxusercontent.com/u/28565502/images/rss.png&#39;;&quot; onmouseover=&quot;this.src=&#39;https://dl.dropboxusercontent.com/u/28565502/images/rsshover.png&#39;;&quot; src=&quot;https://dl.dropboxusercontent.com/u/28565502/images/rss.png&quot; style=&quot;margin-right: 10px;&quot; width=&quot;50&quot; /&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br /&gt;
&lt;div id=&quot;contenido_a_mostrar&quot;&gt;
&lt;a href=&quot;https://dl.dropbox.com/s/z1wm677okn27ox4/TwitterUltimateFeed.rar?dl=0&quot; target=&quot;_blank&quot;&gt;Descargar archivo&lt;/a&gt;.
&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;</description><link>http://thebestandroide.blogspot.com/2014/11/mi-aplicacion-android-con-twitter-feed.html</link><author>noreply@blogger.com (David)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEga2lcmMFNdP7hUhY3JJm09wqzEbj8RHq-vJJr5OwggzCxzjE9tGjZ5Z_e6dD7ihJrz7-bidotd2ygVwTOe73VsocYtAZwfjvIr-Wbk1pFyigXmIOOGoNsgpKNc4uJKRFqG_Y5XE__ei2Uh/s72-c/asdf.png" height="72" width="72"/><thr:total>2</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-1686662779713559896.post-913982719816952324</guid><pubDate>Wed, 05 Nov 2014 11:19:00 +0000</pubDate><atom:updated>2014-11-07T17:44:38.318+00:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">android twitter application</category><category domain="http://www.blogger.com/atom/ns#">crear aplicacion twitter android</category><category domain="http://www.blogger.com/atom/ns#">enlazar twitter android</category><title>Mi aplicación Android con twitter : Crear aplicación</title><description>&lt;a href=&quot;http://thebestandroide.blogspot.com.es/&quot;&gt;&lt;span style=&quot;color: #a5130f;&quot;&gt;Blog &lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #a5130f;&quot;&gt;&lt;a href=&quot;http://thebestandroide.blogspot.com.es/2014/10/comunicacion-con-servidores-en.html&quot;&gt; &lt;span style=&quot;color: black;&quot;&gt;&amp;gt; Comunicación con servidor &amp;gt;&lt;/span&gt;&lt;/a&gt; &lt;/span&gt;&lt;span style=&quot;color: #a5130f;&quot;&gt;&lt;b&gt;Crear App Twitter para Android&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&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/AVvXsEgMphTcFu6QsqeFGvUzW1XFxxhTQ5C-7VqBkUixr55o-wYNzdVM6HwSU_ayWYqlQ4G-l_FTzoiH-i1eX8L_vdGRbX_VlSeL_Tyj_dYO57aYcJmxJ5b-soDvV6LzOG0ZDs04BOzNLE66-qxZ/s1600/twiiter.jpg&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/AVvXsEgMphTcFu6QsqeFGvUzW1XFxxhTQ5C-7VqBkUixr55o-wYNzdVM6HwSU_ayWYqlQ4G-l_FTzoiH-i1eX8L_vdGRbX_VlSeL_Tyj_dYO57aYcJmxJ5b-soDvV6LzOG0ZDs04BOzNLE66-qxZ/s1600/twiiter.jpg&quot; height=&quot;320&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;span style=&quot;font-size: x-large;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;br /&gt;
&lt;span style=&quot;color: #a5130f; font-size: x-large;&quot;&gt;&lt;b&gt;Mi aplicación Android con twitter :&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #a5130f; font-size: x-large;&quot;&gt;&lt;b&gt;Cómo asociar Twitter a aplicación Android&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #a5130f; font-size: x-large;&quot;&gt;&lt;b&gt;&amp;nbsp;&lt;/b&gt;&lt;/span&gt; 
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Buenas developers, en esta ocasión vamos a interactuar con nuestra aplicación Android la red social &lt;b&gt;twitter&lt;/b&gt;.&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
Buscando por la red, hay poquita documentación en castellano, así que voy a ir paso a paso mostrando cómo hacerlo. 
Por esperiencia, he de resaltar la fecha del artículo : Noviembre de 2014 ya que creo que este proceso va a ir modificandose poco a poco hasta llegar al punto de como se implementa el framework de &lt;b&gt;twitter&lt;/b&gt; en X-Code para iPhone es decir, en X-Code se importa el framework, y se hacen dos comprobaciones :&lt;br /&gt;
&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;&lt;b&gt;Si está instalado la aplicación de twitter.
&lt;/b&gt;&lt;/li&gt;
&lt;li&gt;&lt;b&gt;Si está configurada la cuenta de usuario de twitter.
&lt;/b&gt;&lt;/li&gt;
&lt;/ul&gt;
Si se cumplen, ya aparece los campos necesarios para usar&lt;b&gt; Twitter&lt;/b&gt;, aquí anteriormente postee un post que decía cómo se podia hacer en &lt;b&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;a href=&quot;http://thebestandroide.blogspot.com.es/2014/10/ios-ejercicio-22-twitter-facebook-en.html&quot; target=&quot;_blank&quot;&gt;Cocoa Touch&lt;/a&gt;&amp;nbsp;&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
¿Ojala fuese tan sencillo verdad? tiempo al tiempo... Bueno vamos al lio :&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;b&gt;Paso 1 : Crear una aplicación en twitter&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
Necesitamos crear una aplicación en Twitter, el objetivo en bruto es conseguir dos claves que usaremos en la aplicación, una es la &lt;b&gt;secret key&lt;/b&gt; y otra la &lt;b&gt;consumer key&lt;/b&gt;. Todo lo demás aunque es necesario, es &quot;paja&quot;.Bien, comencemos si no la tenemos, por crear una cuenta en twitter, y si la tenemos, ir a aquí: &lt;a href=&quot;https://apps.twitter.com/&quot; target=&quot;_blank&quot;&gt;apps.twitter.com&lt;/a&gt;&lt;br /&gt;
&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/AVvXsEg7LWye_lHdrnGiBxBiPHNFYBIblsJb2b3bgiXhM5bcLsGtUsW_zTD69oHIKf99WuU5MW2JSeLah_U6pz0NG6aRdAOgRQkBIld5jo7keF-H_D_aFulrU3Bbddc_jxa4N_dS02yRg4ditMkU/s1600/screenshot1.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/AVvXsEg7LWye_lHdrnGiBxBiPHNFYBIblsJb2b3bgiXhM5bcLsGtUsW_zTD69oHIKf99WuU5MW2JSeLah_U6pz0NG6aRdAOgRQkBIld5jo7keF-H_D_aFulrU3Bbddc_jxa4N_dS02yRg4ditMkU/s1600/screenshot1.png&quot; height=&quot;312&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&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/AVvXsEhTfNB1YLb-iQXaj-SGXK0zgzLMADyNwCQSGuXewPl0isCRCaqMTabynvEpSeCMFGu12GW2nhhqvmmmj29rUIrALE4ZW2OL06B4jW80idzTSdWXBwfecR13-sQQhAS3iR9n-MiuOv-eDmAg/s1600/screenshot2.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/AVvXsEhTfNB1YLb-iQXaj-SGXK0zgzLMADyNwCQSGuXewPl0isCRCaqMTabynvEpSeCMFGu12GW2nhhqvmmmj29rUIrALE4ZW2OL06B4jW80idzTSdWXBwfecR13-sQQhAS3iR9n-MiuOv-eDmAg/s1600/screenshot2.png&quot; height=&quot;390&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
En esta última pantalla hay tener en cuenta que el nombre deberá ser único. Aceptamos condiciones y seguimos.
&lt;br /&gt;
&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/AVvXsEi0HEUib5IQ2dLgusWIdMFjCqi1smQYlFvX87Q3IauHmjUCuyhfAMyMHVmViIfvovAyg-sTdRy6LM_jwnf8InwTvTpgij62b3xtxyg2U_BUhCfgJ7_RwtTFkRQ48sZBWvRVTBgqO_AjC086/s1600/screenshot3.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/AVvXsEi0HEUib5IQ2dLgusWIdMFjCqi1smQYlFvX87Q3IauHmjUCuyhfAMyMHVmViIfvovAyg-sTdRy6LM_jwnf8InwTvTpgij62b3xtxyg2U_BUhCfgJ7_RwtTFkRQ48sZBWvRVTBgqO_AjC086/s1600/screenshot3.png&quot; height=&quot;358&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Varias consideraciones :&lt;/span&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span style=&quot;font-size: large;&quot;&gt;En la pestaña Permissions, modificar a &lt;b&gt;read &amp;amp; write&lt;/b&gt;, esto es para permitir la publicación de estados. En Settings marcar la casilla &lt;b&gt;Allow this application to be used to Sign in with Twitter&lt;/b&gt;, también podemos modificar el icono de la misma.&lt;/span&gt; &lt;/li&gt;
&lt;/ul&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span style=&quot;font-size: large;&quot;&gt;En &lt;b&gt;Keys and Access Tokens&lt;/b&gt; copiar las dos claves : &lt;b&gt;Consumer key &lt;/b&gt;y &lt;b&gt;Consumer Secret&lt;/b&gt;, que posteriormente utilizaremos
&lt;/span&gt;&lt;/li&gt;
&lt;/ul&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/AVvXsEhhnpRY1PZb9WVuiIe6zUlb3upxW7c7QcaLzY7Nsu9C0U50PmAaQiWtSHEvdQ006raBc9IhSc2DU0Z9od75qqn9zIFLZ9nkfIzIpdh81Shw-RDp-IlnZMbsTW6_kRh41SGEJM2jLdNKHe2k/s1600/Android-Twitter-App.jpg&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/AVvXsEhhnpRY1PZb9WVuiIe6zUlb3upxW7c7QcaLzY7Nsu9C0U50PmAaQiWtSHEvdQ006raBc9IhSc2DU0Z9od75qqn9zIFLZ9nkfIzIpdh81Shw-RDp-IlnZMbsTW6_kRh41SGEJM2jLdNKHe2k/s1600/Android-Twitter-App.jpg&quot; height=&quot;320&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-large;&quot;&gt;Paso 2 : Integración de Twitter con Android&amp;nbsp;&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
Para poder usar el framework de &lt;b&gt;Twitter&lt;/b&gt; en nuestra aplicación, necesimos descargar dos librerías que añadiremos al proyecto :&lt;br /&gt;
&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;&lt;b&gt;&lt;span style=&quot;font-size: large;&quot;&gt;Twitter4j&amp;nbsp;&lt;/span&gt;&lt;/b&gt;&lt;/li&gt;
&lt;li&gt;&lt;b&gt;&lt;span style=&quot;font-size: large;&quot;&gt;oauth-signpost&lt;/span&gt;&lt;/b&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;
Podeis descargarlos desde &lt;a href=&quot;http://twitter4j.org/en/index.html#download&quot; target=&quot;_blank&quot;&gt;aquí&lt;/a&gt; y &lt;a href=&quot;https://code.google.com/p/oauth-signpost/downloads/list&quot; target=&quot;_blank&quot;&gt;aquí&lt;/a&gt;.&lt;br /&gt;
(signpost-core-1.2.1.1.jar, signpost-commonshttp4-1.2.1.1.jar, signpost-jetty6-1.2.1.1.jar)&lt;br /&gt;
&lt;br /&gt;
Y también os he dejado un .rar con todas dentro &lt;a href=&quot;https://dl.dropbox.com/s/tbtzr3w2oog2u3y/librerias.rar?dl=0&quot; target=&quot;_blank&quot;&gt;aquí&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;
Para finalizar este paso, clickamos con el botón derecho en nuestro proyecto -&amp;gt; Java Build Path -&amp;gt; add External JARs y añadimos las librerías a nuestro proyecto.
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Bueno developers, ya tenemos lo necesario para conectarnos a twitter y como más adelante veremos, podremos hacer un Feed de Twitter e incluso Twittear.&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-large;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/b&gt;
&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;http://thebestandroide.blogspot.com.es/2014/11/mi-aplicacion-android-con-twitter-feed.html&quot; target=&quot;_blank&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-size: x-large;&quot;&gt;Feed Twitter&lt;/span&gt;&lt;/b&gt;&lt;/a&gt; &lt;/li&gt;
&lt;/ul&gt;
&lt;b&gt;&lt;span style=&quot;font-size: x-large;&quot;&gt;&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;http://thebestandroide.blogspot.com.es/2014/11/mi-aplicacion-android-con-twitter.html&quot; target=&quot;_blank&quot;&gt;&lt;span style=&quot;font-size: x-large;&quot;&gt;&lt;b&gt;¿Como twittear desde mi aplicación?&lt;/b&gt;&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;script language=&quot;JavaScript&quot;&gt;
function muestra_oculta(id,tipo){
 var resultado=tipo
 var dir = document.location.href;
 var tit = document.title;
 var tit2 = encodeURIComponent(tit);
 var url =&quot;&quot;;
if(resultado==1){
 var url =&quot;http://www.facebook.com/share.php?u=&quot;+dir+&quot;&amp;t=&quot;+tit2
 window.open(url, &#39;TheBestAndroide&#39;);
}
if(resultado==2){
  var url =&quot;http://twitter.com/home?status=Estoy en &quot;+dir+&quot; leyendo &quot;+tit2
  window.open(url, &#39;TheBestAndroide&#39;);
}
if(resultado==3){
 var url =&quot;http://www.linkedin.com/shareArticle?mini=true&amp;url=&quot;+dir+&quot;&amp;title=&quot;+tit2+&quot;&amp;source=http://thebestandroide.blogspot.com.es/&quot;;
  window.open(url, &#39;TheBestAndroide&#39;);
}
if(resultado==4){
  var url =&quot;http://feeds.feedburner.com/Thebestandroide&quot;
  window.open(url, &#39;TheBestAndroide&#39;);
}

if (document.getElementById){ //se obtiene el id
var el = document.getElementById(id); //se define la variable &quot;el&quot; igual a nuestro div
el.style.display = (el.style.display == &#39;none&#39;) ? &#39;block&#39; : &#39;none&#39;; //damos un atributo display:none que oculta el div
}
}
window.onload = function(){/*hace que se cargue la función lo que predetermina que div estará oculto hasta llamar a la función nuevamente*/
muestra_oculta(&#39;contenido_a_mostrar&#39;);/* &quot;contenido_a_mostrar&quot; es el nombre que le dimos al DIV */
}
&lt;/script&gt;

&lt;br /&gt;
&lt;table style=&quot;width: 260px;&quot;&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;img alt=&quot;Compartir&quot; border=&quot;0&quot; height=&quot;50&quot; onclick=&quot;muestra_oculta(&#39;contenido_a_mostrar&#39;,1)&quot; onmouseout=&quot;this.src=&#39;https://dl.dropboxusercontent.com/u/28565502/images/redface.png&#39;;&quot; onmouseover=&quot;this.src=&#39;https://dl.dropboxusercontent.com/u/28565502/images/redfacehover.png&#39;;&quot; src=&quot;https://dl.dropboxusercontent.com/u/28565502/images/redface.png&quot; style=&quot;margin-right: 10px;&quot; width=&quot;50&quot; /&gt;

&lt;img alt=&quot;Compartir&quot; border=&quot;0&quot; height=&quot;50&quot; onclick=&quot;muestra_oculta(&#39;contenido_a_mostrar&#39;,2)&quot; onmouseout=&quot;this.src=&#39;https://dl.dropboxusercontent.com/u/28565502/images/twitterRed.png&#39;;&quot; onmouseover=&quot;this.src=&#39;https://dl.dropboxusercontent.com/u/28565502/images/twitterRedhover.png&#39;;&quot; src=&quot;https://dl.dropboxusercontent.com/u/28565502/images/twitterRed.png&quot; style=&quot;margin-right: 10px;&quot; width=&quot;50&quot; /&gt;

&lt;img alt=&quot;Compartir&quot; border=&quot;0&quot; height=&quot;50&quot; onclick=&quot;muestra_oculta(&#39;contenido_a_mostrar&#39;,3)&quot; onmouseout=&quot;this.src=&#39;https://dl.dropboxusercontent.com/u/28565502/images/LinkedIn-Logo.png&#39;;&quot; onmouseover=&quot;this.src=&#39;https://dl.dropboxusercontent.com/u/28565502/images/LinkedIn-Logohover.png&#39;;&quot; src=&quot;https://dl.dropboxusercontent.com/u/28565502/images/LinkedIn-Logo.png&quot; style=&quot;margin-right: 10px;&quot; width=&quot;50&quot; /&gt;

&lt;img alt=&quot;Compartir&quot; border=&quot;0&quot; height=&quot;50&quot; onclick=&quot;muestra_oculta(&#39;contenido_a_mostrar&#39;,4)&quot; onmouseout=&quot;this.src=&#39;https://dl.dropboxusercontent.com/u/28565502/images/rss.png&#39;;&quot; onmouseover=&quot;this.src=&#39;https://dl.dropboxusercontent.com/u/28565502/images/rsshover.png&#39;;&quot; src=&quot;https://dl.dropboxusercontent.com/u/28565502/images/rss.png&quot; style=&quot;margin-right: 10px;&quot; width=&quot;50&quot; /&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;</description><link>http://thebestandroide.blogspot.com/2014/11/crear-aplicacion-twitter-para-android.html</link><author>noreply@blogger.com (David)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgMphTcFu6QsqeFGvUzW1XFxxhTQ5C-7VqBkUixr55o-wYNzdVM6HwSU_ayWYqlQ4G-l_FTzoiH-i1eX8L_vdGRbX_VlSeL_Tyj_dYO57aYcJmxJ5b-soDvV6LzOG0ZDs04BOzNLE66-qxZ/s72-c/twiiter.jpg" height="72" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-1686662779713559896.post-1282522731274935787</guid><pubDate>Wed, 05 Nov 2014 01:48:00 +0000</pubDate><atom:updated>2014-11-05T10:20:57.677+00:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">android json java</category><category domain="http://www.blogger.com/atom/ns#">crear json android</category><category domain="http://www.blogger.com/atom/ns#">leer json android</category><category domain="http://www.blogger.com/atom/ns#">parsear json android</category><title>Crear y Leer JSON desde Android</title><description>&lt;a href=&quot;http://thebestandroide.blogspot.com.es/&quot;&gt;&lt;span style=&quot;color: #a5130f;&quot;&gt;Blog &lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #a5130f;&quot;&gt;&lt;a href=&quot;http://thebestandroide.blogspot.com.es/2014/10/comunicacion-con-servidores-en.html&quot;&gt; &amp;gt;&lt;span style=&quot;color: black;&quot;&gt;Comunicación con servidor&lt;/span&gt; &amp;gt;&lt;/a&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #a5130f;&quot;&gt;&lt;b&gt;parseando con JSON en Android&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Hola developers, vamos a ver como se parsea un documento JSON en Android.&lt;br /&gt;
&lt;br /&gt;
&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/AVvXsEjfURkLd8hiPcWBKZYkH_evjKLTehhyphenhyphenpugMTVV_u1nbES3rHOUtDQQC_n6lEx1LWjx5b_8bHvtwDpHaxKzVRaadgDQvwL3H84x4lfEKyoJqWWVP1XBuZ0HLvDqbpT1CJDoD16KUwHRBWOls/s1600/screenshot0.jpg&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/AVvXsEjfURkLd8hiPcWBKZYkH_evjKLTehhyphenhyphenpugMTVV_u1nbES3rHOUtDQQC_n6lEx1LWjx5b_8bHvtwDpHaxKzVRaadgDQvwL3H84x4lfEKyoJqWWVP1XBuZ0HLvDqbpT1CJDoD16KUwHRBWOls/s1600/screenshot0.jpg&quot; height=&quot;400&quot; width=&quot;383&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;span style=&quot;color: #a5130f; font-size: x-large;&quot;&gt;&lt;b&gt;JSON EN ANDROID&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;b&gt;JSON&lt;/b&gt; (JavaScript Object Notation) es un formato para intercambiar datos, &lt;b&gt;JSON&lt;/b&gt; los describe con una sintaxis dedicada que se usa para identificarlos y gestionarlos.&lt;b&gt;&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;JSON&lt;/b&gt; es una alternativa a XML,y el fácil uso en javascript ha generado un gran numero de seguidores. 
Una de las mayores ventajas que tiene el uso de &lt;b&gt;JSON&lt;/b&gt; es que puede ser leído por cualquier lenguaje de programación. Así que en resumen, puede ser usado para el intercambio de información entre tecnologías distintas.
&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Según esté realizado el formulario, nos encontraremos con arrays u objetos, y así lo representaremos en el código.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&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/AVvXsEizU0Tez8JHikvEYCNb3evExTsSP7ShCawFcJbzHelg02dFruIPUkDgBTuKA2bONg1IlyGAz_jfVhGd-bVeLg_HwenBiProH3qQ-ulC21hktbbh5OSYU83k_iQ-bkC5jrO1gurV92j9Z3k5/s1600/screenshot21.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/AVvXsEizU0Tez8JHikvEYCNb3evExTsSP7ShCawFcJbzHelg02dFruIPUkDgBTuKA2bONg1IlyGAz_jfVhGd-bVeLg_HwenBiProH3qQ-ulC21hktbbh5OSYU83k_iQ-bkC5jrO1gurV92j9Z3k5/s1600/screenshot21.png&quot; height=&quot;346&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&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/AVvXsEhSzGT5qaZG7whEizFOBJzXmDZHy7eDASpuzesxanKl-zkpDsMsXWmUCdNrT2Xx0pw1J83G8YqM_3RFeK_RdGrBfo4-Q4U5mp7sm4zTp9H61UYqgyc9eIS2hjc9u2-sFsd9WlRX9kRRwfVv/s1600/Untitled.gif&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/AVvXsEhSzGT5qaZG7whEizFOBJzXmDZHy7eDASpuzesxanKl-zkpDsMsXWmUCdNrT2Xx0pw1J83G8YqM_3RFeK_RdGrBfo4-Q4U5mp7sm4zTp9H61UYqgyc9eIS2hjc9u2-sFsd9WlRX9kRRwfVv/s1600/Untitled.gif&quot; height=&quot;400&quot; width=&quot;332&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
Por ejemplo tenemos este código en &lt;b&gt;JSON&lt;/b&gt;, hay herramientas online para la visualización de nuestro archivo JSON y para que se nos ayude con la sintaxis, como por ejemplo &lt;a href=&quot;http://jsonviewer.stack.hu/&quot; target=&quot;_blank&quot;&gt;&lt;span style=&quot;color: #a5130f;&quot;&gt;&lt;b&gt;JSON Viewer&lt;/b&gt;&lt;/span&gt;&lt;/a&gt;
&lt;br /&gt;
&lt;br /&gt;
{&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &quot;Personajes&quot;: [&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &quot;Equipo&quot;: &quot;Elfos&quot;,&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &quot;name&quot;: &quot;Arwen&quot;,&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &quot;Especialidad&quot;:&quot;guerrero&quot;,&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &quot;image&quot;: &quot;http://oi60.tinypic.com/2emoi7n.jpg&quot;,&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &quot;Habilidades&quot;: {&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &quot;Fuerza&quot;: &quot;7&quot;,&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &quot;Espiritu&quot;: &quot;2&quot;,&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &quot;Fortaleza&quot;: &quot;8&quot;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; },&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &quot;Equipo&quot;: &quot;Orcos&quot;,&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &quot;name&quot;: &quot;Arwen&quot;,&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &quot;Especialidad&quot;:&quot;Brujo&quot;,&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &quot;image&quot;: &quot;http://oi59.tinypic.com/2jetzl0.jpg&quot;,&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &quot;Habilidades&quot;: {&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &quot;Fuerza&quot;: &quot;1&quot;,&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &quot;Espiritu&quot;: &quot;10&quot;,&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &quot;Fortaleza&quot;: &quot;5&quot;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; },&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &quot;Equipo&quot;: &quot;Humanos&quot;,&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &quot;name&quot;: &quot;Arwen&quot;,&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &quot;Especialidad&quot;:&quot;Mago&quot;,&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &quot;image&quot;: &quot;http://oi61.tinypic.com/msoyfa.jpg&quot;,&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &quot;Habilidades&quot;: {&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &quot;Fuerza&quot;: &quot;1&quot;,&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &quot;Espiritu&quot;: &quot;9&quot;,&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &quot;Fortaleza&quot;: &quot;3&quot;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;
&amp;nbsp; ]&lt;br /&gt;
} &lt;br /&gt;
&lt;br /&gt;
Este archivo le podeis descargar desde &lt;a href=&quot;https://dl.dropbox.com/s/sjhj5zuxfu87vz5/Archivo.json?dl=0&quot; target=&quot;_blank&quot;&gt;&lt;b&gt;aquí&lt;/b&gt;&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;
Comenzamos por subir el archivo con extension &lt;b&gt;JSON&lt;/b&gt;, en este caso lo llamaremos &quot;Archivo.json&quot;. Para hacer la prueba, lo subí a &lt;a href=&quot;http://www.dropbox.com/&quot; target=&quot;_blank&quot;&gt;&lt;b&gt;dropbox&lt;/b&gt;&lt;/a&gt;, pero no os olvideis de cambiar las 3 www del enlace que conseguireis, por dl para tener el acceso público, de todas formas podreis ver el ejemplo en una de las clases.&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;b&gt;C&lt;/b&gt;omo profesionales que somos, he usado dropbox para el ejemplo, pero los programadores debemos huir literalmente de lo &quot;gratis&quot;, lo que no se paga, tiene una seguridad endeble, entre otras desventajas.&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
También he subido estas imágenes a un servidor gratuito &lt;a href=&quot;http://es.tinypic.com/?t=postupload&quot; target=&quot;_blank&quot;&gt;TinyPic&lt;/a&gt;, quiere decir que podeis usar el mismo archivo&lt;b&gt; JSON&lt;/b&gt; que yo.&lt;br /&gt;
&lt;br /&gt;
IMAGENES
&lt;br /&gt;
Orco&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;http://oi59.tinypic.com/2jetzl0.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;http://oi59.tinypic.com/2jetzl0.jpg&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
Elfo&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;http://oi60.tinypic.com/2emoi7n.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;http://oi60.tinypic.com/2emoi7n.jpg&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
humano&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;http://oi61.tinypic.com/msoyfa.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;http://oi61.tinypic.com/msoyfa.jpg&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
Importamos estas librerías al proyecto para poder usar JSON :&lt;br /&gt;
&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;&lt;b&gt;&lt;a href=&quot;https://dl.dropbox.com/s/gpu5jl5rsdxw48f/gson-1.7.1.jar?dl=0&quot; target=&quot;_blank&quot;&gt;gson-1.7.1.jar&lt;/a&gt;&lt;/b&gt;&lt;/li&gt;
&lt;li&gt;&lt;b&gt;&lt;a href=&quot;https://dl.dropbox.com/s/n09z8ioj8jx33lf/gson-1.7.1-javadoc.jar?dl=0&quot;&gt;gson-1.7.1-javadoc.jar&lt;/a&gt;&lt;/b&gt;&lt;/li&gt;
&lt;li&gt;&lt;b&gt;&lt;a href=&quot;https://dl.dropbox.com/s/rk875il5idiilay/gson-1.7.1-sources.jar?dl=0&quot; target=&quot;_blank&quot;&gt;gson-1.7.1-sources.jar&lt;/a&gt;&lt;/b&gt;&lt;/li&gt;
&lt;li&gt;&lt;b&gt;&lt;a href=&quot;https://dl.dropbox.com/s/3cs4f22zypy7hhs/ksoap2-android-assembly-2.5.8-jar-with-dependencies.jar?dl=0&quot;&gt;ksoap2-android-assembly-22.5.8-jar-with-depencies.jar&lt;/a&gt;&lt;/b&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;
Tendremos que guardar los datos en una clase JavaBeans, así que creamos la correspondiente a nuestro archivo &lt;b&gt;JSON&lt;/b&gt; para trabajar y gestionar los objetos :
&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush:java&quot;&gt;public class Personajes {

 private String nombre;
 private String profesion;
 private String equipo;
 private String Fuerza;
 private String Fortaleza;
 private String Espiritu;
 private String URLimagen;
 public Bitmap imagen;
 


 public Personajes() {
  super();
 }
 
 public String getEquipo() {
  return equipo;
 }
 public void setEquipo(String equipo) {
  this.equipo = equipo;
 }

 public String getNombre() {
  return nombre;
 }
 public void setNombre(String nombre) {
  this.nombre = nombre;
 }
 public String getProfesion() {
  return profesion;
 }
 public void setProfesion(String profesion) {
  this.profesion = profesion;
 }
 
 public String getFuerza() {
  return Fuerza;
 }
 public void setFuerza(String fuerza) {
  Fuerza = fuerza;
 }
 public String getFortaleza() {
  return Fortaleza;
 }
 public void setFortaleza(String fortaleza) {
  Fortaleza = fortaleza;
 }
 public String getEspiritu() {
  return Espiritu;
 }
 public void setEspiritu(String espiritu) {
  Espiritu = espiritu;
 }
 public String getURLimagen() {
  return URLimagen;
 }

 public void setURLimagen(String uRLimagen) {
  URLimagen = uRLimagen;
 }
 public Bitmap getImagen() {
  // TODO Auto-generated method stub
  return imagen;
 }
}
&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
Ahora vamos con el código, pongo a continuación las dos partes del main :&lt;br /&gt;
&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/AVvXsEg5uJ7KBAxWyXvxIlpEfJiJUwZg5mYf5YgEvfA6GU_4n5JD3F7VbgSzYb6lr7gp3HwcuCmk5owWiksojjTgr_aUbwE8YbddsIGPxrQ1WKwJdcfg5RhrS_hW7toxncwBTvgMTFoTw3zC-QIP/s1600/screenshot2.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/AVvXsEg5uJ7KBAxWyXvxIlpEfJiJUwZg5mYf5YgEvfA6GU_4n5JD3F7VbgSzYb6lr7gp3HwcuCmk5owWiksojjTgr_aUbwE8YbddsIGPxrQ1WKwJdcfg5RhrS_hW7toxncwBTvgMTFoTw3zC-QIP/s1600/screenshot2.png&quot; height=&quot;265&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
Y este es el código Java de momento :&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush:java&quot;&gt;public class MainActivity extends Activity {

 private Button buscar;
 private ListView listaa;
 String searchTerm ;
 //SI OS FIJAIS LA URL EMPIEZA POR dl EN VEZ DE www
 String URL = &quot;https://dl.dropbox.com/s/sjhj5zuxfu87vz5/Archivo.json?dl=0&quot;;
 
 Activity a;
 Context context;
 static ArrayList&lt;personajes&gt; lista;
 JSONArray pers;

 @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        lista = new ArrayList&lt;personajes&gt;();
        a=this;
        context=getApplicationContext();
        listaa = (ListView) findViewById(R.id.listViewLista);
        buscar = (Button) findViewById(R.id.busqueda);
        //VEMOS QUE HAY EN EL EDITTEXT
     buscar.setOnClickListener(new OnClickListener(){
   @Override
   public void onClick(View v) {
    // TODO Auto-generated method stub
    //AQUI ES LA EJECUCIÓN DEL PARSEO DEL XML
   }     
     });
     
 }
}

&lt;/personajes&gt;&lt;/personajes&gt;&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;A continuación tenemos el método público que utilizaremos para leer nuestro archivo &lt;b&gt;JSON&lt;/b&gt;. Este método crea la llamada al servicio web. No os olvideis de darle permisos de internet a la aplicación.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush:java&quot;&gt;//CLASE PARA RECOJER EL CODIGO EN BRUTO DEL JSON
public class JSONParser {

   static String response = null;
   public final static int GET = 1;
   public final static int POST = 2;
   //CONSTRUCTOR
   public JSONParser() {
   }
   
   public String makeServiceCall(String url, int method) {
       return this.makeServiceCall(url, method, null);
   }
   //METODO PARA ESTABLECER CONEXIÓN
   public String makeServiceCall(String url, int method,List&lt;namevaluepair&gt; params) {
       try {
           //HTTP CLIENT
           DefaultHttpClient httpClient = new DefaultHttpClient();
           HttpEntity httpEntity = null;
           HttpResponse httpResponse = null;
            
           // AÑADIMOS PARAMETROS AL METODO POST
           if (method == POST) {
               HttpPost httpPost = new HttpPost(url);
               // adding post params
               if (params != null) {
                   httpPost.setEntity(new UrlEncodedFormEntity(params));
               }
               httpResponse = httpClient.execute(httpPost);
           } else if (method == GET) {
               // AÑADIMOS PARAMETROS AL METODO GET
               if (params != null) {
                   String paramString = URLEncodedUtils.format(params, &quot;utf-8&quot;);
                   url += &quot;?&quot; + paramString;
               }
               //METODO GET
               HttpGet httpGet = new HttpGet(url);
               httpResponse = httpClient.execute(httpGet);

           }
           httpEntity = httpResponse.getEntity();
           response = EntityUtils.toString(httpEntity);
           //EXCEPCIONES
       } catch (UnsupportedEncodingException e) {
           e.printStackTrace();
       } catch (ClientProtocolException e) {
           e.printStackTrace();
       } catch (IOException e) {
           e.printStackTrace();
       }
       //DEVOLVEMOS RESPUESTA
        return response;
   }
}
&lt;/namevaluepair&gt;&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
Vamos a completar nuestro main con 2 clases que harán la función de hilos, uno es para cargar los datos del objeto&lt;b&gt; JSON&lt;/b&gt; en un ArrayList y otro es para cargar los datos correspondientes en el ListView, están enlazados y el código está bastante explicado e intuitivo.
&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush:java&quot;&gt;//HILO PARA CARGAR LOS DATOS DEL JSON EN UN ARRAYLIST
class GetContacts extends AsyncTask&lt;void void=&quot;&quot;&gt; {
   ListView list;
        private ProgressDialog pDialog;
     //CONSTRUCTOR
        public GetContacts(ListView listaa) {
   this.list=listaa;
  }
     
  @Override
     protected void onPreExecute() {
             super.onPreExecute();
             pDialog = new ProgressDialog(MainActivity.this);
             pDialog.setMessage(&quot;Getting Data ...&quot;);
             pDialog.setIndeterminate(false);
             pDialog.setCancelable(true);
             pDialog.show();
       }
 
        @Override
        protected Void doInBackground(Void... arg0) {
            // CREAMOS LA INSTANCIA DE LA CLASE
            JSONParser sh = new JSONParser();
            String jsonStr = sh.makeServiceCall(URL, JSONParser.GET);
            
            if (jsonStr != null) {
                try {
                    JSONObject jsonObj = new JSONObject(jsonStr);
                    // Getting JSON Array node
                    pers = jsonObj.getJSONArray(&quot;Personajes&quot;);
 
                    // looping through All Equipos
                    for (int i = 0; i &amp;lt; pers.length(); i++) {
                        JSONObject c = pers.getJSONObject(i);
                        //RECOJEMOS DATOS EN VARIABLES
                        String equipo = c.getString(&quot;Equipo&quot;);
                        String name = c.getString(&quot;name&quot;);
                        String especialidad = c.getString(&quot;Especialidad&quot;);
                        String imagen = c.getString(&quot;image&quot;);
      
                        //SUBITEM CON LAS HABILIDADES
                        JSONObject habilidades = c.getJSONObject(&quot;Habilidades&quot;);
                        String fuerza = habilidades.getString(&quot;Fuerza&quot;);
                        String espiritu = habilidades.getString(&quot;Espiritu&quot;);
                        String fortaleza = habilidades.getString(&quot;Fortaleza&quot;);
 
      //CREAMOS OBJETO Y LO LLENAMOS
                        Personajes e=new Personajes();
                        e.setURLimagen(imagen);
                        e.setNombre(name);
                        e.setEquipo(equipo);
                        e.setProfesion(especialidad);
                        e.setEspiritu(espiritu);
                        e.setFortaleza(fortaleza);
                        e.setFuerza(fuerza);
                        // adding contact to contact list
                        lista.add(e);
                    }
                } catch (JSONException e) {
                    e.printStackTrace();
                }
            } else {
                Log.e(&quot;ServiceHandler&quot;, &quot;Esta habiendo problemas para cargar el JSON&quot;);
            }
 
            return null;
        }
 
        @Override
        protected void onPostExecute(Void result) {
            super.onPostExecute(result);
            // Dismiss the progress dialog
            if (pDialog.isShowing()){
                pDialog.dismiss();
         }
         new CargarListTask().execute();
    }
//HILO PARA CARGAR LOS DATOS EN EL LISTVIEW
class CargarListTask extends AsyncTask&lt;void dapter=&quot;&quot; tring=&quot;&quot;&gt;{
     @Override
     protected void onPreExecute() {
         // TODO Auto-generated method stub
         super.onPreExecute();
     }
     protected Adapter doInBackground(Void... arg0) {
         // TODO Auto-generated method stub
         try{
         }catch(Exception ex){
             ex.printStackTrace();
         }
   
         Adapter adaptador = new Adapter(a,lista);
         return adaptador;
     }
     @Override
     protected void onPostExecute(Adapter result) {
         // TODO Auto-generated method stub
         super.onPostExecute(result);
         listaa.setAdapter(result);
     }
 }
 }

&lt;/void&gt;&lt;/void&gt;&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
Si colocamos cuando clickamos el botón...&lt;br /&gt;
&lt;br /&gt;
new GetContacts(listaa).execute();&lt;br /&gt;
&lt;br /&gt;
Ya está!! sólo necesitamos un adapter con un hilo, este hilo se encargará de llenar la imágen a partir de la URL de la imagen, de esas 3 que he puesto al principio :
&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush:java&quot;&gt;public class Adapter extends BaseAdapter{
   
    protected Activity activity;
    //ARRAYLIST CON TODOS LOS ITEMS
    protected ArrayList&lt;personajes&gt; items;
     
    //CONSTRUCTOR
    public Adapter(Activity activity, ArrayList&lt;personajes&gt; items) {
        this.activity = activity;
        this.items = items;
      }
    //CUENTA LOS ELEMENTOS
    @Override
    public int getCount() {
        return items.size();
    }
    //DEVUELVE UN OBJETO DE UNA DETERMINADA POSICION
    @Override
    public Object getItem(int arg0) {
        return items.get(arg0);
    }

    //METODO PRINCIPAL, AQUI SE LLENAN LOS DATOS
    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        // SE GENERA UN CONVERTVIEW POR MOTIVOS DE EFICIENCIA DE MEMORIA
     //ES UN NIVEL MAS BAJO DE VISTA, PARA QUE OCUPEN MENOS MEMORIA LAS
 
        View v = convertView;
        //ASOCIAMOS LA VISTA AL LAYOUT DEL RECURSO XML DONDE ESTA LA BASE DE
 
       if(convertView == null){
            LayoutInflater inf = (LayoutInflater) activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            v = inf.inflate(R.layout.list_item, null);
        }
  
        Personajes dir = items.get(position);
        //RELLENAMOS LA IMAGEN Y EL TEXTO
        //IMAGEN
        ImageView img = (ImageView) v.findViewById(R.id.imageView1);
  if(img != null) {
   new LoadImage(img).execute(dir.getURLimagen());
  }
        //CAMPOS
        TextView nombre = (TextView) v.findViewById(R.id.username);
        nombre.setText(&quot;NOMBRE : &quot;+dir.getNombre());
        TextView clase = (TextView) v.findViewById(R.id.clase);
        clase.setText(&quot;PROFESION : &quot;+dir.getProfesion());
        TextView equipo = (TextView) v.findViewById(R.id.equipo);
        equipo.setText(&quot;EQUIPO : &quot;+dir.getEquipo());
        TextView fuerza = (TextView) v.findViewById(R.id.fuerza);
        //SUBCAMPOS
        fuerza.setText(&quot;FUERZA : &quot;+dir.getFuerza());
        TextView fortaleza = (TextView) v.findViewById(R.id.fortaleza);
        fortaleza.setText(&quot;FORTALEZA : &quot;+dir.getFortaleza());
        TextView espiritu = (TextView) v.findViewById(R.id.espiritu);
        espiritu.setText(&quot;ESPIRITU : &quot;+dir.getEspiritu());
         
        // DEVOLVEMOS VISTA
        return v;
    }
 @Override
 public long getItemId(int position) {
  // TODO Auto-generated method stub
  return 0;
 }
 
 class LoadImage extends AsyncTask&lt;string bitmap=&quot;&quot; void=&quot;&quot;&gt; {
  ImageView bmImage;

  public LoadImage(ImageView bmImage) {
   this.bmImage = bmImage;
  }

  @Override
  protected Bitmap doInBackground(String... urls) {
   String urldisplay = urls[0];
   Bitmap mIcon11 = null;
   try {
    mIcon11 = BitmapFactory.decodeStream((InputStream)new URL(urldisplay).getContent());
     
   } catch (Exception e) {
    //Log.e(&quot;Error&quot;, e.getMessage());
    e.printStackTrace();
   }
   return mIcon11;
  }

  @Override
  protected void onPostExecute(Bitmap result) {
   bmImage.setImageBitmap(result);
  }
 }
}
&lt;/string&gt;&lt;/personajes&gt;&lt;/personajes&gt;&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
Y por último el item_list.... &lt;br /&gt;
&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/AVvXsEi-kMHw4YtwkzH9vfO5YKa6N75kfJUK35MYMqA3WsxgfxmLulRO5ZG17U_LgXyUcuybT3sBGTy5qwUm_Nhn9tfanCCZiEqEZymrLlpgoQihNkji7MUcGZJhllfZPO3j5HB25Ney4kIeDlKz/s1600/screenshot3.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/AVvXsEi-kMHw4YtwkzH9vfO5YKa6N75kfJUK35MYMqA3WsxgfxmLulRO5ZG17U_LgXyUcuybT3sBGTy5qwUm_Nhn9tfanCCZiEqEZymrLlpgoQihNkji7MUcGZJhllfZPO3j5HB25Ney4kIeDlKz/s1600/screenshot3.png&quot; height=&quot;369&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&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/AVvXsEhSzGT5qaZG7whEizFOBJzXmDZHy7eDASpuzesxanKl-zkpDsMsXWmUCdNrT2Xx0pw1J83G8YqM_3RFeK_RdGrBfo4-Q4U5mp7sm4zTp9H61UYqgyc9eIS2hjc9u2-sFsd9WlRX9kRRwfVv/s1600/Untitled.gif&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/AVvXsEhSzGT5qaZG7whEizFOBJzXmDZHy7eDASpuzesxanKl-zkpDsMsXWmUCdNrT2Xx0pw1J83G8YqM_3RFeK_RdGrBfo4-Q4U5mp7sm4zTp9H61UYqgyc9eIS2hjc9u2-sFsd9WlRX9kRRwfVv/s1600/Untitled.gif&quot; height=&quot;400&quot; width=&quot;332&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Podeis descargar el código fuente de thebestandroide con sólo compartir en facebook,twitter,linkedin o suscribirte a nuestro canal RSS más abajo.&amp;nbsp;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;script language=&quot;JavaScript&quot;&gt;
function muestra_oculta(id,tipo){
 var resultado=tipo
 var dir = document.location.href;
 var tit = document.title;
 var tit2 = encodeURIComponent(tit);
 var url =&quot;&quot;;
if(resultado==1){
 var url =&quot;http://www.facebook.com/share.php?u=&quot;+dir+&quot;&amp;t=&quot;+tit2
 window.open(url, &#39;TheBestAndroide&#39;);
}
if(resultado==2){
  var url =&quot;http://twitter.com/home?status=Estoy en &quot;+dir+&quot; leyendo &quot;+tit2
  window.open(url, &#39;TheBestAndroide&#39;);
}
if(resultado==3){
 var url =&quot;http://www.linkedin.com/shareArticle?mini=true&amp;url=&quot;+dir+&quot;&amp;title=&quot;+tit2+&quot;&amp;source=http://thebestandroide.blogspot.com.es/&quot;;
  window.open(url, &#39;TheBestAndroide&#39;);
}
if(resultado==4){
  var url =&quot;http://feeds.feedburner.com/Thebestandroide&quot;
  window.open(url, &#39;TheBestAndroide&#39;);
}

if (document.getElementById){ //se obtiene el id
var el = document.getElementById(id); //se define la variable &quot;el&quot; igual a nuestro div
el.style.display = (el.style.display == &#39;none&#39;) ? &#39;block&#39; : &#39;none&#39;; //damos un atributo display:none que oculta el div
}
}
window.onload = function(){/*hace que se cargue la función lo que predetermina que div estará oculto hasta llamar a la función nuevamente*/
muestra_oculta(&#39;contenido_a_mostrar&#39;);/* &quot;contenido_a_mostrar&quot; es el nombre que le dimos al DIV */
}
&lt;/script&gt;

&lt;br /&gt;
&lt;table style=&quot;width: 260px;&quot;&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;img alt=&quot;Compartir&quot; border=&quot;0&quot; height=&quot;50&quot; onclick=&quot;muestra_oculta(&#39;contenido_a_mostrar&#39;,1)&quot; onmouseout=&quot;this.src=&#39;https://dl.dropboxusercontent.com/u/28565502/images/redface.png&#39;;&quot; onmouseover=&quot;this.src=&#39;https://dl.dropboxusercontent.com/u/28565502/images/redfacehover.png&#39;;&quot; src=&quot;https://dl.dropboxusercontent.com/u/28565502/images/redface.png&quot; style=&quot;margin-right: 10px;&quot; width=&quot;50&quot; /&gt;

&lt;img alt=&quot;Compartir&quot; border=&quot;0&quot; height=&quot;50&quot; onclick=&quot;muestra_oculta(&#39;contenido_a_mostrar&#39;,2)&quot; onmouseout=&quot;this.src=&#39;https://dl.dropboxusercontent.com/u/28565502/images/twitterRed.png&#39;;&quot; onmouseover=&quot;this.src=&#39;https://dl.dropboxusercontent.com/u/28565502/images/twitterRedhover.png&#39;;&quot; src=&quot;https://dl.dropboxusercontent.com/u/28565502/images/twitterRed.png&quot; style=&quot;margin-right: 10px;&quot; width=&quot;50&quot; /&gt;

&lt;img alt=&quot;Compartir&quot; border=&quot;0&quot; height=&quot;50&quot; onclick=&quot;muestra_oculta(&#39;contenido_a_mostrar&#39;,3)&quot; onmouseout=&quot;this.src=&#39;https://dl.dropboxusercontent.com/u/28565502/images/LinkedIn-Logo.png&#39;;&quot; onmouseover=&quot;this.src=&#39;https://dl.dropboxusercontent.com/u/28565502/images/LinkedIn-Logohover.png&#39;;&quot; src=&quot;https://dl.dropboxusercontent.com/u/28565502/images/LinkedIn-Logo.png&quot; style=&quot;margin-right: 10px;&quot; width=&quot;50&quot; /&gt;

&lt;img alt=&quot;Compartir&quot; border=&quot;0&quot; height=&quot;50&quot; onclick=&quot;muestra_oculta(&#39;contenido_a_mostrar&#39;,4)&quot; onmouseout=&quot;this.src=&#39;https://dl.dropboxusercontent.com/u/28565502/images/rss.png&#39;;&quot; onmouseover=&quot;this.src=&#39;https://dl.dropboxusercontent.com/u/28565502/images/rsshover.png&#39;;&quot; src=&quot;https://dl.dropboxusercontent.com/u/28565502/images/rss.png&quot; style=&quot;margin-right: 10px;&quot; width=&quot;50&quot; /&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br /&gt;
&lt;div id=&quot;contenido_a_mostrar&quot;&gt;
&lt;a href=&quot;https://dl.dropbox.com/s/k36m0yotkx76kf6/LectorJSON.rar?dl=0&quot; target=&quot;_blank&quot;&gt;Descargar archivo&lt;/a&gt;.
&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;</description><link>http://thebestandroide.blogspot.com/2014/11/crear-y-leer-json-desde-android.html</link><author>noreply@blogger.com (David)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjfURkLd8hiPcWBKZYkH_evjKLTehhyphenhyphenpugMTVV_u1nbES3rHOUtDQQC_n6lEx1LWjx5b_8bHvtwDpHaxKzVRaadgDQvwL3H84x4lfEKyoJqWWVP1XBuZ0HLvDqbpT1CJDoD16KUwHRBWOls/s72-c/screenshot0.jpg" height="72" width="72"/><thr:total>34</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-1686662779713559896.post-34894849434073812</guid><pubDate>Mon, 03 Nov 2014 09:58:00 +0000</pubDate><atom:updated>2014-11-03T10:16:21.354+00:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">android drawer menu</category><category domain="http://www.blogger.com/atom/ns#">Android navigation drawer</category><category domain="http://www.blogger.com/atom/ns#">menu fragments</category><category domain="http://www.blogger.com/atom/ns#">navigation drawer  fragment</category><title>Navigation Drawer con DrawerLayout comunicando fragments</title><description>&lt;a href=&quot;http://thebestandroide.blogspot.com.es/&quot;&gt;&lt;span style=&quot;color: #a5130f;&quot;&gt;Blog &lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #a5130f;&quot;&gt;&lt;a href=&quot;http://thebestandroide.blogspot.com/2014/06/lista-soluciones.html&quot;&gt; &amp;gt;Lista Soluciones &amp;gt;&lt;/a&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #a5130f;&quot;&gt;&lt;b&gt;DrawerLayout con fragment &lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Hola amigos desarrolladores!! Después de ver los fragments en este&lt;span style=&quot;color: #a5130f;&quot;&gt;&lt;b&gt; &lt;a href=&quot;http://thebestandroide.blogspot.com.es/2014/11/fragment-en-android.html&quot; target=&quot;_blank&quot;&gt;post&lt;/a&gt;&lt;/b&gt;&lt;/span&gt; anterior, vamos a ver cómo jugar con ellos con un &lt;b&gt;DrawerLayout&lt;/b&gt; además de implementar un ActionBar posteriormente.
&lt;br /&gt;
&lt;span style=&quot;font-size: x-large;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&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/AVvXsEiN6nGVfhoVMr5PfkAh2DJtO8d1BXjM5RZOFtvRm2MrzhODNG0MgB21ex5fecRdEbbd910IOgx7vHzUmkI8MMb-Yd25s3bRXvH5mLnL69DFksU_lRnd92dKHvthcIrTgXn4PDdZsOO9SY8j/s1600/nav.jpg&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/AVvXsEiN6nGVfhoVMr5PfkAh2DJtO8d1BXjM5RZOFtvRm2MrzhODNG0MgB21ex5fecRdEbbd910IOgx7vHzUmkI8MMb-Yd25s3bRXvH5mLnL69DFksU_lRnd92dKHvthcIrTgXn4PDdZsOO9SY8j/s1600/nav.jpg&quot; height=&quot;336&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: #a5130f; font-size: x-large;&quot;&gt;&lt;b&gt;DrawerLayout gestionando fragments &quot;Navigation Drawer&quot;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-large;&quot;&gt; &lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Antes de empezar voy a resaltar que este componente tiene bastantes incopatibilidades según la versión de Android que se use, así que no os desespereis. También hay que tener en cuenta que trabajamos con &lt;b&gt;fragments&lt;/b&gt;, no con &lt;i&gt;Actividades&lt;/i&gt;.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;No es que se complique a la hora de escribir código, hay que enfocarlo de otra forma para para que concuerde de manera adecuada, es decir de forma autocontenida.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;i&gt;El autocontenido se refiere a todo lo que se encuentra en ella dentro sin necesidad de recurrir a contenidos externos como vinculos.&lt;/i&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
De momento nuestro activity_main será así :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;android.support.v4.widget.DrawerLayout&lt;br /&gt;
&amp;nbsp;xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;&lt;br /&gt;
&amp;nbsp;android:id=&quot;@+id/drawer_layout&quot;&lt;br /&gt;
&amp;nbsp;android:layout_width=&quot;match_parent&quot;&lt;br /&gt;
&amp;nbsp;android:layout_height=&quot;match_parent&quot; &amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Contenido principal --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;FrameLayout&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; android:id=&quot;@+id/contenedor_principal&quot;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; android:layout_width=&quot;match_parent&quot;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; android:layout_height=&quot;match_parent&quot;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; android:background=&quot;@android:color/transparent&quot; &amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;lt;/FrameLayout&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Navigation Drawer --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;ListView&lt;br /&gt;
&amp;nbsp;android:id=&quot;@+id/drawer&quot;&lt;br /&gt;
&amp;nbsp;android:layout_width=&quot;240dp&quot;&lt;br /&gt;
&amp;nbsp;android:layout_height=&quot;match_parent&quot;&lt;br /&gt;
&amp;nbsp;android:layout_gravity=&quot;left&quot;&lt;br /&gt;
&amp;nbsp;android:background=&quot;#EEE&quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/android.support.v4.widget.DrawerLayout&amp;gt; &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Analicemoslo bien, el id del &lt;b&gt;Drawer&lt;/b&gt; es super importante, y pensar que tenemos que hacer un listview con adapter para gestionar los fragmentos también tiene su trabajo, poco pero lo tiene, así que vamos a ello :
&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush:java&quot;&gt;public class itemsMenu {

 private String Nombre;
 private String Descripcion;
 private Drawable img;
 private int id;
 
 public itemsMenu(int id,String nombre, String descripcion, Drawable img) {
  super();
  this.id=id;
  this.Nombre = nombre;
  this.Descripcion = descripcion;
  this.img = img;
 }
 public int getId() {
  return id;
 }
 public void setId(int id) {
  this.id = id;
 }
 public String getNombre() {
  return Nombre;
 }
 public void setNombre(String nombre) {
  Nombre = nombre;
 }
 public String getDescripcion() {
  return Descripcion;
 }
 public void setDescripcion(String descripcion) {
  Descripcion = descripcion;
 }
 public Drawable getImg() {
  return img;
 }
 public void setImg(Drawable img) {
  this.img = img;
 }
}

&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
Bien, ya tenemos todo lo necesario para implementar nuestro &lt;b&gt;Drawermenú&lt;/b&gt;, vamos al onCreate del main y tiene que quedar así :
&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush:java&quot;&gt;public class MainActivity extends FragmentActivity {
  private Context context=this;
  private ListView lista;
  public static DrawerLayout drawerLayout;
  private ArrayList&lt;itemsmenu&gt; array;
  private FrameLayout contenedor_principal;
  
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);   
        configurarObjetos();
    }
    public void configurarObjetos(){
        contenedor_principal=(FrameLayout) findViewById(R.id.contenedor_principal);
        lista = (ListView) findViewById(R.id.drawer);
        drawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
        array = new ArrayList&lt;itemsmenu&gt;();
        llenarListaMenu(array);
        //ADAPTER
        MenuAdapter adaptador = new MenuAdapter(this, array);
        lista.setAdapter(adaptador);
    }
  //LLENAR LISTA DE OBJETOS DEL MENU
    public void llenarListaMenu(ArrayList&lt;itemsmenu&gt; arraydir){
     itemsMenu item;
        // Introduzco los elementos
        item = new itemsMenu(1, &quot;Nirvana&quot;, &quot;Heart, sharped box&quot;,getResources().getDrawable(R.drawable.ic_launcher));
        arraydir.add(item);
        item = new itemsMenu(2, &quot;The pixies&quot;, &quot;Where is my mind&quot;,getResources().getDrawable(R.drawable.ic_launcher));
        arraydir.add(item);
        item = new itemsMenu(3,&quot;Bob Dylan&quot;,&quot;Hurrican Carter&quot;,getResources().getDrawable(R.drawable.ic_launcher));
        arraydir.add(item);
        item = new itemsMenu(4, &quot;Toxicity&quot;,&quot;System of a down&quot;,getResources().getDrawable(R.drawable.ic_launcher));
        arraydir.add(item);
        item = new itemsMenu(5, &quot;Maneras de vivir&quot;, &quot;Rosendo&quot;,getResources().getDrawable(R.drawable.ic_launcher));
        arraydir.add(item);
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.main, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        // Handle action bar item clicks here. The action bar will
        // automatically handle clicks on the Home/Up button, so long
        // as you specify a parent activity in AndroidManifest.xml.
        int id = item.getItemId();
        if (id == R.id.action_settings) {
            return true;
        }
        return super.onOptionsItemSelected(item);
    }
}
&lt;/itemsmenu&gt;&lt;/itemsmenu&gt;&lt;/itemsmenu&gt;&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Ejecutamos la aplicación e inicialmente aparecerá una pantalla en blanco, basta con apretar en el lado donde hemos puesto el drawer (en este caso izquierda) y arrastrar hacia la derecha, entonces tendrá esta apariencia :
&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&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/AVvXsEgAK45kHOZV6j03sV3I9hWcg8kkyyP4O5dSYqFKaOEOIhCnPOIi8M_3-VVktnA8IJ2J-iTmM1CGeAKSsJSl-DdEK2kLLFLtDBA1ODzFoGUTJKnsVJVbg_alkIIe0FqSv73zsgLJ7-rRLbZl/s1600/screenshot2.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/AVvXsEgAK45kHOZV6j03sV3I9hWcg8kkyyP4O5dSYqFKaOEOIhCnPOIi8M_3-VVktnA8IJ2J-iTmM1CGeAKSsJSl-DdEK2kLLFLtDBA1ODzFoGUTJKnsVJVbg_alkIIe0FqSv73zsgLJ7-rRLbZl/s1600/screenshot2.png&quot; height=&quot;272&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;La base ya está echa, ahora si queremos maquearlo un poquito, vamos a insertarle un header en la lista,¿Como se hace? Según instanciamos la lista antes de llenar el array escribimos :&lt;/span&gt;
  &lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush:java&quot;&gt;  //HEADER
  View header=getLayoutInflater().inflate(R.layout.header_menu, null);
        lista.addHeaderView(header,null,false);
&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
Donde R.layout.header_menu es un recurso xml que esta en la carpeta layout, y como podeis ver es super simple implementarlo en nuesta Lista de nuestro DrawerMenu :
&lt;br /&gt;
&lt;br /&gt;
&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/AVvXsEjHBVeJycS5Z2TMvH8WgZilJjJXmALnhBqsfFpaCGJ013cbqPYnV0xJ5NnvxL_2Yye4seOpE-npGfkEg8Vd3fWjOCPEQXVQV4tHMU73C3cfRBVddelhvhpCGwgbSary_KIuSAcEsHJz7COy/s1600/screenshot3.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/AVvXsEjHBVeJycS5Z2TMvH8WgZilJjJXmALnhBqsfFpaCGJ013cbqPYnV0xJ5NnvxL_2Yye4seOpE-npGfkEg8Vd3fWjOCPEQXVQV4tHMU73C3cfRBVddelhvhpCGwgbSary_KIuSAcEsHJz7COy/s1600/screenshot3.png&quot; height=&quot;210&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&amp;gt;&lt;br /&gt;
&amp;lt;FrameLayout xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; android:layout_width=&quot;wrap_content&quot;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; android:layout_height=&quot;wrap_content&quot;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; android:orientation=&quot;vertical&quot; &amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;ImageView&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:id=&quot;@+id/alertImage&quot;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:layout_width=&quot;250dp&quot;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:layout_height=&quot;233dp&quot;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:clickable=&quot;false&quot;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:focusable=&quot;false&quot;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:src=&quot;@drawable/ic_launcher&quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/FrameLayout&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Y quedaría así :
&lt;br /&gt;
&lt;br /&gt;
&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/AVvXsEimifl8fRbpu4ByMwot7qdeGyz-DUxFKCPWMNi5LPVjveEcN0gzAuJmFzsZ8IFooQ_w7kNg339-y1fbPsiMUsA64QhnG15l0ClyBA5sqwD7qY6vXfyjD4AxiGGOJl2BkRclacYz3t1pEF3H/s1600/screenshot4.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/AVvXsEimifl8fRbpu4ByMwot7qdeGyz-DUxFKCPWMNi5LPVjveEcN0gzAuJmFzsZ8IFooQ_w7kNg339-y1fbPsiMUsA64QhnG15l0ClyBA5sqwD7qY6vXfyjD4AxiGGOJl2BkRclacYz3t1pEF3H/s1600/screenshot4.png&quot; height=&quot;270&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Observamos que clickamos en cualquier item de la lista y no sucede nada, eso es porque tenemos que implementar el evento onClick en la lista 
&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush:java&quot;&gt;        lista.setOnItemClickListener(new OnItemClickListener(){
   @Override
   public void onItemClick(AdapterView parent, View view,int position, long id) {
    
    seleccionarItem(position);
   }
         
        });
  
//SELECCION DE FRAGMENT
 @SuppressLint(&quot;ResourceAsColor&quot;) 
 public void seleccionarItem(int posicion){
            switch (posicion) {
         // BOTON PLAY, PRIMERA POSICION = 0
                case 1:
     //fragment1
                    break;
                case 2:
                    //fragment2
                    break;
                case 3:
                 //fragment3
                    break;
                case 4:
                  //fragment4
                    break;
                case 5:
     finish
            }  
    }
&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Ya tenemos como gestionar los fragment, ahora lo que necesitamos es crear 4 fragments distintos para que se pueda navegar en ellos, voy a poner uno, pero se deben hacer 4 &quot;copias&quot; que más tarde cada uno le dará una personalización distinta.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: x-large;&quot;&gt;¿Cómo creamos un fragment?&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Creamos un xml y una clase Java así :&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&amp;lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&amp;gt;&lt;br /&gt;&amp;lt;RelativeLayout xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:id=&quot;@+id/RelativeLayout1&quot;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:layout_width=&quot;match_parent&quot;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:layout_height=&quot;match_parent&quot;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:background=&quot;#000000&quot;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:orientation=&quot;vertical&quot; &amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;TextView&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:id=&quot;@+id/textView1&quot;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:layout_width=&quot;wrap_content&quot;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:layout_height=&quot;wrap_content&quot;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:layout_centerHorizontal=&quot;true&quot;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:layout_centerVertical=&quot;true&quot;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:text=&quot;Fragmento 1&quot;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:textAppearance=&quot;?android:attr/textAppearanceLarge&quot;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:textColor=&quot;#ffffff&quot;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:textSize=&quot;30sp&quot; /&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;/RelativeLayout&amp;gt;&lt;/span&gt; &lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;relativelayout android:background=&quot;#000000&quot; android:id=&quot;@+id/RelativeLayout1&quot; android:layout_height=&quot;match_parent&quot; android:layout_width=&quot;match_parent&quot; android:orientation=&quot;vertical&quot; xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;&gt;

    &lt;textview android:id=&quot;@+id/textView1&quot; android:layout_centerhorizontal=&quot;true&quot; android:layout_centervertical=&quot;true&quot; android:layout_height=&quot;wrap_content&quot; android:layout_width=&quot;wrap_content&quot; android:text=&quot;Fragmento 1&quot; android:textappearance=&quot;?android:attr/textAppearanceLarge&quot; android:textcolor=&quot;#ffffff&quot; android:textsize=&quot;30sp&quot;&gt;

&lt;/textview&gt;&lt;/relativelayout&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush:java&quot;&gt;public class Fragment_1 extends Fragment{
 
  public View onCreateView(LayoutInflater inflater, ViewGroup contenedor, Bundle savedInstanceState) {
        View v = inflater.inflate(R.layout.fragment_1, contenedor, false);       
         return v;
     }
}
&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Vamos a darle la funcionalidad para la gestión eficiente de los fragmentos mediante la función seleccionarItem, así que vamos a poner nuestra &lt;b&gt;activity_main&lt;/b&gt; así :
&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush:java&quot;&gt;public class MainActivity extends FragmentActivity {
  private Context context=this;
  private ListView lista;
  public static DrawerLayout drawerLayout;
  private ArrayList&lt;itemsmenu&gt; array;
  private FrameLayout contenedor_principal;
  
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);   
        configurarObjetos();
    }
    public void configurarObjetos(){
        contenedor_principal=(FrameLayout) findViewById(R.id.contenedor_principal);
        lista = (ListView) findViewById(R.id.drawer);
        drawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
        //le ponemos el header
       // View header=getLayoutInflater().inflate(R.layout.header_menu, null);
        //lista.addHeaderView(header,null,false);
        //Lista de objetos
        array = new ArrayList&lt;itemsmenu&gt;();
        llenarListaMenu(array);
        //ADAPTER
        MenuAdapter adaptador = new MenuAdapter(this, array);
        lista.setAdapter(adaptador);
        //PARA QUE SEA POR DEFECTO EL FRAGMENT1
        seleccionarItem(0);
        
        lista.setOnItemClickListener(new OnItemClickListener(){
   @Override
   public void onItemClick(AdapterView parent, View view,int position, long id) {
    
    seleccionarItem(position);
   }
         
        });
    }
    //====================================================================================
    //SELECCION DE FRAGMENT
    @SuppressLint(&quot;ResourceAsColor&quot;) 
    public void seleccionarItem(int posicion){
        Fragment fragment=null;
        boolean salida=false;
               switch (posicion) {
            // BOTON PLAY, PRIMERA POSICION = 0
                 case 0:
                  fragment = new Fragment_1();
                   break;
                   case 1:
                       fragment = new Fragment_2();
                       break;
                   case 2:
                       fragment = new Fragment_3();
                       break;
                   case 3:
                     fragment = new Fragment_4();
                       break;
                   case 5:
                    salida=true;
                    //MARCAMOS EL CLICKADO
                    lista.setItemChecked(posicion, true);
                    drawerLayout.closeDrawer(lista);
                    finish();
               }
               //SI SE SALE DE LA APLICACIÓN, AL HACER EL CAMBIO DE FRAGMENT DARIA NULLPOINTEREXCEPTION
               if (salida==false){
                //HACEMOS USO DE LA LIBRERIA
                FragmentManager fragmentManager=getSupportFragmentManager();
       //REEMPLAZAMOS
                fragmentManager.beginTransaction().replace(R.id.contenedor_principal, fragment).commit();
                //MARCAMOS EL CLICKADO
                lista.setItemChecked(posicion, true);
                drawerLayout.closeDrawer(lista);
            }
     
       }
  //LLENAR LISTA DE OBJETOS DEL MENU
    public void llenarListaMenu(ArrayList&lt;itemsmenu&gt; arraydir){
     itemsMenu item;
        // Introduzco los elementos
        item = new itemsMenu(1, &quot;Nirvana&quot;, &quot;Heart, sharped box&quot;,getResources().getDrawable(R.drawable.ic_launcher));
        arraydir.add(item);
        item = new itemsMenu(2, &quot;The pixies&quot;, &quot;Where is my mind&quot;,getResources().getDrawable(R.drawable.ic_launcher));
        arraydir.add(item);
        item = new itemsMenu(3,&quot;Bob Dylan&quot;,&quot;Hurrican Carter&quot;,getResources().getDrawable(R.drawable.ic_launcher));
        arraydir.add(item);
        item = new itemsMenu(4, &quot;Toxicity&quot;,&quot;System of a down&quot;,getResources().getDrawable(R.drawable.ic_launcher));
        arraydir.add(item);
        item = new itemsMenu(5, &quot;Fin&quot;, &quot;Salir de la aplicación&quot;,getResources().getDrawable(R.drawable.ic_launcher));
        arraydir.add(item);
    }
&lt;/itemsmenu&gt;&lt;/itemsmenu&gt;&lt;/itemsmenu&gt;&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
Y ya tenemos nuestro navigation drawer que navega entre fragmentos, este es el resultado :&lt;br /&gt;
&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/AVvXsEgFef-ifGmHRIq51YZNXWCb67ynq7WL8_zx4xYfRlBopACjaVraPqo55cPoOU71vrZCLGPBOt4LcoMOSbZs2r9CkhaGZVSFHtRLdQJ5ubPGVktC9hQVdzYFiQBEr2p3DYlWB5OwsWPdsHI-/s1600/drawer.gif&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/AVvXsEgFef-ifGmHRIq51YZNXWCb67ynq7WL8_zx4xYfRlBopACjaVraPqo55cPoOU71vrZCLGPBOt4LcoMOSbZs2r9CkhaGZVSFHtRLdQJ5ubPGVktC9hQVdzYFiQBEr2p3DYlWB5OwsWPdsHI-/s1600/drawer.gif&quot; height=&quot;400&quot; width=&quot;325&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;post-content&quot; style=&quot;display: block; overflow: hidden; width: 660px;&quot;&gt;&lt;i&gt;&lt;b&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&quot;En el futuro los ordenadores no pesarán más de 1.5 toneladas.
&quot;&lt;/span&gt;&lt;/b&gt;&lt;/i&gt;&lt;br /&gt;&quot;Popular Mechanics, 1949&quot;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
Podeis descargar el código fuente de thebestandroide con sólo compartir en facebook,twitter,linkedin o suscribirte a nuestro canal RSS más abajo.&amp;nbsp;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;script language=&quot;JavaScript&quot;&gt;
function muestra_oculta(id,tipo){
 var resultado=tipo
 var dir = document.location.href;
 var tit = document.title;
 var tit2 = encodeURIComponent(tit);
 var url =&quot;&quot;;
if(resultado==1){
 var url =&quot;http://www.facebook.com/share.php?u=&quot;+dir+&quot;&amp;t=&quot;+tit2
 window.open(url, &#39;TheBestAndroide&#39;);
}
if(resultado==2){
  var url =&quot;http://twitter.com/home?status=Estoy en &quot;+dir+&quot; leyendo &quot;+tit2
  window.open(url, &#39;TheBestAndroide&#39;);
}
if(resultado==3){
 var url =&quot;http://www.linkedin.com/shareArticle?mini=true&amp;url=&quot;+dir+&quot;&amp;title=&quot;+tit2+&quot;&amp;source=http://thebestandroide.blogspot.com.es/&quot;;
  window.open(url, &#39;TheBestAndroide&#39;);
}
if(resultado==4){
  var url =&quot;http://feeds.feedburner.com/Thebestandroide&quot;
  window.open(url, &#39;TheBestAndroide&#39;);
}

if (document.getElementById){ //se obtiene el id
var el = document.getElementById(id); //se define la variable &quot;el&quot; igual a nuestro div
el.style.display = (el.style.display == &#39;none&#39;) ? &#39;block&#39; : &#39;none&#39;; //damos un atributo display:none que oculta el div
}
}
window.onload = function(){/*hace que se cargue la función lo que predetermina que div estará oculto hasta llamar a la función nuevamente*/
muestra_oculta(&#39;contenido_a_mostrar&#39;);/* &quot;contenido_a_mostrar&quot; es el nombre que le dimos al DIV */
}
&lt;/script&gt;

&lt;br /&gt;
&lt;table style=&quot;width: 260px;&quot;&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;img alt=&quot;Compartir&quot; border=&quot;0&quot; height=&quot;50&quot; onclick=&quot;muestra_oculta(&#39;contenido_a_mostrar&#39;,1)&quot; onmouseout=&quot;this.src=&#39;https://dl.dropboxusercontent.com/u/28565502/images/redface.png&#39;;&quot; onmouseover=&quot;this.src=&#39;https://dl.dropboxusercontent.com/u/28565502/images/redfacehover.png&#39;;&quot; src=&quot;https://dl.dropboxusercontent.com/u/28565502/images/redface.png&quot; style=&quot;margin-right: 10px;&quot; width=&quot;50&quot; /&gt;

&lt;img alt=&quot;Compartir&quot; border=&quot;0&quot; height=&quot;50&quot; onclick=&quot;muestra_oculta(&#39;contenido_a_mostrar&#39;,2)&quot; onmouseout=&quot;this.src=&#39;https://dl.dropboxusercontent.com/u/28565502/images/twitterRed.png&#39;;&quot; onmouseover=&quot;this.src=&#39;https://dl.dropboxusercontent.com/u/28565502/images/twitterRedhover.png&#39;;&quot; src=&quot;https://dl.dropboxusercontent.com/u/28565502/images/twitterRed.png&quot; style=&quot;margin-right: 10px;&quot; width=&quot;50&quot; /&gt;

&lt;img alt=&quot;Compartir&quot; border=&quot;0&quot; height=&quot;50&quot; onclick=&quot;muestra_oculta(&#39;contenido_a_mostrar&#39;,3)&quot; onmouseout=&quot;this.src=&#39;https://dl.dropboxusercontent.com/u/28565502/images/LinkedIn-Logo.png&#39;;&quot; onmouseover=&quot;this.src=&#39;https://dl.dropboxusercontent.com/u/28565502/images/LinkedIn-Logohover.png&#39;;&quot; src=&quot;https://dl.dropboxusercontent.com/u/28565502/images/LinkedIn-Logo.png&quot; style=&quot;margin-right: 10px;&quot; width=&quot;50&quot; /&gt;

&lt;img alt=&quot;Compartir&quot; border=&quot;0&quot; height=&quot;50&quot; onclick=&quot;muestra_oculta(&#39;contenido_a_mostrar&#39;,4)&quot; onmouseout=&quot;this.src=&#39;https://dl.dropboxusercontent.com/u/28565502/images/rss.png&#39;;&quot; onmouseover=&quot;this.src=&#39;https://dl.dropboxusercontent.com/u/28565502/images/rsshover.png&#39;;&quot; src=&quot;https://dl.dropboxusercontent.com/u/28565502/images/rss.png&quot; style=&quot;margin-right: 10px;&quot; width=&quot;50&quot; /&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br /&gt;
&lt;div id=&quot;contenido_a_mostrar&quot;&gt;
&lt;a href=&quot;https://www.dropbox.com/s/er5f1c2gd4li74v/DrawerMenu.rar?dl=0&quot; target=&quot;_blank&quot;&gt;Descargar archivo&lt;/a&gt;.
&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;</description><link>http://thebestandroide.blogspot.com/2014/11/navigation-drawer-con-drawerlayout.html</link><author>noreply@blogger.com (David)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiN6nGVfhoVMr5PfkAh2DJtO8d1BXjM5RZOFtvRm2MrzhODNG0MgB21ex5fecRdEbbd910IOgx7vHzUmkI8MMb-Yd25s3bRXvH5mLnL69DFksU_lRnd92dKHvthcIrTgXn4PDdZsOO9SY8j/s72-c/nav.jpg" height="72" width="72"/><thr:total>14</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-1686662779713559896.post-2484788095348615879</guid><pubDate>Mon, 03 Nov 2014 08:52:00 +0000</pubDate><atom:updated>2014-11-03T10:04:47.663+00:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">android fragment comunicacion</category><category domain="http://www.blogger.com/atom/ns#">android fragment listview</category><category domain="http://www.blogger.com/atom/ns#">comunicar fragment listview</category><category domain="http://www.blogger.com/atom/ns#">Fragment listview</category><category domain="http://www.blogger.com/atom/ns#">fragment modifica fragment</category><category domain="http://www.blogger.com/atom/ns#">fragment update fragment</category><title>Comunicación entre fragment en Android con un listener</title><description>&lt;a href=&quot;http://thebestandroide.blogspot.com.es/&quot;&gt;&lt;span style=&quot;color: #a5130f;&quot;&gt;Blog &lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #a5130f;&quot;&gt;&lt;a href=&quot;http://thebestandroide.blogspot.com/2014/06/lista-soluciones.html&quot;&gt; &amp;gt;Lista Soluciones &amp;gt;&lt;/a&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #a5130f;&quot;&gt;&lt;b&gt;Fragments II&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&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/AVvXsEhaTQSmBZF1JgQ646PEMKN5UkLcN3bDKO6eIHRBFnZlp2NULzbrUmVxI38wk9QnZUt_Cz9pXHUBdO8onuRVNS6R2LJPoRbo19A3u5x7aZIDKE_D7f09wMvPGNO8bAdJeXDvyMPK1dDtwg2I/s1600/screeenshot0.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/AVvXsEhaTQSmBZF1JgQ646PEMKN5UkLcN3bDKO6eIHRBFnZlp2NULzbrUmVxI38wk9QnZUt_Cz9pXHUBdO8onuRVNS6R2LJPoRbo19A3u5x7aZIDKE_D7f09wMvPGNO8bAdJeXDvyMPK1dDtwg2I/s1600/screeenshot0.png&quot; height=&quot;300&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;span style=&quot;color: #a5130f; font-size: x-large;&quot;&gt;&lt;b&gt;Comunicación entre fragments&amp;nbsp;&lt;/b&gt;&lt;/span&gt;
&lt;br /&gt;
&lt;br /&gt;
Vamos con la continuación del&lt;span style=&quot;color: #a5130f;&quot;&gt;&lt;b&gt; &lt;a href=&quot;http://thebestandroide.blogspot.com.es/2014/11/fragment-en-android.html&quot; target=&quot;_blank&quot;&gt;post anterior&lt;/a&gt;&lt;/b&gt;&lt;/span&gt; en el que hablamos sobre los fragments, ahí encontrareis las clases para formar el código necesario para nuestra Activity con el combo de los 3 fragmentos.La habíamos acabado con este aspecto :
&lt;br /&gt;
&lt;br /&gt;
&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/AVvXsEjrVeA_xBaE1UprL0aw2P3LhKtB8Yn4kYFieJN5dcIXRMebYJTA9b7SaPaJYMEsTDmoFbk6B1R0N-sPTY24VJ8jzzpZDheyxO7yeF19p_OyLf9DKpepm5680ABzzySVG1xComTri7d_HMgJ/s1600/screenshot12.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/AVvXsEjrVeA_xBaE1UprL0aw2P3LhKtB8Yn4kYFieJN5dcIXRMebYJTA9b7SaPaJYMEsTDmoFbk6B1R0N-sPTY24VJ8jzzpZDheyxO7yeF19p_OyLf9DKpepm5680ABzzySVG1xComTri7d_HMgJ/s1600/screenshot12.png&quot; height=&quot;270&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
Vamos a cambiar subir 4 imágenes distintas, yo he usado las de unos amiguetes para que al pulsar en el listView de la izquierda cambie la descripción y la foto.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: #a5130f; font-size: x-large;&quot;&gt;&lt;b&gt;Cómo es la comunicación entre fragment&amp;nbsp;&lt;/b&gt;&lt;/span&gt;
&lt;br /&gt;
&lt;br /&gt;
Antes de seguir, es necesario saber como se comunican los fragment entre ellos, ya que a la hora de trabajar con ellos es indispensable. Para usar los componentes de cada uno debemos desarrollarlos de forma totalmente &lt;b&gt;autocontenida&lt;/b&gt; (se refiere a todo lo que se encuentra en ella sin necesidad de recurrir a contenidos externos como vinculos) pudiendo asociarlos con una Activity para crear una interfad de usuario curiosa.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Lo más pro, es diseñando una interfaz, cosa que se explica &lt;b&gt;&lt;a href=&quot;http://mundogeek.net/android/fragmentos/comunicacion.htm&quot; target=&quot;_blank&quot;&gt;aquí&lt;/a&gt;&lt;/b&gt; de forma muy correcta, ya que como otras veces digo, yo me enfoco más en la parte práctica del código.&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;También podeis consultar la documentación oficial sobre &lt;span style=&quot;color: #a5130f;&quot;&gt;&lt;b&gt;ListFragment &lt;/b&gt;&lt;/span&gt;&lt;b&gt;&lt;a href=&quot;http://developer.android.com/reference/android/app/ListFragment.html&quot; target=&quot;_blank&quot;&gt;aquí&lt;/a&gt;&lt;/b&gt;.
&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
En definitiva, creamos un &quot;&lt;b&gt;listener&lt;/b&gt;&quot; mediante la interactuación de una interfaz con el main y el fragment Lista, lo tendremos que modificar :&lt;br /&gt;
&lt;br /&gt;
Creamos una clase con nuestra interfaz
&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush:java&quot;&gt;public interface InterfacePersonaSeleccionada {
 public void onPersonaSelect(item str);
}
&lt;/pre&gt;
&lt;br /&gt;
Y después nuestro Fragment Lista lo dejamos así :
&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush:java&quot;&gt;public class Fragment_Lista extends Fragment{
 //INTERACTUACION CON LA INTERFAD
 private InterfacePersonaSeleccionada listener;
 
    public void setListener(InterfacePersonaSeleccionada listener) {
        this.listener=listener;
    }
  
 private ListView listado;
 
 Fragment_Lista flist;
 FragmentDetalle fdetalle;
 FragmentFoto fFoto;
 
 private item[] datos =new item[]{
                new item(&quot;Paquito&quot;, &quot;Rapper Boy&quot;, &quot;Badajoz rules, I love my gym!!&quot;),
                new item(&quot;Nona&quot;, &quot;Vazquez Rebuenona&quot;, &quot;Alternativa vividora&quot;),
                new item(&quot;Pedro&quot;, &quot;Peña Irlandes&quot;, &quot;No es que sea serio, soy un borde&quot;),
                new item(&quot;Lunares&quot;, &quot;Romero Pochita&quot;, &quot;Mi habibi&quot;)};
 
    @Override
    public View onCreateView(LayoutInflater inflater,ViewGroup container,Bundle savedInstanceState) {
 
  View v=inflater.inflate(R.layout.listado, container, false);
        return v;
    }
    
    public void onActivityCreated(Bundle state) {
        super.onActivityCreated(state);
 
        listado = (ListView)getView().findViewById(R.id.lista);
        listado.setAdapter(new AdapterList(this,datos));
        
        listado.setOnItemClickListener(new OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView list, View view, int pos, long id) {
                if (listener!=null) {
                    listener.onPersonaSelect(datos[pos]);

                }
            }
        });
    }
&lt;/pre&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;El adaptador lo he omitido pero sigue ahí en la misma clase , si os fijais bien el listener y el evento onClick interactúan en el método &lt;b&gt;onActivityCreated&lt;/b&gt; que es cuando se acaba de crear el fragment, y en método setListener se nos obliga a implementar debido a las características de la interfaz.&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
Si quereis documentación a cerca de qué son las interfaces y para qué valen, podeis encontrarla &lt;b&gt;&lt;a href=&quot;http://www.aprenderaprogramar.es/index.php?option=com_content&amp;amp;view=article&amp;amp;id=671:para-que-sirven-las-interfaces-java-implementar-una-interfaz-del-api-ventajas-y-ejemplos-basicos-cu00697b&amp;amp;catid=68:curso-aprender-programacion-java-desde-cero&amp;amp;Itemid=188&quot; target=&quot;_blank&quot;&gt;aquí&lt;/a&gt;&lt;/b&gt;.&lt;br /&gt;
&lt;br /&gt;
El tema es bastante abstracto y por desgracia más de uno no sabe para que sirve.... asi que si optas por no aprender su uso, cagada!! Hay millones de veces que gracias a las interfaces todo sale más técnico, correcto y por lo tanto, más profesional.&lt;br /&gt;
&lt;br /&gt;
Y ya por último nuestro main :
&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush:java&quot;&gt;public class MainActivity extends FragmentActivity  implements InterfacePersonaSeleccionada{
 
 //METODO DE LA INTERFAD, NUESTRO &quot;LISTENER&quot;
 @Override
 public void onPersonaSelect(item str) {
  // TODO Auto-generated method stub
  //REFERENCIAMOS LOS 2 FRAGMENTOS
  FragmentFoto fFoto =(FragmentFoto) getSupportFragmentManager().findFragmentById(R.id.fragmentFoto);
  FragmentDetalle fDetalle=(FragmentDetalle) getSupportFragmentManager().findFragmentById(R.id.fragmentDetalle);
  //ASIGNAMOS LOS VALORES
  fFoto.cambiarFoto(AsignarFoto(str));
  fDetalle.cambiarTexto(str.getDescripcion());
 }
 
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
  
  Fragment_Lista LISTA = 
    (Fragment_Lista) getSupportFragmentManager().findFragmentById(R.id.fragmentLista);
  LISTA.setListener(this);
        
        
    }
 //FUNCION PARA ASIGNAR LA FOTO SEGUN EL OBJETO QUE NOS DE LA INTERFAZ AL HACER CLICK EN LA LISTA
    public Drawable AsignarFoto(item str){
     Drawable foto = null;
     
     if(str.getName().compareTo(&quot;Paquito&quot;)==0){
      foto = getResources().getDrawable(R.drawable.foto1);
     }else if(str.getName().compareTo(&quot;Nona&quot;)==0){
      foto = getResources().getDrawable(R.drawable.foto2);
     }else if(str.getName().compareTo(&quot;Pedro&quot;)==0){
      foto = getResources().getDrawable(R.drawable.foto3);
     }else if(str.getName().compareTo(&quot;Lunares&quot;)==0){
      foto = getResources().getDrawable(R.drawable.foto4);
     }
     return foto;
    }
&lt;/pre&gt;
&lt;br /&gt;
&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/AVvXsEjqd2xuHf04KZO3J2CZgVIPiyI9N3MuIGmKuaGxQAKoCwMpLmNp7M3Brr3f2mcsPHLGghW-U9lAGVJMv1oa_oWli7eJ1O_87WP4kl3Renn_Z1SDLmKvOdE9N0seZxofrO1eMzFpPkULJmc0/s1600/video.gif&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/AVvXsEjqd2xuHf04KZO3J2CZgVIPiyI9N3MuIGmKuaGxQAKoCwMpLmNp7M3Brr3f2mcsPHLGghW-U9lAGVJMv1oa_oWli7eJ1O_87WP4kl3Renn_Z1SDLmKvOdE9N0seZxofrO1eMzFpPkULJmc0/s1600/video.gif&quot; height=&quot;320&quot; width=&quot;266&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
Podeis descargar el código fuente de thebestandroide con sólo compartir en facebook,twitter,linkedin o suscribirte a nuestro canal RSS más abajo.&amp;nbsp;
&lt;br /&gt;
&lt;br /&gt;
&lt;script language=&quot;JavaScript&quot;&gt;
function muestra_oculta(id,tipo){
 var resultado=tipo
 var dir = document.location.href;
 var tit = document.title;
 var tit2 = encodeURIComponent(tit);
 var url =&quot;&quot;;
if(resultado==1){
 var url =&quot;http://www.facebook.com/share.php?u=&quot;+dir+&quot;&amp;t=&quot;+tit2
 window.open(url, &#39;TheBestAndroide&#39;);
}
if(resultado==2){
  var url =&quot;http://twitter.com/home?status=Estoy en &quot;+dir+&quot; leyendo &quot;+tit2
  window.open(url, &#39;TheBestAndroide&#39;);
}
if(resultado==3){
 var url =&quot;http://www.linkedin.com/shareArticle?mini=true&amp;url=&quot;+dir+&quot;&amp;title=&quot;+tit2+&quot;&amp;source=http://thebestandroide.blogspot.com.es/&quot;;
  window.open(url, &#39;TheBestAndroide&#39;);
}
if(resultado==4){
  var url =&quot;http://feeds.feedburner.com/Thebestandroide&quot;
  window.open(url, &#39;TheBestAndroide&#39;);
}

if (document.getElementById){ //se obtiene el id
var el = document.getElementById(id); //se define la variable &quot;el&quot; igual a nuestro div
el.style.display = (el.style.display == &#39;none&#39;) ? &#39;block&#39; : &#39;none&#39;; //damos un atributo display:none que oculta el div
}
}
window.onload = function(){/*hace que se cargue la función lo que predetermina que div estará oculto hasta llamar a la función nuevamente*/
muestra_oculta(&#39;contenido_a_mostrar&#39;);/* &quot;contenido_a_mostrar&quot; es el nombre que le dimos al DIV */
}
&lt;/script&gt;

&lt;br /&gt;
&lt;table style=&quot;width: 260px;&quot;&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;img alt=&quot;Compartir&quot; border=&quot;0&quot; height=&quot;50&quot; onclick=&quot;muestra_oculta(&#39;contenido_a_mostrar&#39;,1)&quot; onmouseout=&quot;this.src=&#39;https://dl.dropboxusercontent.com/u/28565502/images/redface.png&#39;;&quot; onmouseover=&quot;this.src=&#39;https://dl.dropboxusercontent.com/u/28565502/images/redfacehover.png&#39;;&quot; src=&quot;https://dl.dropboxusercontent.com/u/28565502/images/redface.png&quot; style=&quot;margin-right: 10px;&quot; width=&quot;50&quot; /&gt;

&lt;img alt=&quot;Compartir&quot; border=&quot;0&quot; height=&quot;50&quot; onclick=&quot;muestra_oculta(&#39;contenido_a_mostrar&#39;,2)&quot; onmouseout=&quot;this.src=&#39;https://dl.dropboxusercontent.com/u/28565502/images/twitterRed.png&#39;;&quot; onmouseover=&quot;this.src=&#39;https://dl.dropboxusercontent.com/u/28565502/images/twitterRedhover.png&#39;;&quot; src=&quot;https://dl.dropboxusercontent.com/u/28565502/images/twitterRed.png&quot; style=&quot;margin-right: 10px;&quot; width=&quot;50&quot; /&gt;

&lt;img alt=&quot;Compartir&quot; border=&quot;0&quot; height=&quot;50&quot; onclick=&quot;muestra_oculta(&#39;contenido_a_mostrar&#39;,3)&quot; onmouseout=&quot;this.src=&#39;https://dl.dropboxusercontent.com/u/28565502/images/LinkedIn-Logo.png&#39;;&quot; onmouseover=&quot;this.src=&#39;https://dl.dropboxusercontent.com/u/28565502/images/LinkedIn-Logohover.png&#39;;&quot; src=&quot;https://dl.dropboxusercontent.com/u/28565502/images/LinkedIn-Logo.png&quot; style=&quot;margin-right: 10px;&quot; width=&quot;50&quot; /&gt;

&lt;img alt=&quot;Compartir&quot; border=&quot;0&quot; height=&quot;50&quot; onclick=&quot;muestra_oculta(&#39;contenido_a_mostrar&#39;,4)&quot; onmouseout=&quot;this.src=&#39;https://dl.dropboxusercontent.com/u/28565502/images/rss.png&#39;;&quot; onmouseover=&quot;this.src=&#39;https://dl.dropboxusercontent.com/u/28565502/images/rsshover.png&#39;;&quot; src=&quot;https://dl.dropboxusercontent.com/u/28565502/images/rss.png&quot; style=&quot;margin-right: 10px;&quot; width=&quot;50&quot; /&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br /&gt;
&lt;div id=&quot;contenido_a_mostrar&quot;&gt;
&lt;a href=&quot;https://www.dropbox.com/s/x5h8jm2evc2hwcc/Fragments2.rar?dl=0&quot; target=&quot;_blank&quot;&gt;Descargar archivo&lt;/a&gt;.
&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;</description><link>http://thebestandroide.blogspot.com/2014/11/comunicacion-entre-fragment-en-android.html</link><author>noreply@blogger.com (David)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhaTQSmBZF1JgQ646PEMKN5UkLcN3bDKO6eIHRBFnZlp2NULzbrUmVxI38wk9QnZUt_Cz9pXHUBdO8onuRVNS6R2LJPoRbo19A3u5x7aZIDKE_D7f09wMvPGNO8bAdJeXDvyMPK1dDtwg2I/s72-c/screeenshot0.png" height="72" width="72"/><thr:total>2</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-1686662779713559896.post-8300260968719430224</guid><pubDate>Sat, 01 Nov 2014 00:30:00 +0000</pubDate><atom:updated>2014-11-03T10:22:08.066+00:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">android fragment</category><category domain="http://www.blogger.com/atom/ns#">android varios fragment</category><category domain="http://www.blogger.com/atom/ns#">android varios fragment xml</category><category domain="http://www.blogger.com/atom/ns#">Fragment ciclo de vida</category><title>Fragment en Android</title><description>&lt;a href=&quot;http://thebestandroide.blogspot.com.es/&quot;&gt;&lt;span style=&quot;color: #a5130f;&quot;&gt;Blog &lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #a5130f;&quot;&gt;&lt;a href=&quot;http://thebestandroide.blogspot.com/2014/06/lista-soluciones.html&quot;&gt; &amp;gt;Lista Soluciones &amp;gt;&lt;/a&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #a5130f;&quot;&gt;&lt;b&gt;Fragment I&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Hola developers!! vamos hoy a ver un tema sobre un tipo de componentes relativamente nuevos: los Fragments.
&lt;br /&gt;
&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/AVvXsEhMd8d9vdXHfTiHZutBGj0AD1yZhGvwVHgJt5_vtvHA3F6XSs5jw1NpqNHUtYluB1ROxM9bHzIciHFIyet-FspL3mMgZ2PmDMWS5cY6kMt6ZXb9dk_yINwBk0GmWKL25DH7s1R9M3-hQSqe/s1600/screeenshot0.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/AVvXsEhMd8d9vdXHfTiHZutBGj0AD1yZhGvwVHgJt5_vtvHA3F6XSs5jw1NpqNHUtYluB1ROxM9bHzIciHFIyet-FspL3mMgZ2PmDMWS5cY6kMt6ZXb9dk_yINwBk0GmWKL25DH7s1R9M3-hQSqe/s1600/screeenshot0.png&quot; height=&quot;300&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: #a5130f; font-size: x-large;&quot;&gt;&lt;b&gt;Fragment&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #a5130f; font-size: x-large;&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Los fragments los podemos explicar diciendo que son trozos de vista que se pueden mostrar o no dependiendo de nuestros intereses, ya sea porque nos interesen distintas dimensiones de pantalla o en la orientación del dispositvo, podemos añadirlos cuando queramos.&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Recientemente los podemos ver en múltiples aplicaciones que hay subidas en Google Play, de hecho el menú que tiene Outlook o Gmail se componen de ellos. En Android usamos varias librerias para su implementación , no obstante antes de describir ninguna, vamos a ver el ciclo de vida de los Fragments :
&lt;/span&gt;&lt;br /&gt;
&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/AVvXsEiohcMLmwycbEBVDH02v3Oh8_GmYtq1Bjzm-HNJd8bSbrWkV7HqPv1wqFp02Ipom-63ZzRSs4G1nB3D4DaS9vbeqkolgnvCqOPcR9puccEPYxEVlNrDw9pxPhpyS27-5xlI93_q1ZkPE0Ch/s1600/screenshot1.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/AVvXsEiohcMLmwycbEBVDH02v3Oh8_GmYtq1Bjzm-HNJd8bSbrWkV7HqPv1wqFp02Ipom-63ZzRSs4G1nB3D4DaS9vbeqkolgnvCqOPcR9puccEPYxEVlNrDw9pxPhpyS27-5xlI93_q1ZkPE0Ch/s1600/screenshot1.png&quot; height=&quot;640&quot; width=&quot;580&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: x-large;&quot;&gt;Un Fragment depende de &lt;span style=&quot;color: #a5130f;&quot;&gt;&lt;b&gt;FragmentActivity&lt;/b&gt;&lt;/span&gt; y siempre descansa o puede pasar varias veces en FragmentActivity.&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
Entonces se puede decir que su ciclo de vida depende del ciclo de vida de &lt;b&gt;FragmentActivity&lt;/b&gt;. Para crear un fragment deberemos extender la clase &quot;Fragment&quot; y sobreescribir el método &quot;onCreateView()&quot; en el que devolveremos la vista de dicho fragment.En el sitio oficial de Android podreis curiosear todo lo que querais, os  lo dejo &lt;a href=&quot;http://developer.android.com/reference/android/app/Fragment.html&quot;&gt;&lt;span style=&quot;color: #a5130f;&quot;&gt;&lt;b&gt;aquí&lt;/b&gt;&lt;/span&gt;&lt;/a&gt;.
&lt;br /&gt;
&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span style=&quot;color: #a5130f;&quot;&gt;&lt;b&gt;onCreate() :&lt;/b&gt;&lt;/span&gt; El sistema llama a este método a la hora de crear el fragmento, normalmente iniciaremos los componentes esenciales del fragmento.
&lt;/li&gt;
&lt;/ul&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span style=&quot;color: #a5130f;&quot;&gt;&lt;b&gt;onCreateView() :&lt;/b&gt;&lt;/span&gt; Se llamará al método cuando haya que crear la interface de usuario o vista, normalmente se devuelve la View del fragmento.
&lt;/li&gt;
&lt;/ul&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span style=&quot;color: #a5130f;&quot;&gt;&lt;b&gt;onPause() :&lt;/b&gt;&lt;/span&gt; Se llama método en el momento que el usuario abandone el fragmento, es un buen momento para guardar información.
&lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush:java&quot;&gt;public class FragmentOne extends Fragment{
 
    public static final String TAG = &quot;ExampleFragment&quot;;
    private FragmentIterationListener mCallback = null;
 
    public interface FragmentIterationListener{
        public void onFragmentIteration(Bundle parameters);
    }
     
    public static ExampleFragment newInstance(Bundle arguments){
        ExampleFragment f = new ExampleFragment();
        if(arguments != null){
            f.setArguments(arguments);
        }
        return f;
    }
     //CONSTRUCTOR
    public FragmentOne(){
     
    }
     
    //El fragment se ha adjuntado al Activity
    @Override
    public void onAttach(Activity activity) {
        super.onAttach(activity);
    }
     
    //El Fragment ha sido creado       
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    }
     
    //La vista de layout ha sido creada y ya está disponible
    @Override
    public void onViewCreated(View view, Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
    }
     
    //La vista ha sido creada y cualquier configuración guardada está cargada
    @Override
    public void onViewStateRestored(Bundle savedInstanceState) {
        super.onViewStateRestored(savedInstanceState);
    }
     
     
    //El Fragment ha sido quitado de su Activity y ya no está disponible
    @Override
    public void onDetach() {
        super.onDetach();
    }
     //El Fragment va a cargar su layout, el cual debemos especificar
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,Bundle savedInstanceState) {
        super.onCreateView(inflater, container, savedInstanceState);      
  View v =  inflater.inflate(R.layout.examplefragment_view, container, false);  
    }
}
&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;El &lt;b&gt;LayoutInflater&lt;/b&gt; lo usaremos para inflar el layout de nuestro fragment. inflate recoge tres parámetros.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
En el primero indicamos la&lt;b&gt; id del layout&lt;/b&gt; de nuestro fragment,el &lt;b&gt;view padre&lt;/b&gt; de nuestro fragment y un booleano que nos servirá para indicar&lt;b&gt; si el inflado del layout debe ser insertado en el ViewGroup&lt;/b&gt; (En este caso es false porque se esta insertando directamente el layout en el ViewGroup).&lt;br /&gt;
&lt;br /&gt;
El ViewGroup sera el &quot;padre&quot; donde se insertara el layout de nuestro fragment. 
El Bundle podremos utilizarlo para recuperar datos de una instancia anterior de nuestro fragment.
&lt;br /&gt;
Incluyo ahora el método&lt;b&gt; onActivityCreated&lt;/b&gt;, que nos vale para declarar las variables que tengan que ver con el Activity en onActivityCreated()
&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush:java&quot;&gt;    //El Activity que contiene el Fragment ha terminado su creación
    @Override
    public void onActivityCreated(Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
    }
&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
Se deben instanciar los elementos que&lt;b&gt; no &lt;/b&gt;sean vistas en el método &lt;b&gt;onCreateView()&lt;/b&gt;, como botones, TextViews etc, el layout se carga también en ese método.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: #a5130f; font-size: x-large;&quot;&gt;&lt;b&gt;Agregar un fragment&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-large;&quot;&gt; &lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &lt;br /&gt;
Se pueden agregar mediante XML o Java :
&lt;br /&gt;
XML&lt;linearlayout android:layout_height=&quot;match_parent&quot; android:layout_width=&quot;match_parent&quot; android:orientation=&quot;vertical&quot; xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;&gt;&lt;/linearlayout&gt;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;lt;LinearLayout &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; android:orientation=&quot;vertical&quot;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; android:layout_width=&quot;match_parent&quot;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; android:layout_height=&quot;match_parent&quot;&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;fragment &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:name=&quot;com.fragments.fragmentOne&quot;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:id=&quot;@+id/fragmentOne&quot;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:layout_width=&quot;match_parent&quot;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:layout_height=&quot;match_parent&quot;/&amp;gt;&lt;br /&gt;
&amp;lt;/LinearLayout&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Es necesario asignarle un identificador único para cada fragment, hay 3 maneras de declarar un fragment :&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span style=&quot;font-size: large;&quot;&gt;android:id
&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style=&quot;font-size: large;&quot;&gt;android:tag
&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style=&quot;font-size: large;&quot;&gt;Recogida automática mediante la id de la vista&amp;nbsp;&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&amp;nbsp;&lt;/span&gt;Java :
&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush:java&quot;&gt;protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.fragmentTwo);
  
    FragmentManager FM = getSupportFragmentManager();
    FragmentTransaction FT = FM.beginTransaction();
  
    Fragment fragment = new FragmentOne();
    FT.add(R.id.fragmentOne_container, fragment);
    FT.commit();
}
&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
Bueno, una vez que ya está mas o menos explicado, vamos con un ejemplo que es como mejor se entiende, en este caso he de recalcar que voy a hacerlo sobre fragments estáticos.
&lt;br /&gt;
&lt;br /&gt;
Antes de liarlos con el código, quiero que veais el aspecto que va a tener :
&lt;br /&gt;
&lt;br /&gt;
&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/AVvXsEjdUeX5I0mL1zZZz3EZ_esniYqDLCYIULY3EE8yhYiBPw_jiv9wxBzX5-D8L9rfRs-0yCegSDkeucsq8AcDOAmKCqbqxAQZw4nhaVFA3fM8kT8wXzt-H8xGJCLqSQyWcp-EoMKlmRc7E11R/s1600/screenshot8.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/AVvXsEjdUeX5I0mL1zZZz3EZ_esniYqDLCYIULY3EE8yhYiBPw_jiv9wxBzX5-D8L9rfRs-0yCegSDkeucsq8AcDOAmKCqbqxAQZw4nhaVFA3fM8kT8wXzt-H8xGJCLqSQyWcp-EoMKlmRc7E11R/s1600/screenshot8.png&quot; height=&quot;271&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
Es un activitymain.xml que tiene 3 fragmentos, asociados cada uno a su correspondiente clase, el java de la clase principal es super sencillo, únicamente hay que indicarle que extienda de &lt;b&gt;FragmentActivity&lt;/b&gt; :
&lt;br /&gt;
&lt;br /&gt;
Este es el aspecto de nuestro main.xml :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;FrameLayout xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; xmlns:tools=&quot;http://schemas.android.com/tools&quot;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; android:id=&quot;@+id/contenedorPrincipal&quot;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; android:layout_width=&quot;fill_parent&quot;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; android:layout_height=&quot;fill_parent&quot;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; tools:context=&quot;com.example.fragments.MainActivity&quot; &amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;LinearLayout&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; android:layout_width=&quot;fill_parent&quot;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; android:layout_height=&quot;fill_parent&quot;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; android:orientation=&quot;horizontal&quot; &amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;fragment&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:id=&quot;@+id/fragmentLista&quot;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:name=&quot;com.example.fragments.Fragment_Lista&quot;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:layout_width=&quot;150dp&quot;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:layout_height=&quot;fill_parent&quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;LinearLayout&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:layout_width=&quot;fill_parent&quot;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:layout_height=&quot;fill_parent&quot;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:orientation=&quot;vertical&quot; &amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;fragment&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:id=&quot;@+id/fragmentFoto&quot;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:name=&quot;com.example.fragments.FragmentFoto&quot;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:layout_width=&quot;wrap_content&quot;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:layout_height=&quot;180dp&quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;fragment&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:id=&quot;@+id/fragmentDetalle&quot;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:layout_width=&quot;match_parent&quot;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:layout_height=&quot;wrap_content&quot;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:layout_weight=&quot;70&quot;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; android:name=&quot;com.example.fragments.FragmentDetalle&quot; /&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/LinearLayout&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/LinearLayout&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/FrameLayout&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&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/AVvXsEh7EUpY2wrVYkh13xAY8cAmYh-HpmXhkO7cIG3_-PmpcES-aD1p5sGPjk8Dsy9X61bF5AQzzuKb9btkIMQoLMKls-eXKpL5VFN3ildASkbiNu-hcOugGLWp8x95nQQYgtuCABf2gMoPV672/s1600/screenshot7.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/AVvXsEh7EUpY2wrVYkh13xAY8cAmYh-HpmXhkO7cIG3_-PmpcES-aD1p5sGPjk8Dsy9X61bF5AQzzuKb9btkIMQoLMKls-eXKpL5VFN3ildASkbiNu-hcOugGLWp8x95nQQYgtuCABf2gMoPV672/s1600/screenshot7.png&quot; height=&quot;175&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;framelayout android:id=&quot;@+id/contenedorPrincipal&quot; android:layout_height=&quot;fill_parent&quot; android:layout_width=&quot;fill_parent&quot; tools:context=&quot;com.example.fragments.MainActivity&quot; xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot; xmlns:tools=&quot;http://schemas.android.com/tools&quot;&gt;

&lt;linearlayout android:layout_height=&quot;fill_parent&quot; android:layout_width=&quot;fill_parent&quot; android:orientation=&quot;horizontal&quot;&gt;

            &lt;fragment android:id=&quot;@+id/fragmentLista&quot; android:layout_height=&quot;fill_parent&quot; android:layout_width=&quot;150dp&quot; android:name=&quot;com.example.fragments.Fragment_Lista&quot;&gt;

        &lt;linearlayout android:layout_height=&quot;fill_parent&quot; android:layout_width=&quot;fill_parent&quot; android:orientation=&quot;vertical&quot;&gt;

            &lt;fragment android:id=&quot;@+id/fragmentFoto&quot; android:layout_height=&quot;150dp&quot; android:layout_width=&quot;wrap_content&quot; android:name=&quot;com.example.fragments.FragmentFoto&quot;&gt;

            &lt;fragment android:id=&quot;@+id/fragmentDetalle&quot; android:layout_height=&quot;wrap_content&quot; android:layout_weight=&quot;70&quot; android:layout_width=&quot;match_parent&quot; android:name=&quot;com.example.fragments.FragmentDetalle&quot;&gt;
        &lt;/fragment&gt;&lt;/fragment&gt;&lt;/linearlayout&gt;

&lt;/fragment&gt;&lt;/linearlayout&gt;
&lt;/framelayout&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush:java&quot;&gt;public class MainActivity extends FragmentActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
}
&lt;/pre&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Y ahora vamos con los 3 fragments; cada uno está enfocado a una cosa distinta, uno a un TextView otro a un ImageView y otro a un ListView&lt;/span&gt;
&lt;br /&gt;
&lt;br /&gt;
&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/AVvXsEgvgTgWCMkBZ458qRJfNssq4AYcXQFLqyUKPP27HVZQP_wURpbWOznhHJNhuEQjQcdRzHj_4TJJWZgoX7uNHZkmtsQErxkT6-m9UYSzFvrUojZJCv5ps3a-gkLYBKopyWBUuVyijwO_r-CQ/s1600/screenshot9.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/AVvXsEgvgTgWCMkBZ458qRJfNssq4AYcXQFLqyUKPP27HVZQP_wURpbWOznhHJNhuEQjQcdRzHj_4TJJWZgoX7uNHZkmtsQErxkT6-m9UYSzFvrUojZJCv5ps3a-gkLYBKopyWBUuVyijwO_r-CQ/s1600/screenshot9.png&quot; height=&quot;400&quot; width=&quot;237&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;linearlayout android:background=&quot;#aaaaaa&quot; android:layout_height=&quot;fill_parent&quot; android:layout_width=&quot;fill_parent&quot; android:orientation=&quot;horizontal&quot; xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;&gt;

    &lt;textview android:id=&quot;@+id/Txt_d&quot; android:layout_height=&quot;match_parent&quot; android:layout_width=&quot;wrap_content&quot; android:text=&quot;Texto detallado&quot; android:textappearance=&quot;?android:attr/textAppearanceLarge&quot;&gt;

&lt;/textview&gt;&lt;/linearlayout&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush:java&quot;&gt;public class FragmentDetalle extends Fragment{
 @Override
    public View onCreateView(LayoutInflater inflater,ViewGroup container,Bundle savedInstanceState) {
 
        return inflater.inflate(R.layout.fragment_detalle, container, false);
    }
    public void cambiarTexto(String t) {
        TextView f =(TextView)getView().findViewById(R.id.Txt_d);
        f.setText(t);
    }

}
&lt;/pre&gt;
&lt;br /&gt;
&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/AVvXsEjN_mj1uZEN1IGg6ufYh1bjwaEt_hYU9Nxvzvps20ZHlErO-Vgi7LAUUOsOczttSehGVPva6K4fjgY-k9NYNQgz3OT3h0_mqX7QMQAtGhy5_axnxhriv2Xyu5wmsbP7yS90PZ86_vlqF7DJ/s1600/screenshot10.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/AVvXsEjN_mj1uZEN1IGg6ufYh1bjwaEt_hYU9Nxvzvps20ZHlErO-Vgi7LAUUOsOczttSehGVPva6K4fjgY-k9NYNQgz3OT3h0_mqX7QMQAtGhy5_axnxhriv2Xyu5wmsbP7yS90PZ86_vlqF7DJ/s1600/screenshot10.png&quot; height=&quot;400&quot; width=&quot;265&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;linearlayout android:layout_height=&quot;match_parent&quot; android:layout_width=&quot;match_parent&quot; android:orientation=&quot;horizontal&quot; xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;&gt;

    &lt;imageview android:id=&quot;@+id/fotito&quot; android:layout_height=&quot;150dp&quot; android:layout_width=&quot;150dp&quot; android:src=&quot;@drawable/ic_launcher&quot;&gt;

&lt;/imageview&gt;&lt;/linearlayout&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush:java&quot;&gt;public class FragmentFoto  extends Fragment{
 @Override
    public View onCreateView(LayoutInflater inflater,ViewGroup container,Bundle savedInstanceState) {
 
        return inflater.inflate(R.layout.fragment_foto, container, false);
    }
 
    public void cambiarFoto(Drawable foto) {
        ImageView f =(ImageView)getView().findViewById(R.id.fotito);
        f.setImageDrawable(foto);
    }
}
&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
Ahora vamos con el listview, además del xml y de la clase java, usaremos el adapter y el item_list correspondiente, si quereis saber un poquito más sobre cómo van los adapters podeis verlo en este &lt;a href=&quot;http://thebestandroide.blogspot.com.es/2014/07/android-listview-con-imageview-textview.html&quot;&gt;&lt;b&gt;post&lt;/b&gt;&lt;/a&gt;.
&lt;br /&gt;
&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/AVvXsEhgCyhIOpIqPue9tSxtyRVzGTTJnKE9pkKNmSzrX9RRUSgb2gZ98SIVhcmslhe_Y8fTo4uBAxPFpgqm5UCEE2GkCiCWlltxbUO97Itclu7kG_4Jrmto6NZBanjT4Gc5NcDp3kVreoszQr3s/s1600/screenshot11.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/AVvXsEhgCyhIOpIqPue9tSxtyRVzGTTJnKE9pkKNmSzrX9RRUSgb2gZ98SIVhcmslhe_Y8fTo4uBAxPFpgqm5UCEE2GkCiCWlltxbUO97Itclu7kG_4Jrmto6NZBanjT4Gc5NcDp3kVreoszQr3s/s1600/screenshot11.png&quot; height=&quot;400&quot; width=&quot;240&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
list_item
&lt;br /&gt;
&lt;linearlayout android:layout_height=&quot;match_parent&quot; android:layout_width=&quot;fill_parent&quot; android:orientation=&quot;vertical&quot; xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;&gt;

    &lt;linearlayout android:layout_height=&quot;wrap_content&quot; android:layout_margin=&quot;10dp&quot; android:layout_width=&quot;match_parent&quot; android:orientation=&quot;vertical&quot;&gt;

        &lt;textview android:id=&quot;@+id/nombre&quot; android:layout_height=&quot;wrap_content&quot; android:layout_width=&quot;wrap_content&quot; android:text=&quot;Nombre&quot; android:textappearance=&quot;?android:attr/textAppearanceLarge&quot;&gt;

        &lt;textview android:id=&quot;@+id/apellidos&quot; android:layout_height=&quot;wrap_content&quot; android:layout_width=&quot;wrap_content&quot; android:text=&quot;Apellidos&quot;&gt;
    &lt;/textview&gt;&lt;/textview&gt;&lt;/linearlayout&gt;

&lt;/linearlayout&gt;

item
&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush:java&quot;&gt;package com.example.fragments;

public class item {
 private String name;
 private String apellidos;
 private String descripcion;
 
 
 
 public item(String name, String apellidos, String descripcion) {
  super();
  this.name = name;
  this.apellidos = apellidos;
  this.descripcion = descripcion;
 }
 public String getName() {
  return name;
 }
 public void setName(String name) {
  this.name = name;
 }
 public String getApellidos() {
  return apellidos;
 }
 public void setApellidos(String apellidos) {
  this.apellidos = apellidos;
 }
 public String getDescripcion() {
  return descripcion;
 }
 public void setDescripcion(String descripcion) {
  this.descripcion = descripcion;
 }
}
&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
Este es el xml y la clase para el fragment list
&lt;br /&gt;
&lt;linearlayout android:background=&quot;#ff1ff1&quot; android:layout_height=&quot;match_parent&quot; android:layout_width=&quot;match_parent&quot; android:orientation=&quot;vertical&quot; xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;&gt;

    &lt;listview android:id=&quot;@+id/lista&quot; android:layout_height=&quot;wrap_content&quot; android:layout_width=&quot;match_parent&quot;&gt;

    &lt;/listview&gt;
&lt;/linearlayout&gt;

&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush:java&quot;&gt;public class Fragment_Lista extends Fragment{
 
@Override
 public void onStart() {
  // TODO Auto-generated method stub
  super.onStart();
 }

private ListView listado;
 
 private item[] datos =new item[]{
                new item(&quot;Paquito&quot;, &quot;Rapper Boy&quot;, &quot;Badajoz rules&quot;),
                new item(&quot;Alisa&quot;, &quot;Cuadros&quot;, &quot;Ramstad compañera de trabajo&quot;),
                new item(&quot;Felipe´s&quot;, &quot;Fiestas&quot;, &quot;Ojo tuerto&quot;),
                new item(&quot;Lunares&quot;, &quot;Romero Redondo&quot;, &quot;Mi habibi&quot;)};
 
    @Override
    public View onCreateView(LayoutInflater inflater,ViewGroup container,Bundle savedInstanceState) {
 
        return inflater.inflate(R.layout.listado, container, false);
    }
    
    public void onActivityCreated(Bundle state) {
        super.onActivityCreated(state);
 
        listado = (ListView)getView().findViewById(R.id.lista);
        listado.setAdapter(new AdapterList(this,datos));
        
        listado.setOnItemClickListener(new OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView list, View view, int pos, long id) {
               /* if (listener!=null) {
                    listener.onCorreoSeleccionado(
                        (Correo)lstListado.getAdapter().getItem(pos));
                }*/
            }
        });
    }

public class AdapterList extends ArrayAdapter&lt;item&gt; {
        Activity context;
        item[] lista;

        AdapterList(Fragment context,item[] lista) {
            super(context.getActivity(), R.layout.list_item, lista);
            this.context = context.getActivity();
            this.lista=lista;
        }

        public View getView(int position, View convertView, ViewGroup parent) {
         LayoutInflater inflater = context.getLayoutInflater();
         View item = inflater.inflate(R.layout.list_item, null);

         TextView name = (TextView)item.findViewById(R.id.nombre);
         name.setText(lista[position].getName());

         TextView ape = (TextView)item.findViewById(R.id.apellidos);
         ape.setText(lista[position].getApellidos());
         
        return(item);
        }
    }
}
&lt;/item&gt;&lt;/pre&gt;
&lt;br /&gt;
&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/AVvXsEiHB5G8q9ZY_-N6JV0H0cvJBoaiGnXZQ4VV3RRXX6oZXSR-EdeMbyQNFHZmH_jK9rk9EaechN_JeIVGO6b48ecVxpC6fzDuL9-eOiGgOEswlRpLLs1dW3oB1J_9EgEvRkmopF2Q0IzgmbIa/s1600/screenshot12.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/AVvXsEiHB5G8q9ZY_-N6JV0H0cvJBoaiGnXZQ4VV3RRXX6oZXSR-EdeMbyQNFHZmH_jK9rk9EaechN_JeIVGO6b48ecVxpC6fzDuL9-eOiGgOEswlRpLLs1dW3oB1J_9EgEvRkmopF2Q0IzgmbIa/s1600/screenshot12.png&quot; height=&quot;270&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
Ya tenemos bastante verdad¿? Vamos ahora a ver la comunicación entre los fragments, estaría chulo que viésemos como al clickar en un item de la lista, cambiase la foto y el texto a mostrar... podremos verlo en el siguiente &lt;a href=&quot;http://thebestandroide.blogspot.com.es/2014/11/comunicacion-entre-fragment-en-android.html&quot; target=&quot;_blank&quot;&gt;&lt;b&gt;post&lt;/b&gt;.&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
Podeis descargar el código fuente de thebestandroide con sólo compartir en facebook,twitter,linkedin o suscribirte a nuestro canal RSS más abajo.&amp;nbsp;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;script language=&quot;JavaScript&quot;&gt;
function muestra_oculta(id,tipo){
 var resultado=tipo
 var dir = document.location.href;
 var tit = document.title;
 var tit2 = encodeURIComponent(tit);
 var url =&quot;&quot;;
if(resultado==1){
 var url =&quot;http://www.facebook.com/share.php?u=&quot;+dir+&quot;&amp;t=&quot;+tit2
 window.open(url, &#39;TheBestAndroide&#39;);
}
if(resultado==2){
  var url =&quot;http://twitter.com/home?status=Estoy en &quot;+dir+&quot; leyendo &quot;+tit2
  window.open(url, &#39;TheBestAndroide&#39;);
}
if(resultado==3){
 var url =&quot;http://www.linkedin.com/shareArticle?mini=true&amp;url=&quot;+dir+&quot;&amp;title=&quot;+tit2+&quot;&amp;source=http://thebestandroide.blogspot.com.es/&quot;;
  window.open(url, &#39;TheBestAndroide&#39;);
}
if(resultado==4){
  var url =&quot;http://feeds.feedburner.com/Thebestandroide&quot;
  window.open(url, &#39;TheBestAndroide&#39;);
}

if (document.getElementById){ //se obtiene el id
var el = document.getElementById(id); //se define la variable &quot;el&quot; igual a nuestro div
el.style.display = (el.style.display == &#39;none&#39;) ? &#39;block&#39; : &#39;none&#39;; //damos un atributo display:none que oculta el div
}
}
window.onload = function(){/*hace que se cargue la función lo que predetermina que div estará oculto hasta llamar a la función nuevamente*/
muestra_oculta(&#39;contenido_a_mostrar&#39;);/* &quot;contenido_a_mostrar&quot; es el nombre que le dimos al DIV */
}
&lt;/script&gt;

&lt;br /&gt;
&lt;table style=&quot;width: 260px;&quot;&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;img alt=&quot;Compartir&quot; border=&quot;0&quot; height=&quot;50&quot; onclick=&quot;muestra_oculta(&#39;contenido_a_mostrar&#39;,1)&quot; onmouseout=&quot;this.src=&#39;https://dl.dropboxusercontent.com/u/28565502/images/redface.png&#39;;&quot; onmouseover=&quot;this.src=&#39;https://dl.dropboxusercontent.com/u/28565502/images/redfacehover.png&#39;;&quot; src=&quot;https://dl.dropboxusercontent.com/u/28565502/images/redface.png&quot; style=&quot;margin-right: 10px;&quot; width=&quot;50&quot; /&gt;

&lt;img alt=&quot;Compartir&quot; border=&quot;0&quot; height=&quot;50&quot; onclick=&quot;muestra_oculta(&#39;contenido_a_mostrar&#39;,2)&quot; onmouseout=&quot;this.src=&#39;https://dl.dropboxusercontent.com/u/28565502/images/twitterRed.png&#39;;&quot; onmouseover=&quot;this.src=&#39;https://dl.dropboxusercontent.com/u/28565502/images/twitterRedhover.png&#39;;&quot; src=&quot;https://dl.dropboxusercontent.com/u/28565502/images/twitterRed.png&quot; style=&quot;margin-right: 10px;&quot; width=&quot;50&quot; /&gt;

&lt;img alt=&quot;Compartir&quot; border=&quot;0&quot; height=&quot;50&quot; onclick=&quot;muestra_oculta(&#39;contenido_a_mostrar&#39;,3)&quot; onmouseout=&quot;this.src=&#39;https://dl.dropboxusercontent.com/u/28565502/images/LinkedIn-Logo.png&#39;;&quot; onmouseover=&quot;this.src=&#39;https://dl.dropboxusercontent.com/u/28565502/images/LinkedIn-Logohover.png&#39;;&quot; src=&quot;https://dl.dropboxusercontent.com/u/28565502/images/LinkedIn-Logo.png&quot; style=&quot;margin-right: 10px;&quot; width=&quot;50&quot; /&gt;

&lt;img alt=&quot;Compartir&quot; border=&quot;0&quot; height=&quot;50&quot; onclick=&quot;muestra_oculta(&#39;contenido_a_mostrar&#39;,4)&quot; onmouseout=&quot;this.src=&#39;https://dl.dropboxusercontent.com/u/28565502/images/rss.png&#39;;&quot; onmouseover=&quot;this.src=&#39;https://dl.dropboxusercontent.com/u/28565502/images/rsshover.png&#39;;&quot; src=&quot;https://dl.dropboxusercontent.com/u/28565502/images/rss.png&quot; style=&quot;margin-right: 10px;&quot; width=&quot;50&quot; /&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br /&gt;
&lt;div id=&quot;contenido_a_mostrar&quot;&gt;
&lt;a href=&quot;https://www.dropbox.com/s/0nceuu6tisjavw0/Fragments.rar?dl=0&quot; target=&quot;_blank&quot;&gt;Descargar archivo&lt;/a&gt;.
&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;</description><link>http://thebestandroide.blogspot.com/2014/11/fragment-en-android.html</link><author>noreply@blogger.com (David)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhMd8d9vdXHfTiHZutBGj0AD1yZhGvwVHgJt5_vtvHA3F6XSs5jw1NpqNHUtYluB1ROxM9bHzIciHFIyet-FspL3mMgZ2PmDMWS5cY6kMt6ZXb9dk_yINwBk0GmWKL25DH7s1R9M3-hQSqe/s72-c/screeenshot0.png" height="72" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-1686662779713559896.post-8645484684260828172</guid><pubDate>Fri, 31 Oct 2014 10:34:00 +0000</pubDate><atom:updated>2014-11-07T17:47:32.803+00:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">android conexion servidores</category><category domain="http://www.blogger.com/atom/ns#">android parsear JSON</category><category domain="http://www.blogger.com/atom/ns#">thebestandroide read JSON</category><category domain="http://www.blogger.com/atom/ns#">thebestandroide twitter</category><category domain="http://www.blogger.com/atom/ns#">thestandroide json</category><title>Comunicación con servidores en plataformas moviles</title><description>&lt;b style=&quot;color: #a5130f;&quot;&gt;&lt;b&gt;&lt;b&gt;&lt;b style=&quot;color: #a5130f;&quot;&gt;&lt;span style=&quot;font-size: x-large;&quot;&gt;&lt;b&gt;Comunicación en Servidores&lt;/b&gt;&lt;/span&gt;&lt;/b&gt;&lt;/b&gt;&lt;/b&gt;&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
Sección del blog de Thebestandroide dedicada a las comunicaciones 
mediante Java y Objective - C con cualquier servidor de formas distintas y con distintos métdos, 
pudiendo enviar o recibir datos.&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;La programáción dedicada a las conexiones a Internet juegan un papel muy importante en esta época en las que guardamos mucha documentación personal en la nube o para acceder a cualquier recurso que esté colgado en la red.&lt;/span&gt;&lt;br /&gt;
&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/AVvXsEjZ0wM5LBAuZjtTTkkBhcvVZUnhdkoT8RdjjAm2lhIe9aKpJOOIz4TEPXHiAuFbbKL4pzCIgcu6PEev8c15prJzWRpdQM21PVxpd06SK-7pNrNAFsWXLrvtC_au3e-lXJn3uyJMTRYPWVXF/s1600/cafeses.jpg&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/AVvXsEjZ0wM5LBAuZjtTTkkBhcvVZUnhdkoT8RdjjAm2lhIe9aKpJOOIz4TEPXHiAuFbbKL4pzCIgcu6PEev8c15prJzWRpdQM21PVxpd06SK-7pNrNAFsWXLrvtC_au3e-lXJn3uyJMTRYPWVXF/s1600/cafeses.jpg&quot; height=&quot;265&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
Esta sección está echa con el objetivo de tener un repositorio de código orientado a programación Android e iOS, y soy partidario de la libre información, así que lo comparto con todos vosotros para darle un fin mayor que el beneficio profesional personal único.&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;i&gt;&lt;br /&gt;&lt;/i&gt;&lt;/span&gt;
&lt;span class=&quot;post-content&quot; style=&quot;display: block; overflow: hidden; width: 660px;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;i&gt;Sé conservador en lo que haces, sé liberal en lo que aceptas de otros.
&lt;/i&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-size: xx-small;&quot;&gt;Jon Postel, máxima de diseño de protocolos de Red del IETF
&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEir7uKAyDkqe7RZVhsH0ERfgYrhQK1FYv7BCJUZ4m3GXjqfLbqM-KsDXDALwj8cqDrA6qgVBogrsP2WTcmq_Jm_9PN8Xe9QngLQO6WA54zTT5JYrS9JTe_4nHCPtedE8Pq9lSpz0f5s2f68/s1600/iOS_Android_server.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/AVvXsEir7uKAyDkqe7RZVhsH0ERfgYrhQK1FYv7BCJUZ4m3GXjqfLbqM-KsDXDALwj8cqDrA6qgVBogrsP2WTcmq_Jm_9PN8Xe9QngLQO6WA54zTT5JYrS9JTe_4nHCPtedE8Pq9lSpz0f5s2f68/s1600/iOS_Android_server.png&quot; height=&quot;148&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: x-large;&quot;&gt;Comunicación con servers desde Android e iOS&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;b style=&quot;color: #a5130f;&quot;&gt;&lt;b&gt;&lt;b&gt;&lt;b style=&quot;color: #a5130f;&quot;&gt;
&lt;span style=&quot;font-size: x-large;&quot;&gt;&lt;b&gt;ANDROID&lt;/b&gt;&lt;/span&gt;&lt;/b&gt;&lt;/b&gt;&lt;/b&gt;&lt;/b&gt;&lt;br /&gt;
&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/AVvXsEgJXr2VfSZNlfYL6W-S81eTZjQq5d1kx5ZKba-NvzHyMaOhQQtUQZLGmxNU1VbdSna6WFkxPiAhc0ueW9dwI-eeNpXSrG61aFs0VVleQDU3ERLWyL8TfH3UMc3GU5NMXXYo2PfqeG4jlQEv/s1600/screenshot0.jpg&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/AVvXsEgJXr2VfSZNlfYL6W-S81eTZjQq5d1kx5ZKba-NvzHyMaOhQQtUQZLGmxNU1VbdSna6WFkxPiAhc0ueW9dwI-eeNpXSrG61aFs0VVleQDU3ERLWyL8TfH3UMc3GU5NMXXYo2PfqeG4jlQEv/s1600/screenshot0.jpg&quot; height=&quot;200&quot; width=&quot;191&quot; /&gt;&amp;nbsp;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;ul&gt;
&lt;li&gt;&lt;b style=&quot;color: #a5130f;&quot;&gt;&lt;b&gt;&lt;b&gt;&lt;b style=&quot;color: #a5130f;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;b&gt;Trabajando desde mi aplicación Android con JSON&lt;/b&gt;&lt;/span&gt;&lt;/b&gt;&lt;/b&gt;&lt;/b&gt;&lt;/b&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;ul&gt;
&lt;/ul&gt;
&lt;ol&gt;
&lt;li&gt;&lt;a href=&quot;http://thebestandroide.blogspot.com.es/2014/11/crear-y-leer-json-desde-android.html&quot; target=&quot;_blank&quot;&gt;&lt;b style=&quot;color: #a5130f;&quot;&gt;&lt;b&gt;&lt;b&gt;&lt;span style=&quot;color: black;&quot;&gt;Crear y leer un archivo JSON&lt;/span&gt;&lt;/b&gt;&lt;/b&gt;&lt;/b&gt;&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;ul&gt;
&lt;/ul&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;b style=&quot;color: #a5130f;&quot;&gt;&lt;b&gt;&lt;b&gt;&lt;b style=&quot;color: #a5130f;&quot;&gt;&lt;span style=&quot;font-size: x-large;&quot;&gt;&lt;b&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgay-kecRRM4J0V-SKKoMNrmrdi5F9-H3Bn1_UWNKkClRQYjTmvEsUrS1L8f2O77JXhXTqBVW3EK0t57Ou_neWYrfS-6y5gs7Gmy3jlSNXkiWklYswCfy9gdWhcxHwem2OnbWADRbNb16gZ/s1600/asdf.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/AVvXsEgay-kecRRM4J0V-SKKoMNrmrdi5F9-H3Bn1_UWNKkClRQYjTmvEsUrS1L8f2O77JXhXTqBVW3EK0t57Ou_neWYrfS-6y5gs7Gmy3jlSNXkiWklYswCfy9gdWhcxHwem2OnbWADRbNb16gZ/s1600/asdf.png&quot; height=&quot;148&quot; width=&quot;200&quot; /&gt;&lt;/a&gt;&lt;/b&gt;&lt;/span&gt;&lt;/b&gt;&lt;/b&gt;&lt;/b&gt;&lt;/b&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;&lt;b style=&quot;color: #a5130f;&quot;&gt;&lt;b&gt;&lt;b&gt;&lt;b style=&quot;color: #a5130f;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;b&gt;&amp;nbsp;Mi aplicación Android con Twitter&lt;/b&gt;&lt;/span&gt;&lt;/b&gt;&lt;/b&gt;&lt;/b&gt;&lt;/b&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;ol&gt;
&lt;li&gt;&lt;a href=&quot;http://thebestandroide.blogspot.com.es/2014/11/crear-aplicacion-twitter-para-android.html&quot; target=&quot;_blank&quot;&gt;&lt;b&gt;Mi aplicación Android con Twitter : Hacer aplicación Twitter y conseguir claves&lt;/b&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://thebestandroide.blogspot.com.es/2014/11/mi-aplicacion-android-con-twitter-feed.html&quot; target=&quot;_blank&quot;&gt;&lt;b&gt;Mi aplicación Android con Twitter : Feed de Twitter&lt;/b&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://thebestandroide.blogspot.com.es/2014/11/mi-aplicacion-android-con-twitter.html&quot; target=&quot;_blank&quot;&gt;&lt;b&gt;Mi aplicación Android con Twitter : Cómo escribir un tweet autentificandonos con la cabecera de la conexión http&lt;/b&gt;&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;b style=&quot;color: #a5130f;&quot;&gt;&lt;b&gt;&lt;b&gt;
&lt;/b&gt;&lt;/b&gt;&lt;/b&gt;
&lt;br /&gt;
&lt;ul style=&quot;color: black; font-weight: normal;&quot;&gt;&lt;b style=&quot;color: #a5130f;&quot;&gt;&lt;b&gt;&lt;b&gt;&lt;b style=&quot;color: #a5130f;&quot;&gt;
&lt;/b&gt;&lt;/b&gt;&lt;/b&gt;&lt;/b&gt;&lt;/ul&gt;
&lt;b style=&quot;color: #a5130f;&quot;&gt;&lt;b&gt;&lt;b&gt;&lt;b style=&quot;color: #a5130f;&quot;&gt;
&lt;span style=&quot;font-size: x-large;&quot;&gt;&lt;b&gt;iOS&lt;/b&gt;
&lt;/span&gt;&lt;/b&gt;&lt;/b&gt;&lt;/b&gt;&lt;/b&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: x-large;&quot;&gt;&lt;b style=&quot;color: #a5130f;&quot;&gt;&lt;b&gt;&lt;b&gt;
&lt;/b&gt;&lt;/b&gt;&lt;/b&gt;&lt;/span&gt;
&lt;b style=&quot;color: #a5130f;&quot;&gt;&lt;b&gt;&lt;b&gt;
&lt;/b&gt;&lt;/b&gt;&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
ESPACIO EN CONSTRUCCION, DISCULPEN LAS MOLESTIAS&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&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/AVvXsEhVt_EQ-8UaBF9U2qmWEYgFpOJqmj7j6xbSxCEx1Ngxk0u8REg3H1zrR7kagdh4C8h3HnVBFi_3CuqEGYNmcSe_ghPDHpRlgbdWma1PzEzqm8P71wnVBk9pPEFVNRB0azwUazPi4FFhMPod/s1600/logo_chico.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/AVvXsEhVt_EQ-8UaBF9U2qmWEYgFpOJqmj7j6xbSxCEx1Ngxk0u8REg3H1zrR7kagdh4C8h3HnVBFi_3CuqEGYNmcSe_ghPDHpRlgbdWma1PzEzqm8P71wnVBk9pPEFVNRB0azwUazPi4FFhMPod/s1600/logo_chico.png&quot; height=&quot;247&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;</description><link>http://thebestandroide.blogspot.com/2014/10/comunicacion-con-servidores-en.html</link><author>noreply@blogger.com (David)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjZ0wM5LBAuZjtTTkkBhcvVZUnhdkoT8RdjjAm2lhIe9aKpJOOIz4TEPXHiAuFbbKL4pzCIgcu6PEev8c15prJzWRpdQM21PVxpd06SK-7pNrNAFsWXLrvtC_au3e-lXJn3uyJMTRYPWVXF/s72-c/cafeses.jpg" height="72" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-1686662779713559896.post-4105746036233368624</guid><pubDate>Tue, 28 Oct 2014 21:30:00 +0000</pubDate><atom:updated>2014-10-28T21:30:00.939+00:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">aprender asp.net</category><category domain="http://www.blogger.com/atom/ns#">asp.net</category><category domain="http://www.blogger.com/atom/ns#">thebestandroide asp.net</category><category domain="http://www.blogger.com/atom/ns#">tutorial asp.net mvc</category><title>Curso Express para aprender ASP.Net en 7 días</title><description>&lt;span style=&quot;font-size: x-large;&quot;&gt;Curso Express ASP.Net en arquitectura MVC5&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&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/AVvXsEh8M0SqNK0zGPiaq1zZaMbKWZEq4RTS9xipbNb-_9BG-v1-wtA74V5xwjVN1-fhpPjwD5MjQw9ladWN_hfXOMvulGTP49UW0YyR8jswLTTBy0QQ1035uzPmi9Vw3ssoDeg8eudVDaSMhqHA/s1600/%C3%ADndice.jpg&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/AVvXsEh8M0SqNK0zGPiaq1zZaMbKWZEq4RTS9xipbNb-_9BG-v1-wtA74V5xwjVN1-fhpPjwD5MjQw9ladWN_hfXOMvulGTP49UW0YyR8jswLTTBy0QQ1035uzPmi9Vw3ssoDeg8eudVDaSMhqHA/s1600/%C3%ADndice.jpg&quot; height=&quot;320&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
Hola developers, entre distintas entrevistas de curros, me he tenido que actualizar un poquito, que hacía bastante que no lo tocaba. Dejo aquí un tutorial muy interesante y eficiente para aprender ASP.Net en poquito tiempo. Espero que os sirva!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&lt;a href=&quot;http://www.codeproject.com/Articles/207797/Learn-MVC-Model-View-Controller-step-by-step-in&quot;&gt;http://www.codeproject.com/Articles/207797/Learn-MVC-Model-View-Controller-step-by-step-in&lt;/a&gt;</description><link>http://thebestandroide.blogspot.com/2014/10/curso-express-para-aprender-aspnet-en-7.html</link><author>noreply@blogger.com (David)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh8M0SqNK0zGPiaq1zZaMbKWZEq4RTS9xipbNb-_9BG-v1-wtA74V5xwjVN1-fhpPjwD5MjQw9ladWN_hfXOMvulGTP49UW0YyR8jswLTTBy0QQ1035uzPmi9Vw3ssoDeg8eudVDaSMhqHA/s72-c/%C3%ADndice.jpg" height="72" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-1686662779713559896.post-2387147829046747379</guid><pubDate>Thu, 02 Oct 2014 00:30:00 +0000</pubDate><atom:updated>2014-10-05T16:52:03.284+01:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">acceder directorio documents</category><category domain="http://www.blogger.com/atom/ns#">developer iOS</category><category domain="http://www.blogger.com/atom/ns#">ejercicio iOS</category><category domain="http://www.blogger.com/atom/ns#">iOS NSFileManager</category><category domain="http://www.blogger.com/atom/ns#">thebestandroide ejercicios ios</category><category domain="http://www.blogger.com/atom/ns#">XCode acceder directorio documents</category><category domain="http://www.blogger.com/atom/ns#">xcode Documents</category><title>iOS : Ejercicio 23. Acceder al directorio Documents de nuestro iPhone</title><description>&lt;br /&gt;
&lt;a href=&quot;http://thebestandroide.blogspot.com.es/&quot;&gt;&lt;span style=&quot;color: #a5130f;&quot;&gt;Blog &lt;/span&gt;&lt;/a&gt;
&lt;span style=&quot;color: #a5130f;&quot;&gt;&lt;a href=&quot;http://thebestandroide.blogspot.com.es/2014/07/iOS-aprende-ejercicios.html&quot;&gt;&amp;gt;Lista ejercicios &amp;gt;&amp;nbsp;&lt;/a&gt;&lt;/span&gt;
&lt;span style=&quot;color: #a5130f;&quot;&gt;&lt;b&gt;Ejercicio 23&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&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/AVvXsEh7rt8mF_uyaVj70oeocAkIO-cTc5dnJtYrJIIy5dtmtMV3U6sYmVMlomkt6VlMEYaP8EJpgeasnPQII3H6pBUeu98IJJKw1EcI63XP65SQ6FyZMBaSv2pE2r9wM-c84yU6sP-7gUdBgtLj/s1600/cabezote2.jpg&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/AVvXsEh7rt8mF_uyaVj70oeocAkIO-cTc5dnJtYrJIIy5dtmtMV3U6sYmVMlomkt6VlMEYaP8EJpgeasnPQII3H6pBUeu98IJJKw1EcI63XP65SQ6FyZMBaSv2pE2r9wM-c84yU6sP-7gUdBgtLj/s1600/cabezote2.jpg&quot; height=&quot;131&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: x-large;&quot;&gt;Ejercicio 23 : Accediendo al directorio Documents de nuestro proyecto
&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: #a5130f;&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-size: x-large;&quot;&gt;&lt;u&gt;Acceder al directorio de la aplicación:&lt;/u&gt;&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;El directorio de la aplicación nos permiten guardar datos en cuatro lugares distintos :&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;b style=&quot;color: #a5130f;&quot;&gt;DOCUMENTS&lt;/b&gt;&amp;nbsp;: Ubicación principal donde la aplicación guarda sus datos.&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;b style=&quot;color: #a5130f;&quot;&gt;PREFERENCES&lt;/b&gt;&amp;nbsp;: No ha sido creado para manipular directamente los archivos.&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;b style=&quot;color: #a5130f;&quot;&gt;CACHES&lt;/b&gt;&amp;nbsp;: Guarda temporalmente los archivos que tienen que existir cuando se abre la aplicación.&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;b style=&quot;color: #a5130f;&quot;&gt;TMP&lt;/b&gt;&amp;nbsp;: Se usa para guardar los archivos temporales innecesarios una vez se abre la aplicación.&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Las aplicaciones son las encargadas y únicas responsables de&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;limpiar el contenido de estas carpetas para que el dispositivo se encuentre optimizado.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;b style=&quot;color: #a5130f;&quot;&gt;NSSearchPathForDIrectoriesInDomains :&lt;/b&gt;&lt;b&gt; &lt;/b&gt;Sirve para obtener la ruta de los directorios&lt;b style=&quot;color: #a5130f;&quot;&gt; Caches y Documents.&lt;/b&gt;&lt;span style=&quot;color: #a5130f;&quot;&gt; &lt;/span&gt;La función devuelve una instancia de&lt;b style=&quot;color: #a5130f;&quot;&gt; NSArray&lt;/b&gt; con el listado de directorios.&lt;/span&gt;&lt;br /&gt;
&lt;b style=&quot;color: #a5130f;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/b&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;b style=&quot;color: #a5130f;&quot;&gt;NSTemporalyDirectory :&lt;/b&gt; Sirve para obtener la ruta de la carpeta&lt;b style=&quot;color: #a5130f;&quot;&gt; tmp.&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;b style=&quot;color: #a5130f;&quot;&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;b style=&quot;color: #a5130f;&quot;&gt;stringByAppendingPathComponent:@&quot;Datos.dat&quot; : &lt;/b&gt;Nos permite acceder a Datos.dat &amp;nbsp;contenido en un directorio en concreto.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;b style=&quot;color: #a5130f;&quot;&gt;&lt;span style=&quot;font-size: x-large;&quot;&gt;&lt;u&gt;CLASE NSFileManager&lt;/u&gt;&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Sólo puede haber una instancia única durante el ciclo de vida de la aplicación. Esta es la clase que nos permite manipular los archivos contenidos en los directorios de la aplicación.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Una vez leida esta pequeña introducción, vamos a empezar con el ejercicio.&lt;/span&gt;&lt;span style=&quot;font-size: large;&quot;&gt;Comenzamos agregando una nueva clase de &lt;b&gt;Objective C&lt;/b&gt; que herede de &lt;/span&gt;&lt;b style=&quot;color: #a5130f;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;NSObject&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;font-size: large;&quot;&gt;,hay que destacar que si hay alguna referencia a outlets no funcionará.Además hacemos que herede de &lt;/span&gt;&lt;b style=&quot;color: #a5130f;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;NSCoding&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&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/AVvXsEgj9pf7M9dMfPXfZcASEZdtgN2U5I1D2PBESjVzvgLCuHPDvNiBOorhoSVGoXofcAL-NqBXH-4vwQiCjfgZRbd_VUsc5SzLVvnQuZv0j4x70jK7tiFJJeds7XMylWZ0kSBvOwkNvC2_OL3v/s1600/screenshot1.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/AVvXsEgj9pf7M9dMfPXfZcASEZdtgN2U5I1D2PBESjVzvgLCuHPDvNiBOorhoSVGoXofcAL-NqBXH-4vwQiCjfgZRbd_VUsc5SzLVvnQuZv0j4x70jK7tiFJJeds7XMylWZ0kSBvOwkNvC2_OL3v/s1600/screenshot1.png&quot; height=&quot;271&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&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/AVvXsEjMyZqKr5RD2Kyycv6HC4LyjK6SL4FzK57QlA0IvZ6bWTnmm_KYGeASBdn1KjTIpjVHKERtSq1pMXz27z3-RqOHdT1ymDSN7IE98MJZXkUw4UFN05-LnVDS29oPB0L8bqsJVv8UR3iAjcdl/s1600/screenshot2.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/AVvXsEjMyZqKr5RD2Kyycv6HC4LyjK6SL4FzK57QlA0IvZ6bWTnmm_KYGeASBdn1KjTIpjVHKERtSq1pMXz27z3-RqOHdT1ymDSN7IE98MJZXkUw4UFN05-LnVDS29oPB0L8bqsJVv8UR3iAjcdl/s1600/screenshot2.png&quot; height=&quot;270&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;En el .h creamos 2 variables para almacenar los datos, una para el nombre y otra para el teléfono.
&lt;/span&gt;&lt;br /&gt;
&lt;b style=&quot;color: #a5130f;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;NSCoding&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&amp;nbsp;nos obliga a usar dos métodos de instancia &lt;b&gt;encodeWithCoder&lt;/b&gt; y &lt;b&gt;initWithCoder&lt;/b&gt;, cada uno de estos métodos codifican y decodifican sus propiedades. Para que quede más claro es como crear una especie de &quot;almacen&quot;.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Un objeto puede recibir estos métodos cualquier número de veces. &lt;b&gt;initWithCoder&lt;/b&gt; instruye al objeto para inicializar a partir de datos del codificador proporcionado sustituyendo a cualquier otro método de inicialización y sólo se envía una vez al objeto.
&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
.h
&lt;br /&gt;
&lt;pre class=&quot;brush: objc;&quot;&gt;//  Datos.h
//  Documents
//
//  Created by makone moreno on 20/09/14.
//  Copyright (c) 2014 makone moreno. All rights reserved.
//
#import &lt;foundation oundation.h=&quot;&quot;&gt;
@interface Datos : NSObject &lt;nscoding&gt;
@property (nonatomic,strong) NSString *nombre;
@property (nonatomic,strong) NSString *telefono;

@end
&lt;/nscoding&gt;&lt;/foundation&gt;&lt;/pre&gt;
&lt;br /&gt;
.m
&lt;br /&gt;
&lt;pre class=&quot;brush: objc;&quot;&gt;//  Datos.m
//  Documents
//
//  Created by makone moreno on 20/09/14.
//  Copyright (c) 2014 makone moreno. All rights reserved.
//
#import &quot;Datos.h&quot;
@implementation Datos

@synthesize nombre;
@synthesize telefono;

//METODO PARA  INICIALIZARLAS, SUPERCLASE
-(id)initWithCoder:(NSCoder *)aDecoder{
    if (self = [super init]){
        nombre = [aDecoder decodeObjectForKey:@&quot;nombre&quot;];
        telefono = [aDecoder decodeObjectForKey:@&quot;telefono&quot;];
    }
    return self;
}

//METODO QUE SIRVE PARA CODIFICAR LAS VARIABLES DEL OBJETO
- (void)encodeWithCoder:(NSCoder *)aCoder{
    [aCoder encodeObject:nombre forKey:@&quot;nombre&quot;];
    [aCoder encodeObject:telefono forKey:@&quot;telefono&quot;];
    
}
@end
&lt;/pre&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Abrimos nuestro storyboard e insertamos un botón, creamos la conexión y creamos un NSArray para guardar los contactos del telefono.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&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/AVvXsEiq_Hb9LEu5fQL0s8JubsPk4JybWMFoCbnvOalt_O22ICHzFcQqeRcofucvOVaoeAVC94RKbwRrkt72l8w7Z4YcdmJkZ_K9LC19OOOBqrQMl_OBd0pO9Ot7pnvc2LubIeQ749Wwi75x1yp-/s1600/screenshot3.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/AVvXsEiq_Hb9LEu5fQL0s8JubsPk4JybWMFoCbnvOalt_O22ICHzFcQqeRcofucvOVaoeAVC94RKbwRrkt72l8w7Z4YcdmJkZ_K9LC19OOOBqrQMl_OBd0pO9Ot7pnvc2LubIeQ749Wwi75x1yp-/s1600/screenshot3.png&quot; height=&quot;446&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
.H
&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush: objc;&quot;&gt;//  ViewController.h
//  Documents
//
//  Created by makone moreno on 20/09/14.
//  Copyright (c) 2014 ___FULLUSERNAME___. All rights reserved.
//

#import &lt;uikit it.h=&quot;&quot;&gt;
#import &quot;Datos.h&quot;

@interface ViewController : UIViewController
@property (strong, nonatomic)NSArray *lista;
- (IBAction)BotonGuardar:(id)sender;
@end
&lt;/uikit&gt;&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
.M
&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush: objc;&quot;&gt;//  ViewController.m
//  Documents
//
//  Created by makone moreno on 20/09/14.
//  Copyright (c) 2014 ___FULLUSERNAME___. All rights reserved.
//

#import &quot;ViewController.h&quot;

@interface ViewController ()

@end

@implementation ViewController
@synthesize lista;++
- (void)viewDidLoad
{
    [super viewDidLoad];
    //OBJETO PARA ALMACENAR RUTA
 NSArray *ruta= NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    //RUTA DOCUMENTS
    NSString *directorioDocuments = [ruta objectAtIndex:0];
    //BUSCAMOS EL ARCHIVO DatosContacto.dat
    NSString *rutaArchivo = [directorioDocuments stringByAppendingPathComponent:@&quot;DatosContacto.dat&quot;];
    
    //MENSAJE PARA SABER SI EL ARCHIVO EXISTE
    if([[NSFileManager defaultManager] fileExistsAtPath:rutaArchivo]==NO){
        UIAlertView *msgError = [[UIAlertView alloc] initWithTitle:@&quot;DatosContacto.dat no encontrado&quot; message:@&quot;Creandolo...&quot; delegate:nil cancelButtonTitle:@&quot;Ok&quot; otherButtonTitles:nil, nil];
        
        [msgError show];
        //CONTACTO1
        Datos *d1 = [[Datos alloc]init];
        d1.nombre = @&quot;Paca&quot;;
        d1.telefono = @&quot;666666666&quot;;
        //CONTACTO2
        Datos *d2 = [[Datos alloc]init];
        d2.nombre = @&quot;Eugenia&quot;;
        d2.telefono = @&quot;777777777&quot;;
        //CONTACTO3
        Datos *d3 = [[Datos alloc]init];
        d3.nombre = @&quot;Atapuerca&quot;;
        d3.telefono = @&quot;888888888&quot;;
        
        lista = [NSArray arrayWithObjects:d1,d2,d3, nil];

    }else{
        //SI EL ARCHIVO EXISTE NO HAY QUE CREARLO, SIMPLEMENTE RECOGEMOS LOS CONTACTOS
        lista = [NSKeyedUnarchiver unarchiveObjectWithFile:rutaArchivo];
        //CREAMOS MENSAJE
        NSString *mensaje = [NSString stringWithFormat:@&quot;Cargados %d objetos&quot;, [lista count]];
        //VENTANA DE AVISO
        UIAlertView *toast= [[UIAlertView alloc] initWithTitle:@&quot;Archivo encontrado!&quot; message:mensaje delegate:nil cancelButtonTitle:@&quot;OK&quot; otherButtonTitles:nil, nil];
        [toast show];
    }
}
- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
- (IBAction)BotonGuardar:(id)sender {
    NSArray *ruta = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    //RUTA DOCUMENTS
    NSString *directorioDocuments = [ruta objectAtIndex:0];
    //BUSCAMOS EL ARCHIVO DatosContacto.dat
    NSString *rutaArchivo = [directorioDocuments stringByAppendingPathComponent:@&quot;DatosContacto.dat&quot;];
    //ALMACENAMOS EN UNA VARIABLE BOOLEANA EL RESULTADO DE SI SE HA ENCONTRADO O NO EL ARCHIVO
    BOOL result = [NSKeyedArchiver archiveRootObject:lista toFile:rutaArchivo];
    if (result == YES) {
        UIAlertView *msgError = [[UIAlertView alloc] initWithTitle:@&quot;El archivo ya ha sido guardado&quot; message:@&quot;Creandolo...&quot; delegate:nil cancelButtonTitle:@&quot;Ok&quot; otherButtonTitles:nil, nil];
   [msgError show];
    }else{
        UIAlertView *msgError = [[UIAlertView alloc] initWithTitle:@&quot;Error al guardar el archivo&quot; message:@&quot;&quot; delegate:nil cancelButtonTitle:@&quot;Ok&quot; otherButtonTitles:nil, nil];
   [msgError show];
    }
}
@end
&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Bien, vemos el resultado, la primera vez que se ejecuta la aplicación, no está creado el archivo, entonces :&lt;/span&gt;&lt;br /&gt;
&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/AVvXsEgGKwQ1M0PPwkrmTJC9ZrxFqwBNr4uuDA9E4vOPRy3kzussC-qIlI5SyqoDDQYYDaavV5pg6IqDod-8Tdzdf7UYs8ltR7NXzLLe-ze_XwtAbeH9wQK204fyxFIzHW6WoQWTxqGmWfL52W0s/s1600/screenshot4.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/AVvXsEgGKwQ1M0PPwkrmTJC9ZrxFqwBNr4uuDA9E4vOPRy3kzussC-qIlI5SyqoDDQYYDaavV5pg6IqDod-8Tdzdf7UYs8ltR7NXzLLe-ze_XwtAbeH9wQK204fyxFIzHW6WoQWTxqGmWfL52W0s/s1600/screenshot4.png&quot; height=&quot;400&quot; width=&quot;251&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Si pulsamos en el botón guardar, veremos esto :&lt;/span&gt;&lt;br /&gt;
&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/AVvXsEjJotKvWaCxb0dicrI-g9Odq6g48aqCKQPVIjflRC18zmB6z9DQSvOjAbZ_GhRlTFG3bCK_xdT7nHcz83nUMXHQFz1ciKxBQX2gmpMTtodr3mYA8Z531IzQixnNK84UKcLiJLw3H9J2Ug2b/s1600/screenshot5.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/AVvXsEjJotKvWaCxb0dicrI-g9Odq6g48aqCKQPVIjflRC18zmB6z9DQSvOjAbZ_GhRlTFG3bCK_xdT7nHcz83nUMXHQFz1ciKxBQX2gmpMTtodr3mYA8Z531IzQixnNK84UKcLiJLw3H9J2Ug2b/s1600/screenshot5.png&quot; height=&quot;400&quot; width=&quot;246&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Y por último, si volvemos a ejecutar la aplicación, veremos que ya se ha creado el archivo anteriormente :&lt;/span&gt;&lt;br /&gt;
&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/AVvXsEj1xATJEe76obIgarSj-W0o6IcWGKEuS0bszcYCZquUMm8QuSfgVTW_sDRxA_hHW_bNv4fJEyVmsB6EfJF7blsSXY_pPMYFi7A_cGRdr7X_mE-ZmcbPipl5U9Ov2gIAhUbYboTwsJn1so67/s1600/screenshot6.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/AVvXsEj1xATJEe76obIgarSj-W0o6IcWGKEuS0bszcYCZquUMm8QuSfgVTW_sDRxA_hHW_bNv4fJEyVmsB6EfJF7blsSXY_pPMYFi7A_cGRdr7X_mE-ZmcbPipl5U9Ov2gIAhUbYboTwsJn1so67/s1600/screenshot6.png&quot; height=&quot;400&quot; width=&quot;252&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;script language=&quot;JavaScript&quot;&gt;
function muestra_oculta(id,tipo){
 var resultado=tipo
 var dir = document.location.href;
 var tit = document.title;
 var tit2 = encodeURIComponent(tit);
 var url =&quot;&quot;;
if(resultado==1){
 var url =&quot;http://www.facebook.com/share.php?u=&quot;+dir+&quot;&amp;t=&quot;+tit2
 window.open(url, &#39;TheBestAndroide&#39;);
}
if(resultado==2){
  var url =&quot;http://twitter.com/home?status=Estoy en &quot;+dir+&quot; leyendo &quot;+tit2
  window.open(url, &#39;TheBestAndroide&#39;);
}
if(resultado==3){
 var url =&quot;http://www.linkedin.com/shareArticle?mini=true&amp;url=&quot;+dir+&quot;&amp;title=&quot;+tit2+&quot;&amp;source=http://thebestandroide.blogspot.com.es/&quot;;
  window.open(url, &#39;TheBestAndroide&#39;);
}
if(resultado==4){
  var url =&quot;http://feeds.feedburner.com/Thebestandroide&quot;
  window.open(url, &#39;TheBestAndroide&#39;);
}

if (document.getElementById){ //se obtiene el id
var el = document.getElementById(id); //se define la variable &quot;el&quot; igual a nuestro div
el.style.display = (el.style.display == &#39;none&#39;) ? &#39;block&#39; : &#39;none&#39;; //damos un atributo display:none que oculta el div
}
}
window.onload = function(){/*hace que se cargue la función lo que predetermina que div estará oculto hasta llamar a la función nuevamente*/
muestra_oculta(&#39;contenido_a_mostrar&#39;);/* &quot;contenido_a_mostrar&quot; es el nombre que le dimos al DIV */
}
&lt;/script&gt;

&lt;br /&gt;
&lt;table style=&quot;width: 260px;&quot;&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;img alt=&quot;Compartir&quot; border=&quot;0&quot; height=&quot;50&quot; onclick=&quot;muestra_oculta(&#39;contenido_a_mostrar&#39;,1)&quot; onmouseout=&quot;this.src=&#39;https://dl.dropboxusercontent.com/u/28565502/images/redface.png&#39;;&quot; onmouseover=&quot;this.src=&#39;https://dl.dropboxusercontent.com/u/28565502/images/redfacehover.png&#39;;&quot; src=&quot;https://dl.dropboxusercontent.com/u/28565502/images/redface.png&quot; style=&quot;margin-right: 10px;&quot; width=&quot;50&quot; /&gt;

&lt;img alt=&quot;Compartir&quot; border=&quot;0&quot; height=&quot;50&quot; onclick=&quot;muestra_oculta(&#39;contenido_a_mostrar&#39;,2)&quot; onmouseout=&quot;this.src=&#39;https://dl.dropboxusercontent.com/u/28565502/images/twitterRed.png&#39;;&quot; onmouseover=&quot;this.src=&#39;https://dl.dropboxusercontent.com/u/28565502/images/twitterRedhover.png&#39;;&quot; src=&quot;https://dl.dropboxusercontent.com/u/28565502/images/twitterRed.png&quot; style=&quot;margin-right: 10px;&quot; width=&quot;50&quot; /&gt;

&lt;img alt=&quot;Compartir&quot; border=&quot;0&quot; height=&quot;50&quot; onclick=&quot;muestra_oculta(&#39;contenido_a_mostrar&#39;,3)&quot; onmouseout=&quot;this.src=&#39;https://dl.dropboxusercontent.com/u/28565502/images/LinkedIn-Logo.png&#39;;&quot; onmouseover=&quot;this.src=&#39;https://dl.dropboxusercontent.com/u/28565502/images/LinkedIn-Logohover.png&#39;;&quot; src=&quot;https://dl.dropboxusercontent.com/u/28565502/images/LinkedIn-Logo.png&quot; style=&quot;margin-right: 10px;&quot; width=&quot;50&quot; /&gt;

&lt;img alt=&quot;Compartir&quot; border=&quot;0&quot; height=&quot;50&quot; onclick=&quot;muestra_oculta(&#39;contenido_a_mostrar&#39;,4)&quot; onmouseout=&quot;this.src=&#39;https://dl.dropboxusercontent.com/u/28565502/images/rss.png&#39;;&quot; onmouseover=&quot;this.src=&#39;https://dl.dropboxusercontent.com/u/28565502/images/rsshover.png&#39;;&quot; src=&quot;https://dl.dropboxusercontent.com/u/28565502/images/rss.png&quot; style=&quot;margin-right: 10px;&quot; width=&quot;50&quot; /&gt;&amp;nbsp;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;table style=&quot;height: 360px;&quot;&gt;
&lt;tbody&gt;
&lt;tr&gt;
  &lt;td&gt;&lt;img alt=&quot;Thebestandroide&quot; height=&quot;70&quot; src=&quot;https://dl.dropboxusercontent.com/u/28565502/thebestandroide/firma/logoSoloRuedasChico.jpg&quot; width=&quot;70&quot; /&gt; 
  &lt;a href=&quot;http://thebestandroide.blogspot.com.es/2014/07/iOS-aprende-ejercicios.html&quot;&gt;Indice&lt;/a&gt; 
  &lt;/td&gt;
 &lt;td align=&quot;right&quot;&gt;&lt;img alt=&quot;Thebestandroide&quot; height=&quot;70&quot; src=&quot;https://dl.dropboxusercontent.com/u/28565502/thebestandroide/firma/logoSoloRuedasChico.jpg&quot; width=&quot;70&quot; /&gt; 
 
 &lt;a href=&quot;http://thebestandroide.blogspot.com.es/2014/10/ios-ejercicio-22-twitter-facebook-en.html&quot;&gt;Ejercicio anterior&lt;/a&gt; &lt;/td&gt;
  &lt;td align=&quot;right&quot;&gt;&lt;img alt=&quot;Thebestandroide&quot; height=&quot;70&quot; src=&quot;https://dl.dropboxusercontent.com/u/28565502/thebestandroide/firma/logoSoloRuedasChico.jpg&quot; width=&quot;70&quot; /&gt; 
  
 &lt;a href=&quot;https://www/&quot;&gt;Siguiente ejercicio&lt;/a&gt; &lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
</description><link>http://thebestandroide.blogspot.com/2014/10/ios-ejercicio-23-acceder-al-directorio.html</link><author>noreply@blogger.com (David)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh7rt8mF_uyaVj70oeocAkIO-cTc5dnJtYrJIIy5dtmtMV3U6sYmVMlomkt6VlMEYaP8EJpgeasnPQII3H6pBUeu98IJJKw1EcI63XP65SQ6FyZMBaSv2pE2r9wM-c84yU6sP-7gUdBgtLj/s72-c/cabezote2.jpg" height="72" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-1686662779713559896.post-4050190029458285537</guid><pubDate>Wed, 01 Oct 2014 23:30:00 +0000</pubDate><atom:updated>2014-10-05T17:07:08.492+01:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">developer iOS</category><category domain="http://www.blogger.com/atom/ns#">ejercicio iOS</category><category domain="http://www.blogger.com/atom/ns#">iOS boton facebook</category><category domain="http://www.blogger.com/atom/ns#">iOS boton twitter</category><category domain="http://www.blogger.com/atom/ns#">iOS facebook</category><category domain="http://www.blogger.com/atom/ns#">iOS twitter</category><category domain="http://www.blogger.com/atom/ns#">objective C facebook</category><category domain="http://www.blogger.com/atom/ns#">objective C twitter</category><category domain="http://www.blogger.com/atom/ns#">thebestandroide ejercicios ios</category><title>iOS : Ejercicio 22. Twitter &amp; Facebook en nuestro iPhone</title><description>&lt;a href=&quot;http://thebestandroide.blogspot.com.es/&quot;&gt;&lt;span style=&quot;color: #a5130f;&quot;&gt;Blog &lt;/span&gt;&lt;/a&gt;
&lt;span style=&quot;color: #a5130f;&quot;&gt;&lt;a href=&quot;http://thebestandroide.blogspot.com.es/2014/07/iOS-aprende-ejercicios.html&quot;&gt;&amp;gt;Lista ejercicios &amp;gt;&amp;nbsp;&lt;/a&gt;&lt;/span&gt;
&lt;span style=&quot;color: #a5130f;&quot;&gt;&lt;b&gt;Ejercicio 22&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&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/AVvXsEh7rt8mF_uyaVj70oeocAkIO-cTc5dnJtYrJIIy5dtmtMV3U6sYmVMlomkt6VlMEYaP8EJpgeasnPQII3H6pBUeu98IJJKw1EcI63XP65SQ6FyZMBaSv2pE2r9wM-c84yU6sP-7gUdBgtLj/s1600/cabezote2.jpg&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/AVvXsEh7rt8mF_uyaVj70oeocAkIO-cTc5dnJtYrJIIy5dtmtMV3U6sYmVMlomkt6VlMEYaP8EJpgeasnPQII3H6pBUeu98IJJKw1EcI63XP65SQ6FyZMBaSv2pE2r9wM-c84yU6sP-7gUdBgtLj/s1600/cabezote2.jpg&quot; height=&quot;131&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: x-large;&quot;&gt;Ejercicio 22 : Poniendo botones sociales Twitter &amp;amp; Facebook en nuestro iPhone&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: x-large;&quot;&gt;&amp;nbsp; &lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Configuramos cuenta twitter en emulador de XCode, sino no funcionará, también insertamos una cuenta sino, tampoco funcionará.&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
Creamos un nuevo proyecto : single view application. Ahí abrimos el storyboard y añadimos dos botones, yo he insertado dos imágenes de mi blog para ponerlas de background en los botones y además dos labels :
&lt;br /&gt;
&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/AVvXsEiOqOyxQU1r4xKRArSSn9jfZwAFh6Sc9dxdjKPA8iClaeZc1T8i2vLE_d2D2G1gZ4FCpri-qxNi8V1GAAsoo_59UCSjGx0hx-Y0dKAsDi3oqR1UtTkTUFI1b99tNnvUFXdc8qdh3k_eudJE/s1600/Screenshot1.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/AVvXsEiOqOyxQU1r4xKRArSSn9jfZwAFh6Sc9dxdjKPA8iClaeZc1T8i2vLE_d2D2G1gZ4FCpri-qxNi8V1GAAsoo_59UCSjGx0hx-Y0dKAsDi3oqR1UtTkTUFI1b99tNnvUFXdc8qdh3k_eudJE/s1600/Screenshot1.png&quot; height=&quot;400&quot; width=&quot;297&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: x-large;&quot;&gt;&lt;b&gt;&lt;span style=&quot;color: #a5130f;&quot;&gt;Twitter&lt;/span&gt;&lt;/b&gt;&lt;/span&gt; &lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;font-size: x-large;&quot;&gt;Desde la&lt;b&gt; versión 5&lt;/b&gt; de iOS, Apple incluye la integración de Twitter en el sistema operativo de los dispositivos.&lt;/span&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Este framework proporciona una hoja para los tweets que tendremos que usar para que las aplicaciones desarrolladas envien tweets.&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Usaremos una instancia de &lt;span style=&quot;color: #a5130f;&quot;&gt;&lt;b&gt;TWTwitterComposerViewController&lt;/b&gt;&lt;/span&gt;, que tiene una interfad de usuario que permite escribir el mensaje a enviar, así como añadir la ubicación e incluso adjuntar alguna imagen.
Para verificar si se ha llevado a cabo con éxito la operción, usaremos estos métodos, que son booleanos :&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;color: #a5130f;&quot;&gt;&lt;b&gt;setInitialText&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;color: #a5130f;&quot;&gt;&lt;b&gt;addImage&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;color: #a5130f;&quot;&gt;&lt;b&gt;TwiaddUrl&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;color: #a5130f;&quot;&gt;&lt;b&gt;&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Y en el caso de que queramos descartar la hoja de tweets usaremos el método &lt;b&gt;dismissViewControllerAnimated&lt;/b&gt;&lt;/span&gt;
&lt;br /&gt;
&lt;br /&gt;
Establecemos las conexiones de los dos botones y los dos labels, además importamos la libreria de Twitter :&lt;br /&gt;
&lt;br /&gt;
&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/AVvXsEiIEqrp55FqzyM650WF9YckVZuFtRwFmh3xy4PvEGZ6n6tIhZHngngpzroJ-WHrB9xDYtkqqkW3NrUBj88pQK_nJTet3HVJxviN_v-QJP5xzvUj29Ywk4by0HIxWtiuedQN3SKb2SZl_1Pi/s1600/Screenshot2.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/AVvXsEiIEqrp55FqzyM650WF9YckVZuFtRwFmh3xy4PvEGZ6n6tIhZHngngpzroJ-WHrB9xDYtkqqkW3NrUBj88pQK_nJTet3HVJxviN_v-QJP5xzvUj29Ywk4by0HIxWtiuedQN3SKb2SZl_1Pi/s1600/Screenshot2.png&quot; height=&quot;340&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&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/AVvXsEgB5hIR_Kuzbtw9Hw_lsGhAONwGm9pzPOvH3uco41XVTsGFfV2C-sfngbnCjNt9U1S9xa5X0dnCC_9QALsmGbg9kRmzs1tbBzM8xJQkBJAKv8fGeewE_gtIDlBla14KWnqhUfyr21Z7n7BZ/s1600/Screenshot3.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/AVvXsEgB5hIR_Kuzbtw9Hw_lsGhAONwGm9pzPOvH3uco41XVTsGFfV2C-sfngbnCjNt9U1S9xa5X0dnCC_9QALsmGbg9kRmzs1tbBzM8xJQkBJAKv8fGeewE_gtIDlBla14KWnqhUfyr21Z7n7BZ/s1600/Screenshot3.png&quot; height=&quot;640&quot; width=&quot;556&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Y este es el código para escribir un tweet en twitter, he añadido una imágen al proyecto para twittear en twitter:&lt;/span&gt;&lt;br /&gt;
&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/AVvXsEgut1HXEBGXQRH0IWoo6yiB5dwFg9qi-RAa1kHlTI8Bwq2kpgZn-y17EIy8W5-V-e1_UA_Vc5GRTURvCaIoUkFGH5xhHUkuS2Iiz1E6-W4pc1FHzzhvdtK08w_wZEcMLMB44iSJWAbFetuM/s1600/logo_PURO.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/AVvXsEgut1HXEBGXQRH0IWoo6yiB5dwFg9qi-RAa1kHlTI8Bwq2kpgZn-y17EIy8W5-V-e1_UA_Vc5GRTURvCaIoUkFGH5xhHUkuS2Iiz1E6-W4pc1FHzzhvdtK08w_wZEcMLMB44iSJWAbFetuM/s1600/logo_PURO.png&quot; height=&quot;252&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&amp;nbsp;&lt;/span&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
.h&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush: objc;&quot;&gt;//
//  ViewController.h
//  FacebookTwitter
//
//  Copyright (c) 2014 ___FULLUSERNAME___. All rights reserved.
//

#import &lt;uikit it.h=&quot;&quot;&gt;
#import &lt;twitter witter.h=&quot;&quot;&gt;
@interface ViewController : UIViewController
@property (weak, nonatomic) IBOutlet UILabel *labelDisponibleTwitter;
@property (weak, nonatomic) IBOutlet UILabel *labelDisponibleFacebook;
- (IBAction)botonTwitter:(id)sender;
- (IBAction)botonFacebook:(id)sender;
@end
&lt;/twitter&gt;&lt;/uikit&gt;&lt;/pre&gt;
&lt;br /&gt;
.m&lt;br /&gt;
&lt;pre class=&quot;brush: objc;&quot;&gt;//
//  ViewController.m
//  TwitterFacebook
//
//  Created by makone moreno on 15/09/14.
//  Copyright (c) 2014 ___FULLUSERNAME___. All rights reserved.
//
#import &quot;ViewController.h&quot;
@interface ViewController ()
@end

@implementation ViewController
@synthesize labelDisponibleFacebook;
@synthesize labelDisponibleTwitter;
- (void)viewDidLoad
{
    [super viewDidLoad];
    //Si se puede enviar Tweets
    if([TWTweetComposeViewController canSendTweet]){
        labelDisponibleTwitter.text=@&quot;Iniciando servicio&quot;;
    }else{
        labelDisponibleTwitter.text=@&quot;No se puede iniciar el servicio&quot;;
    }
}
- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
- (IBAction)botonTwitter:(id)sender {  if ([TWTweetComposeViewController canSendTweet]==NO) {
    //MENSAJE NO DISPONIBLE
    UIAlertView *mensaje=[[UIAlertView alloc]initWithTitle:@&quot;Servicio no disponible&quot;
                                                   message:@&quot;No se puede realizar la conexion&quot;
                                                  delegate:nil
                                         cancelButtonTitle:@&quot;Ok&quot;
                                         otherButtonTitles:nil, nil];
    [mensaje show];
    //Salimos
    return;
}
    //Sino entra en el if, carga la hoja para escribir el tweet
TWTweetComposeViewController *HOJATWEET=[[TWTweetComposeViewController alloc] init];
    //AÑADO TEXTO
    [HOJATWEET setInitialText:@&quot;Programando en iOS&quot;];
    //AÑADO IMAGEN
    [HOJATWEET addImage:[UIImage imageNamed:@&quot;logo_PURO.png&quot;]];
    //AÑADO URL
    [HOJATWEET addURL:[NSURL URLWithString:@&quot;http//:www.thebestandroide.blogspot.com.es&quot;]];
    [self presentViewController:HOJATWEET animated:YES completion:^{
        //CODIGO A EJECUTAR EN CUANTO SE ENVIE EL TWEET
    }];
}
- (IBAction)botonFacebook:(id)sender {

}

@end
&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
.m

&lt;br /&gt;
&lt;br /&gt;
Ahora al iniciar el emulador:
&lt;br /&gt;
&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/AVvXsEjFSVqCaAUdG_AYtqBnAFtp4pltW63WzZY5I10XL6h46SB5RiOE9RsuUNzewVHbM1NVBzb4OgMjPxA4AYEUBg3hQpousFU4wkPIE8cDgDFJzz4twzyM7WFKXaOycg5169jMOrt-5tAqcUvS/s1600/Screenshot4.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/AVvXsEjFSVqCaAUdG_AYtqBnAFtp4pltW63WzZY5I10XL6h46SB5RiOE9RsuUNzewVHbM1NVBzb4OgMjPxA4AYEUBg3hQpousFU4wkPIE8cDgDFJzz4twzyM7WFKXaOycg5169jMOrt-5tAqcUvS/s1600/Screenshot4.png&quot; height=&quot;400&quot; width=&quot;253&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&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/AVvXsEjJdC200oDWljQFGhJ9DGgPIfMgtZKSHVS77GFOU4R6RY1OHf9CuUBGrJUUZZejeYp49kxMK07kjm3CHhhii6eu46RcPesCERMAbI3yGPmXEhxtiRrIrmknTLYlqkT4_LL0yfoVZLMhc_WG/s1600/Screenshot5.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/AVvXsEjJdC200oDWljQFGhJ9DGgPIfMgtZKSHVS77GFOU4R6RY1OHf9CuUBGrJUUZZejeYp49kxMK07kjm3CHhhii6eu46RcPesCERMAbI3yGPmXEhxtiRrIrmknTLYlqkT4_LL0yfoVZLMhc_WG/s1600/Screenshot5.png&quot; height=&quot;400&quot; width=&quot;252&quot; /&gt;&amp;nbsp;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;br /&gt;
&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/AVvXsEiIEqrp55FqzyM650WF9YckVZuFtRwFmh3xy4PvEGZ6n6tIhZHngngpzroJ-WHrB9xDYtkqqkW3NrUBj88pQK_nJTet3HVJxviN_v-QJP5xzvUj29Ywk4by0HIxWtiuedQN3SKb2SZl_1Pi/s1600/Screenshot2.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/AVvXsEiIEqrp55FqzyM650WF9YckVZuFtRwFmh3xy4PvEGZ6n6tIhZHngngpzroJ-WHrB9xDYtkqqkW3NrUBj88pQK_nJTet3HVJxviN_v-QJP5xzvUj29Ywk4by0HIxWtiuedQN3SKb2SZl_1Pi/s1600/Screenshot2.png&quot; height=&quot;170&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&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/AVvXsEjABatEYIVAXPwBQziu2V9eMJw51TwFVIsCiY4T21ByBqDU1CZ0awlpU3zNmArJuvs-QQsoEaVTu5Dr21w1SoWq778AI3f3QjJ_RIMAowMyn0v5ol8JxTaMnElIClZ0BHnKh3NjmwJNrUEx/s1600/Screenshot6.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/AVvXsEjABatEYIVAXPwBQziu2V9eMJw51TwFVIsCiY4T21ByBqDU1CZ0awlpU3zNmArJuvs-QQsoEaVTu5Dr21w1SoWq778AI3f3QjJ_RIMAowMyn0v5ol8JxTaMnElIClZ0BHnKh3NjmwJNrUEx/s1600/Screenshot6.png&quot; height=&quot;255&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: #a5130f; font-size: x-large;&quot;&gt;&lt;b&gt;Facebook&lt;/b&gt;&lt;/span&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;El método es muy similar al de twitter, pero en este caso no hay que añadir &lt;b&gt;ningún framework&lt;/b&gt;, aun así hay que &lt;b&gt;configurar nuevamente el emulador para que tenga una cuenta en facebook&lt;/b&gt;, después sólo hay que rellenar el botón correspondiente a la conexión del botón de facebook,veamos como queda :
&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
.m
&lt;br /&gt;
&lt;pre class=&quot;brush: objc;&quot;&gt;- (IBAction)botonFacebook:(id)sender {
    //Si se puede enviar post en facebook
    if([SLComposeViewController isAvailableForServiceType:SLServiceTypeFacebook]==NO){
        //MENSAJE NO DISPONIBLE
        UIAlertView *mensaje=[[UIAlertView alloc]initWithTitle:@&quot;Servicio no disponible&quot;
                                                       message:@&quot;No se puede realizar la conexion&quot;
                                                      delegate:nil
                                             cancelButtonTitle:@&quot;Ok&quot;
                                             otherButtonTitles:nil, nil];
        [mensaje show];
        //Salimos
        return;
    }
    SLComposeViewController *HOJAFACE =[SLComposeViewController composeViewControllerForServiceType:SLServiceTypeFacebook];
    //AÑADO TEXTO
    [HOJAFACE setInitialText:@&quot;Programando en iOS&quot;];
    //AÑADO IMAGEN
    [HOJAFACE addImage:[UIImage imageNamed:@&quot;logo_PURO.png&quot;]];
    //AÑADO URL
    [HOJAFACE addURL:[NSURL URLWithString:@&quot;http//:www.thebestandroide.blogspot.com.es&quot;]];
    [self presentViewController:HOJAFACE animated:YES completion:^{
        //codigo que se ejecuta segun se ha publicado
    }];
}
&lt;/pre&gt;
&lt;br /&gt;
&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/AVvXsEhSb4zP_h5RQwUbefglmjo85B5SprWchmE718gd0ld4vUrpT_8WbT-OPV7ffIe3HOHLe0ShZekycTGisyhPI0_E0vTO9svkihUOje7xSDx-wMue4e8kz33EHq7R0IiG_7s4rAalkPfc5Uif/s1600/Screenshot7.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/AVvXsEhSb4zP_h5RQwUbefglmjo85B5SprWchmE718gd0ld4vUrpT_8WbT-OPV7ffIe3HOHLe0ShZekycTGisyhPI0_E0vTO9svkihUOje7xSDx-wMue4e8kz33EHq7R0IiG_7s4rAalkPfc5Uif/s1600/Screenshot7.png&quot; height=&quot;400&quot; width=&quot;262&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&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/AVvXsEiW5e3nJeax-AQbdfasGaMSFJ4UNE3pYpQlwSaUjkOZ7gxALIAQdLilouDyj0cFY68iiRd0T-O24W-yHeOXrqt0WnCMWIW4vqeFG0IA7LDDv9bmpFn6q75hxRXXZaEw_yZ_FPrBBCpqNtyL/s1600/Screenshot8.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/AVvXsEiW5e3nJeax-AQbdfasGaMSFJ4UNE3pYpQlwSaUjkOZ7gxALIAQdLilouDyj0cFY68iiRd0T-O24W-yHeOXrqt0WnCMWIW4vqeFG0IA7LDDv9bmpFn6q75hxRXXZaEw_yZ_FPrBBCpqNtyL/s1600/Screenshot8.png&quot; height=&quot;310&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;script language=&quot;JavaScript&quot;&gt;
function muestra_oculta(id,tipo){
 var resultado=tipo
 var dir = document.location.href;
 var tit = document.title;
 var tit2 = encodeURIComponent(tit);
 var url =&quot;&quot;;
if(resultado==1){
 var url =&quot;http://www.facebook.com/share.php?u=&quot;+dir+&quot;&amp;t=&quot;+tit2
 window.open(url, &#39;TheBestAndroide&#39;);
}
if(resultado==2){
  var url =&quot;http://twitter.com/home?status=Estoy en &quot;+dir+&quot; leyendo &quot;+tit2
  window.open(url, &#39;TheBestAndroide&#39;);
}
if(resultado==3){
 var url =&quot;http://www.linkedin.com/shareArticle?mini=true&amp;url=&quot;+dir+&quot;&amp;title=&quot;+tit2+&quot;&amp;source=http://thebestandroide.blogspot.com.es/&quot;;
  window.open(url, &#39;TheBestAndroide&#39;);
}
if(resultado==4){
  var url =&quot;http://feeds.feedburner.com/Thebestandroide&quot;
  window.open(url, &#39;TheBestAndroide&#39;);
}

if (document.getElementById){ //se obtiene el id
var el = document.getElementById(id); //se define la variable &quot;el&quot; igual a nuestro div
el.style.display = (el.style.display == &#39;none&#39;) ? &#39;block&#39; : &#39;none&#39;; //damos un atributo display:none que oculta el div
}
}
window.onload = function(){/*hace que se cargue la función lo que predetermina que div estará oculto hasta llamar a la función nuevamente*/
muestra_oculta(&#39;contenido_a_mostrar&#39;);/* &quot;contenido_a_mostrar&quot; es el nombre que le dimos al DIV */
}
&lt;/script&gt;

&lt;br /&gt;
&lt;table style=&quot;width: 260px;&quot;&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;img alt=&quot;Compartir&quot; border=&quot;0&quot; height=&quot;50&quot; onclick=&quot;muestra_oculta(&#39;contenido_a_mostrar&#39;,1)&quot; onmouseout=&quot;this.src=&#39;https://dl.dropboxusercontent.com/u/28565502/images/redface.png&#39;;&quot; onmouseover=&quot;this.src=&#39;https://dl.dropboxusercontent.com/u/28565502/images/redfacehover.png&#39;;&quot; src=&quot;https://dl.dropboxusercontent.com/u/28565502/images/redface.png&quot; style=&quot;margin-right: 10px;&quot; width=&quot;50&quot; /&gt;

&lt;img alt=&quot;Compartir&quot; border=&quot;0&quot; height=&quot;50&quot; onclick=&quot;muestra_oculta(&#39;contenido_a_mostrar&#39;,2)&quot; onmouseout=&quot;this.src=&#39;https://dl.dropboxusercontent.com/u/28565502/images/twitterRed.png&#39;;&quot; onmouseover=&quot;this.src=&#39;https://dl.dropboxusercontent.com/u/28565502/images/twitterRedhover.png&#39;;&quot; src=&quot;https://dl.dropboxusercontent.com/u/28565502/images/twitterRed.png&quot; style=&quot;margin-right: 10px;&quot; width=&quot;50&quot; /&gt;

&lt;img alt=&quot;Compartir&quot; border=&quot;0&quot; height=&quot;50&quot; onclick=&quot;muestra_oculta(&#39;contenido_a_mostrar&#39;,3)&quot; onmouseout=&quot;this.src=&#39;https://dl.dropboxusercontent.com/u/28565502/images/LinkedIn-Logo.png&#39;;&quot; onmouseover=&quot;this.src=&#39;https://dl.dropboxusercontent.com/u/28565502/images/LinkedIn-Logohover.png&#39;;&quot; src=&quot;https://dl.dropboxusercontent.com/u/28565502/images/LinkedIn-Logo.png&quot; style=&quot;margin-right: 10px;&quot; width=&quot;50&quot; /&gt;

&lt;img alt=&quot;Compartir&quot; border=&quot;0&quot; height=&quot;50&quot; onclick=&quot;muestra_oculta(&#39;contenido_a_mostrar&#39;,4)&quot; onmouseout=&quot;this.src=&#39;https://dl.dropboxusercontent.com/u/28565502/images/rss.png&#39;;&quot; onmouseover=&quot;this.src=&#39;https://dl.dropboxusercontent.com/u/28565502/images/rsshover.png&#39;;&quot; src=&quot;https://dl.dropboxusercontent.com/u/28565502/images/rss.png&quot; style=&quot;margin-right: 10px;&quot; width=&quot;50&quot; /&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br /&gt;
&lt;div id=&quot;contenido_a_mostrar&quot;&gt;
&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;table style=&quot;height: 360px;&quot;&gt;
&lt;tbody&gt;
&lt;tr&gt;
  &lt;td&gt;&lt;img alt=&quot;Thebestandroide&quot; height=&quot;70&quot; src=&quot;https://dl.dropboxusercontent.com/u/28565502/thebestandroide/firma/logoSoloRuedasChico.jpg&quot; width=&quot;70&quot; /&gt; 
  &lt;a href=&quot;http://thebestandroide.blogspot.com.es/2014/07/iOS-aprende-ejercicios.html&quot;&gt;Indice&lt;/a&gt; 
  &lt;/td&gt;
 &lt;td align=&quot;right&quot;&gt;&lt;img alt=&quot;Thebestandroide&quot; height=&quot;70&quot; src=&quot;https://dl.dropboxusercontent.com/u/28565502/thebestandroide/firma/logoSoloRuedasChico.jpg&quot; width=&quot;70&quot; /&gt; 
 
 &lt;a href=&quot;http://thebestandroide.blogspot.com.es/2014/10/ios-ejercicio-21-iuwebview-cargando.html&quot;&gt;Ejercicio anterior&lt;/a&gt; &lt;/td&gt;
  &lt;td align=&quot;right&quot;&gt;&lt;img alt=&quot;Thebestandroide&quot; height=&quot;70&quot; src=&quot;https://dl.dropboxusercontent.com/u/28565502/thebestandroide/firma/logoSoloRuedasChico.jpg&quot; width=&quot;70&quot; /&gt; 
  
 &lt;a href=&quot;http://thebestandroide.blogspot.com.es/2014/10/ios-ejercicio-23-acceder-al-directorio.html&quot;&gt;Siguiente ejercicio&lt;/a&gt; &lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
</description><link>http://thebestandroide.blogspot.com/2014/10/ios-ejercicio-22-twitter-facebook-en.html</link><author>noreply@blogger.com (David)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh7rt8mF_uyaVj70oeocAkIO-cTc5dnJtYrJIIy5dtmtMV3U6sYmVMlomkt6VlMEYaP8EJpgeasnPQII3H6pBUeu98IJJKw1EcI63XP65SQ6FyZMBaSv2pE2r9wM-c84yU6sP-7gUdBgtLj/s72-c/cabezote2.jpg" height="72" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-1686662779713559896.post-6447328592958814764</guid><pubDate>Wed, 01 Oct 2014 22:25:00 +0000</pubDate><atom:updated>2014-10-05T16:42:00.273+01:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">iOS IUWebView load url</category><category domain="http://www.blogger.com/atom/ns#">IUWebView XCode</category><category domain="http://www.blogger.com/atom/ns#">UIWebView html</category><category domain="http://www.blogger.com/atom/ns#">UIWebView javascript</category><category domain="http://www.blogger.com/atom/ns#">UIWebView url</category><title>iOS : Ejercicio 21. IUWebView cargando código HTML, Javascript y URL</title><description>&lt;a href=&quot;http://thebestandroide.blogspot.com.es/&quot;&gt;&lt;span style=&quot;color: #a5130f;&quot;&gt;Blog &lt;/span&gt;&lt;/a&gt;
&lt;span style=&quot;color: #a5130f;&quot;&gt;&lt;a href=&quot;http://thebestandroide.blogspot.com.es/2014/07/iOS-aprende-ejercicios.html&quot;&gt;&amp;gt;Lista ejercicios &amp;gt;&amp;nbsp;&lt;/a&gt;&lt;/span&gt;
&lt;span style=&quot;color: #a5130f;&quot;&gt;&lt;b&gt;Ejercicio 21&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&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/AVvXsEiIWBQxhv7TibBZZPJbSVzCeBDT8gbmzTe7b4HONd33U029BIpx6fBxb250NvhhGq6XlikEEtr9s71216KLQfd5tY1bZP8NRGLep9bnp9hd-6kDHc0FTLOwmwP93P73d7ODJCLAxBomGQWN/s1600/cabezote2.jpg&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/AVvXsEiIWBQxhv7TibBZZPJbSVzCeBDT8gbmzTe7b4HONd33U029BIpx6fBxb250NvhhGq6XlikEEtr9s71216KLQfd5tY1bZP8NRGLep9bnp9hd-6kDHc0FTLOwmwP93P73d7ODJCLAxBomGQWN/s1600/cabezote2.jpg&quot; height=&quot;131&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: x-large;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-size: x-large;&quot;&gt;Ejercicio 21: IUWebView interpretando HTML, Javascript y una URL&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Creamos un proyecto de la forma habitual : create new proyect - Single view application
&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Ahora en nuestro storyboard añadimos un &lt;/span&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;color: #a5130f;&quot;&gt;&lt;b&gt;UIWebView&lt;/b&gt;&lt;/span&gt; y 3 botones, además de poner a cada elemento su conexión pertinente :
&lt;/span&gt;&lt;br /&gt;
&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/AVvXsEgLlXmwoZLy-ZcONJeF-RgWEhaWTdFDAS3Yk3bAiLSWdosNU0NS0I5KHPAYeIn6q1k5i1_K0IW0qZiJicMmtdGPEK5kwgfhOuxYJKRj71vG4hScEtuCP5ItKCCWbRqW-zyC-uaaalwAg_jm/s1600/screenshot1.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/AVvXsEgLlXmwoZLy-ZcONJeF-RgWEhaWTdFDAS3Yk3bAiLSWdosNU0NS0I5KHPAYeIn6q1k5i1_K0IW0qZiJicMmtdGPEK5kwgfhOuxYJKRj71vG4hScEtuCP5ItKCCWbRqW-zyC-uaaalwAg_jm/s1600/screenshot1.png&quot; height=&quot;190&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Bien, ahora le daremos funcionalidad a cada botón, que al pulsarlo, cargue un código &lt;b&gt;html&lt;/b&gt; hecho por nosotros, un código &lt;b&gt;Javascript&lt;/b&gt;, o una &lt;b&gt;URL&lt;/b&gt; de una página externa :&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
.h&lt;br /&gt;
&lt;pre class=&quot;brush: objc;&quot;&gt;//  ViewController.h
//  WebView
//
//  Created by makone moreno on 16/09/14.
//  Copyright (c) 2014 ___FULLUSERNAME___. All rights reserved.
//
#import &lt;uikit it.h=&quot;&quot;&gt;
@interface ViewController : UIViewController
@property (weak, nonatomic) IBOutlet UIWebView *wEb;
- (IBAction)Web:(id)sender;
- (IBAction)Javascript:(id)sender;
- (IBAction)URL:(id)sender;
@end
&lt;/uikit&gt;&lt;/pre&gt;
&lt;br /&gt;
.m&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush: objc;&quot;&gt;//
//  ViewController.m
//  WebView
//
//  Created by makone moreno on 16/09/14.
//  Copyright (c) 2014 ___FULLUSERNAME___. All rights reserved.
//
#import &quot;ViewController.h&quot;

@interface ViewController ()
@end

@implementation ViewController
@synthesize wEb;
- (void)viewDidLoad
{
    [super viewDidLoad];

// Do any additional setup after loading the view, typically from a nib.
}
- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
//BOTON HTML
- (IBAction)Web:(id)sender {
    NSString *codigoHTML=@&quot;&lt;h2&gt;
cODIGO html&lt;/h2&gt;
&lt;div style=&quot;color: blue;&quot;&gt;
Párrafo &lt;b&gt;negrita&lt;/b&gt;&lt;/div&gt;
&quot;;
    [wEb loadHTMLString:codigoHTML baseURL:nil];
}
//BOTON JAVASCRIPT
- (IBAction)Javascript:(id)sender {
    NSString *codigoJavasCript=@&quot;&lt;scri t=&quot;&quot;&gt;alert(&#39;CODIGO JAVASCRIPT&#39;)&lt;/scri&gt;&quot;;
    [wEb loadHTMLString:codigoJavasCript baseURL:nil];
}
//BOTON URL
- (IBAction)URL:(id)sender {
    //MUY IMPORTANTE, SINO PONEMOS EL http:// NO FUNCIONA
    NSURL *url=[[NSURL alloc] initWithString:@&quot;http://www.google.es&quot;];
    NSURLRequest *respuesta=[[NSURLRequest alloc] initWithURL:url];
    [wEb loadRequest:respuesta];
}
@end


&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Es bastante sencillo e intuitivo,simplemente hay que jugar con las propiedades del webView, la que más llama la atención es &lt;span style=&quot;color: #a5130f;&quot;&gt;&lt;b&gt;loadHtmlString&lt;/b&gt;&lt;/span&gt;, que es la que se suele usar en la mayoría de los casos para la carga de contenido, así que por eso comento muy poquito el código.&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&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/AVvXsEikfj8aMqsw6-7SmdfRB4RH3rEQqAg9yJeOmYxIulSn3Hyqu3m2AVcCBl3BR-spOTtKQXdJV_Bl-ipI47oIZ2QKvghMi1Hnrsxh2-uO8rfXqY6il8BD_41RQqzCoI_Azo99VGPSL7HaTB_6/s1600/screenshot2.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/AVvXsEikfj8aMqsw6-7SmdfRB4RH3rEQqAg9yJeOmYxIulSn3Hyqu3m2AVcCBl3BR-spOTtKQXdJV_Bl-ipI47oIZ2QKvghMi1Hnrsxh2-uO8rfXqY6il8BD_41RQqzCoI_Azo99VGPSL7HaTB_6/s1600/screenshot2.png&quot; height=&quot;640&quot; width=&quot;406&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&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/AVvXsEgZKGnoNdHSKt4cOdfSUytKMlRUHQzn1oGWEgogkuCeGRKGwU4d455d0BiSCpqO9d7WioSgHltCApxl2cNWlUyf4iMoyyqEr3A38I5eWqb2d2Rv8uUTw6SWD1ffdmlHQJzdtULZl7WDStWX/s1600/screenshot3.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/AVvXsEgZKGnoNdHSKt4cOdfSUytKMlRUHQzn1oGWEgogkuCeGRKGwU4d455d0BiSCpqO9d7WioSgHltCApxl2cNWlUyf4iMoyyqEr3A38I5eWqb2d2Rv8uUTw6SWD1ffdmlHQJzdtULZl7WDStWX/s1600/screenshot3.png&quot; height=&quot;640&quot; width=&quot;410&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&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/AVvXsEg7FTk6xKKJQ0S_0PXWqI4Rk1ZYMV_u0BqzMmH5reh6uxAaUT4z-OECFp9roToFMSByCrqD6FPVSiOIuTuZchT8mZ3N6grQ6drZeArJG0djpXuE0uh8AuNgLJUClabUQLwVaClh_3viCs51/s1600/screenshot4.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/AVvXsEg7FTk6xKKJQ0S_0PXWqI4Rk1ZYMV_u0BqzMmH5reh6uxAaUT4z-OECFp9roToFMSByCrqD6FPVSiOIuTuZchT8mZ3N6grQ6drZeArJG0djpXuE0uh8AuNgLJUClabUQLwVaClh_3viCs51/s1600/screenshot4.png&quot; height=&quot;640&quot; width=&quot;410&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;script language=&quot;JavaScript&quot;&gt;
function muestra_oculta(id,tipo){
 var resultado=tipo
 var dir = document.location.href;
 var tit = document.title;
 var tit2 = encodeURIComponent(tit);
 var url =&quot;&quot;;
if(resultado==1){
 var url =&quot;http://www.facebook.com/share.php?u=&quot;+dir+&quot;&amp;t=&quot;+tit2
 window.open(url, &#39;TheBestAndroide&#39;);
}
if(resultado==2){
  var url =&quot;http://twitter.com/home?status=Estoy en &quot;+dir+&quot; leyendo &quot;+tit2
  window.open(url, &#39;TheBestAndroide&#39;);
}
if(resultado==3){
 var url =&quot;http://www.linkedin.com/shareArticle?mini=true&amp;url=&quot;+dir+&quot;&amp;title=&quot;+tit2+&quot;&amp;source=http://thebestandroide.blogspot.com.es/&quot;;
  window.open(url, &#39;TheBestAndroide&#39;);
}
if(resultado==4){
  var url =&quot;http://feeds.feedburner.com/Thebestandroide&quot;
  window.open(url, &#39;TheBestAndroide&#39;);
}

if (document.getElementById){ //se obtiene el id
var el = document.getElementById(id); //se define la variable &quot;el&quot; igual a nuestro div
el.style.display = (el.style.display == &#39;none&#39;) ? &#39;block&#39; : &#39;none&#39;; //damos un atributo display:none que oculta el div
}
}
window.onload = function(){/*hace que se cargue la función lo que predetermina que div estará oculto hasta llamar a la función nuevamente*/
muestra_oculta(&#39;contenido_a_mostrar&#39;);/* &quot;contenido_a_mostrar&quot; es el nombre que le dimos al DIV */
}
&lt;/script&gt;

&lt;br /&gt;
&lt;table style=&quot;width: 260px;&quot;&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;img alt=&quot;Compartir&quot; border=&quot;0&quot; height=&quot;50&quot; onclick=&quot;muestra_oculta(&#39;contenido_a_mostrar&#39;,1)&quot; onmouseout=&quot;this.src=&#39;https://dl.dropboxusercontent.com/u/28565502/images/redface.png&#39;;&quot; onmouseover=&quot;this.src=&#39;https://dl.dropboxusercontent.com/u/28565502/images/redfacehover.png&#39;;&quot; src=&quot;https://dl.dropboxusercontent.com/u/28565502/images/redface.png&quot; style=&quot;margin-right: 10px;&quot; width=&quot;50&quot; /&gt;

&lt;img alt=&quot;Compartir&quot; border=&quot;0&quot; height=&quot;50&quot; onclick=&quot;muestra_oculta(&#39;contenido_a_mostrar&#39;,2)&quot; onmouseout=&quot;this.src=&#39;https://dl.dropboxusercontent.com/u/28565502/images/twitterRed.png&#39;;&quot; onmouseover=&quot;this.src=&#39;https://dl.dropboxusercontent.com/u/28565502/images/twitterRedhover.png&#39;;&quot; src=&quot;https://dl.dropboxusercontent.com/u/28565502/images/twitterRed.png&quot; style=&quot;margin-right: 10px;&quot; width=&quot;50&quot; /&gt;

&lt;img alt=&quot;Compartir&quot; border=&quot;0&quot; height=&quot;50&quot; onclick=&quot;muestra_oculta(&#39;contenido_a_mostrar&#39;,3)&quot; onmouseout=&quot;this.src=&#39;https://dl.dropboxusercontent.com/u/28565502/images/LinkedIn-Logo.png&#39;;&quot; onmouseover=&quot;this.src=&#39;https://dl.dropboxusercontent.com/u/28565502/images/LinkedIn-Logohover.png&#39;;&quot; src=&quot;https://dl.dropboxusercontent.com/u/28565502/images/LinkedIn-Logo.png&quot; style=&quot;margin-right: 10px;&quot; width=&quot;50&quot; /&gt;

&lt;img alt=&quot;Compartir&quot; border=&quot;0&quot; height=&quot;50&quot; onclick=&quot;muestra_oculta(&#39;contenido_a_mostrar&#39;,4)&quot; onmouseout=&quot;this.src=&#39;https://dl.dropboxusercontent.com/u/28565502/images/rss.png&#39;;&quot; onmouseover=&quot;this.src=&#39;https://dl.dropboxusercontent.com/u/28565502/images/rsshover.png&#39;;&quot; src=&quot;https://dl.dropboxusercontent.com/u/28565502/images/rss.png&quot; style=&quot;margin-right: 10px;&quot; width=&quot;50&quot; /&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br /&gt;
&lt;div id=&quot;contenido_a_mostrar&quot;&gt;
&lt;/div&gt;
&lt;table style=&quot;height: 211px; width: 507px;&quot;&gt;
&lt;tbody&gt;
&lt;tr&gt;
  &lt;td&gt;&lt;img alt=&quot;Thebestandroide&quot; height=&quot;70&quot; src=&quot;https://dl.dropboxusercontent.com/u/28565502/thebestandroide/firma/logoSoloRuedasChico.jpg&quot; width=&quot;70&quot; /&gt; 
  &lt;a href=&quot;http://thebestandroide.blogspot.com.es/2014/07/iOS-aprende-ejercicios.html&quot;&gt;Indice&lt;/a&gt; 
  &lt;/td&gt;
 &lt;td align=&quot;right&quot;&gt;&lt;img alt=&quot;Thebestandroide&quot; height=&quot;70&quot; src=&quot;https://dl.dropboxusercontent.com/u/28565502/thebestandroide/firma/logoSoloRuedasChico.jpg&quot; width=&quot;70&quot; /&gt; 
 
 &lt;a href=&quot;http://thebestandroide.blogspot.com.es/2014/10/ios-ejercicio-20-reproduciendo-un-mp3.html&quot;&gt;Ejercicio anterior&lt;/a&gt; &lt;/td&gt;
  &lt;td align=&quot;right&quot;&gt;&lt;img alt=&quot;Thebestandroide&quot; height=&quot;70&quot; src=&quot;https://dl.dropboxusercontent.com/u/28565502/thebestandroide/firma/logoSoloRuedasChico.jpg&quot; width=&quot;70&quot; /&gt; 
  
 &lt;a href=&quot;http://thebestandroide.blogspot.com.es/2014/10/ios-ejercicio-22-twitter-facebook-en.html&quot;&gt;Siguiente ejercicio&lt;/a&gt; &lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
</description><link>http://thebestandroide.blogspot.com/2014/10/ios-ejercicio-21-iuwebview-cargando.html</link><author>noreply@blogger.com (David)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiIWBQxhv7TibBZZPJbSVzCeBDT8gbmzTe7b4HONd33U029BIpx6fBxb250NvhhGq6XlikEEtr9s71216KLQfd5tY1bZP8NRGLep9bnp9hd-6kDHc0FTLOwmwP93P73d7ODJCLAxBomGQWN/s72-c/cabezote2.jpg" height="72" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-1686662779713559896.post-3192880034612093395</guid><pubDate>Wed, 01 Oct 2014 21:30:00 +0000</pubDate><atom:updated>2014-10-05T16:58:53.481+01:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">iOS play streaming</category><category domain="http://www.blogger.com/atom/ns#">MPMoviePlayerController</category><category domain="http://www.blogger.com/atom/ns#">request URL</category><category domain="http://www.blogger.com/atom/ns#">stream video XCode</category><category domain="http://www.blogger.com/atom/ns#">thebestandroide ejercicios ios</category><category domain="http://www.blogger.com/atom/ns#">XCode play video url</category><category domain="http://www.blogger.com/atom/ns#">XCode reproducir video</category><category domain="http://www.blogger.com/atom/ns#">XCode stream video</category><category domain="http://www.blogger.com/atom/ns#">XCode video streaming</category><title>iOS : Ejercicio 20. Reproduciendo video en nuestro iPhone</title><description>&lt;a href=&quot;http://thebestandroide.blogspot.com.es/&quot;&gt;&lt;span style=&quot;color: #a5130f;&quot;&gt;Blog &lt;/span&gt;&lt;/a&gt;
&lt;span style=&quot;color: #a5130f;&quot;&gt;&lt;a href=&quot;http://thebestandroide.blogspot.com.es/2014/07/iOS-aprende-ejercicios.html&quot;&gt;&amp;gt;Lista ejercicios &amp;gt;&amp;nbsp;&lt;/a&gt;&lt;/span&gt;
&lt;span style=&quot;color: #a5130f;&quot;&gt;&lt;b&gt;Ejercicio 20&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
Hola developers, continuamos con los ejercicios básicos en iOS con el numero 20.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&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/AVvXsEj_kokwcX4966nu5nmKjAOWfEeT5zpNreKezTjLcsMU97IToOIEXAwJ8xbtX5UP-xhslRQwt2irjGpfYJJP_XTRgLvjUZks20OxwgkUPocPJlPQE5-KIozsn9GCI9CeOcBw-q2wfKElP6BG/s1600/cabezote2.jpg&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/AVvXsEj_kokwcX4966nu5nmKjAOWfEeT5zpNreKezTjLcsMU97IToOIEXAwJ8xbtX5UP-xhslRQwt2irjGpfYJJP_XTRgLvjUZks20OxwgkUPocPJlPQE5-KIozsn9GCI9CeOcBw-q2wfKElP6BG/s1600/cabezote2.jpg&quot; height=&quot;131&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: x-large;&quot;&gt;Ejercicio 20 : Reproducción video en iPhone :
&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: x-large;&quot;&gt;iOS soporta la mayoria de los codecs de video, el más común  es .mp4 (sistema H263, H264)&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;En este ejercicio primero lo haremos insertando el vídeo en el proyecto, además del framework necesario: &lt;b&gt;MediaPlayer&lt;/b&gt; por medio de una vista.&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
Creamos un proyecto de la forma habitual:  create new proyect - single view application :&lt;br /&gt;
&lt;br /&gt;
&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/AVvXsEhN0GZe0Nx6pYmR6g6Ej-C-oE1SLfHpf5bJdnziL6Hw5QxUGyL2MyjRCXT793VEPf6H0W41n68bzNdOiNQtPlQCOv0RKS5a6gFlPdQHska9nMzQAJI3gY_nSoOBGAkyCdUfcqTe5EPQyKnG/s1600/screenshot1.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/AVvXsEhN0GZe0Nx6pYmR6g6Ej-C-oE1SLfHpf5bJdnziL6Hw5QxUGyL2MyjRCXT793VEPf6H0W41n68bzNdOiNQtPlQCOv0RKS5a6gFlPdQHska9nMzQAJI3gY_nSoOBGAkyCdUfcqTe5EPQyKnG/s1600/screenshot1.png&quot; height=&quot;270&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Después añadimos el framework necesario para hacer el objeto &lt;/span&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;span style=&quot;color: #a5130f;&quot;&gt;&lt;b&gt;MPMoviePlayer&lt;/b&gt;&lt;/span&gt;, así que sobre el proyecto hacemos click y en Build Phases, en la opción Link Binary With Libraries pulsando el + añadimos la libreria  MediaPlayer.framework.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&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/AVvXsEjeWAC7e17_SmmmgssFPxJ_ttAoH4OmUpI5bzmul4YpgnalauxQdWNob1ErVWBmKgLdkhsX66SM37ong_k4hPT96TFlu3PJSkYNgzzFglg7RpxHyu6ajX9SpHIIJnVeVLnT01WGd9vaffH3/s1600/screenshot2.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/AVvXsEjeWAC7e17_SmmmgssFPxJ_ttAoH4OmUpI5bzmul4YpgnalauxQdWNob1ErVWBmKgLdkhsX66SM37ong_k4hPT96TFlu3PJSkYNgzzFglg7RpxHyu6ajX9SpHIIJnVeVLnT01WGd9vaffH3/s1600/screenshot2.png&quot; height=&quot;368&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Ahora hacemos la instancia global &lt;span style=&quot;color: #a5130f;&quot;&gt;&lt;b&gt;MPMoviePlayerController&lt;/b&gt;&lt;/span&gt;, que va a ser donde se va a reproducir nuestro vídeo, lo hacemos en el archivo .h; añadimos video al proyecto, no olvidemos importar la librería.&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
Clickamos en el botón derecho en la carpeta del proyecto y seleccionando Add Files to &quot;nombreProyecto&quot;, seleccionamos el archivo y lo añadimos :&lt;br /&gt;
&lt;br /&gt;
.H&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush: objc;&quot;&gt;//  ViewController.h
//  Reproductor_video
//  Copyright (c) 2014 ___FULLUSERNAME___. All rights reserved.
//
#import &lt;uikit it.h=&quot;&quot;&gt;
#import &lt;mediaplayer ediaplayer.h=&quot;&quot;&gt;
@interface ViewController : UIViewController
@property (nonatomic,strong) MPMoviePlayerController *Reproductor;
@end
&lt;/mediaplayer&gt;&lt;/uikit&gt;&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
Por último ponemos en el código .M ponemos el código necesario para reproducir el vídeo que anteriormente hemos importado al proyecto
&lt;br /&gt;
&lt;br /&gt;
.M&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush: objc;&quot;&gt;//  ViewController.m
//  Reproductor_video
//
//  Created by makone moreno on 12/09/14.
//  Copyright (c) 2014 ___FULLUSERNAME___. All rights reserved.
//
#import &quot;ViewController.h&quot;

@interface ViewController ()
@end

@implementation ViewController
@synthesize Reproductor;
- (void)viewDidLoad
{
    [super viewDidLoad];
    //INSTANCIAMOS EL VIDEO
    NSString *video= [[NSBundle mainBundle]pathForResource:@&quot;shark&quot; ofType:@&quot;mp4&quot;];
    //RUTA DEL VIDEO
    NSURL *direccion= [[NSURL alloc]initFileURLWithPath:video];
    //INICIALIZAMOS
    Reproductor=[[MPMoviePlayerController alloc] initWithContentURL:direccion];
    //CONFIGURAMOS LA PROPIEDAD VIEW DEL REPRODUCTOR PARA ASIGNARLE UN TAMAÑO
    Reproductor.view.frame=CGRectMake(30, 30, 200, 200);
    //Y AHORA SU VISTA LA AÑADIMOS A LA VISTA PRINCIPAL
    [self.view addSubview:Reproductor.view];
    [Reproductor play];
}
- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
}
@end
&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
Ejecutamos el proyecto para probarlo.&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: x-large;&quot;&gt;También podemos usar &lt;b&gt;&lt;span style=&quot;color: #a5130f;&quot;&gt;MPMoviePlayerController&lt;/span&gt;&lt;/b&gt; para reproducir videos en streaming.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Los vídeos suelen ser ficheros grandes que pueden tardar en cargarse un tiempo determinado.Para todo aquel que no sepa que significa &quot;in Streaming&quot;, se hace referencia al video que se graba en modo &quot;online&quot; es decir, en directo.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
Subimos un video a dropbox, de la misma manera que se explica como subir una imagen &lt;a href=&quot;http://thebestandroide.blogspot.com.es/2014/09/ios-ejercicio-17-cargar-imagen-en.html&quot; target=&quot;_blank&quot;&gt;aquí&lt;/a&gt;.
&lt;br /&gt;
Si queremos saber cuando ha terminado la carga del vídeo podemos insertarlo a la notificación MPMoviePlayerContentPreloadDidFinishNotification así:
&lt;br /&gt;
&lt;br /&gt;
.M&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush: objc;&quot;&gt;//  ViewController.m
//  Reproductor_video
//
//  Created by makone moreno on 12/09/14.
//  Copyright (c) 2014 ___FULLUSERNAME___. All rights reserved.
//
#import &quot;ViewController.h&quot;

@interface ViewController ()
@end

@implementation ViewController
@synthesize Reproductor;
- (void)viewDidLoad
{
    [super viewDidLoad];
    NSURL *url = [NSURL URLWithString:@&quot;https://dl.dropbox.com/s/kgxftmkehugywzm/shark.mp4?dl=0&quot;];
    [[NSNotificationCenter defaultCenter] addObserver:self
                                             selector:@selector(moviePlaybackDidFinish:)
                                                 name:MPMoviePlayerPlaybackDidFinishNotification
                                               object:Reproductor];
    //INICIALIZAMOS
    Reproductor=[[MPMoviePlayerController alloc] initWithContentURL:url];
    //CONFIGURAMOS LA PROPIEDAD VIEW DEL REPRODUCTOR PARA ASIGNARLE UN TAMAÑO
    Reproductor.view.frame=CGRectMake(30, 30, 200, 200);
    //Y AHORA SU VISTA LA AÑADIMOS A LA VISTA PRINCIPAL
    [self.view addSubview:Reproductor.view];
    [Reproductor play];

}
- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
}
@end&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
Y bien este es el resultado, como podeis observar se crean los controles de forma automática sin necesidad de insertar código :&lt;br /&gt;
&lt;br /&gt;
&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/AVvXsEjQhiX9DxyJtNGkvycJvb2DXBvvnRCSbyLdJ3p_CckXDsPs72urM92-q-90hc2Q8wuff8x5OOa0yyZIA4QMq9DfCySSHLAORNOS_sVL5fgh-dwH0S5c6y4gneqm0vpI4BlSoRiunz0UtCd0/s1600/screenshot3.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/AVvXsEjQhiX9DxyJtNGkvycJvb2DXBvvnRCSbyLdJ3p_CckXDsPs72urM92-q-90hc2Q8wuff8x5OOa0yyZIA4QMq9DfCySSHLAORNOS_sVL5fgh-dwH0S5c6y4gneqm0vpI4BlSoRiunz0UtCd0/s1600/screenshot3.png&quot; height=&quot;640&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;script language=&quot;JavaScript&quot;&gt;
function muestra_oculta(id,tipo){
 var resultado=tipo
 var dir = document.location.href;
 var tit = document.title;
 var tit2 = encodeURIComponent(tit);
 var url =&quot;&quot;;
if(resultado==1){
 var url =&quot;http://www.facebook.com/share.php?u=&quot;+dir+&quot;&amp;t=&quot;+tit2
 window.open(url, &#39;TheBestAndroide&#39;);
}
if(resultado==2){
  var url =&quot;http://twitter.com/home?status=Estoy en &quot;+dir+&quot; leyendo &quot;+tit2
  window.open(url, &#39;TheBestAndroide&#39;);
}
if(resultado==3){
 var url =&quot;http://www.linkedin.com/shareArticle?mini=true&amp;url=&quot;+dir+&quot;&amp;title=&quot;+tit2+&quot;&amp;source=http://thebestandroide.blogspot.com.es/&quot;;
  window.open(url, &#39;TheBestAndroide&#39;);
}
if(resultado==4){
  var url =&quot;http://feeds.feedburner.com/Thebestandroide&quot;
  window.open(url, &#39;TheBestAndroide&#39;);
}

if (document.getElementById){ //se obtiene el id
var el = document.getElementById(id); //se define la variable &quot;el&quot; igual a nuestro div
el.style.display = (el.style.display == &#39;none&#39;) ? &#39;block&#39; : &#39;none&#39;; //damos un atributo display:none que oculta el div
}
}
window.onload = function(){/*hace que se cargue la función lo que predetermina que div estará oculto hasta llamar a la función nuevamente*/
muestra_oculta(&#39;contenido_a_mostrar&#39;);/* &quot;contenido_a_mostrar&quot; es el nombre que le dimos al DIV */
}
&lt;/script&gt;

&lt;br /&gt;
&lt;table style=&quot;width: 260px;&quot;&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;img alt=&quot;Compartir&quot; border=&quot;0&quot; height=&quot;50&quot; onclick=&quot;muestra_oculta(&#39;contenido_a_mostrar&#39;,1)&quot; onmouseout=&quot;this.src=&#39;https://dl.dropboxusercontent.com/u/28565502/images/redface.png&#39;;&quot; onmouseover=&quot;this.src=&#39;https://dl.dropboxusercontent.com/u/28565502/images/redfacehover.png&#39;;&quot; src=&quot;https://dl.dropboxusercontent.com/u/28565502/images/redface.png&quot; style=&quot;margin-right: 10px;&quot; width=&quot;50&quot; /&gt;

&lt;img alt=&quot;Compartir&quot; border=&quot;0&quot; height=&quot;50&quot; onclick=&quot;muestra_oculta(&#39;contenido_a_mostrar&#39;,2)&quot; onmouseout=&quot;this.src=&#39;https://dl.dropboxusercontent.com/u/28565502/images/twitterRed.png&#39;;&quot; onmouseover=&quot;this.src=&#39;https://dl.dropboxusercontent.com/u/28565502/images/twitterRedhover.png&#39;;&quot; src=&quot;https://dl.dropboxusercontent.com/u/28565502/images/twitterRed.png&quot; style=&quot;margin-right: 10px;&quot; width=&quot;50&quot; /&gt;

&lt;img alt=&quot;Compartir&quot; border=&quot;0&quot; height=&quot;50&quot; onclick=&quot;muestra_oculta(&#39;contenido_a_mostrar&#39;,3)&quot; onmouseout=&quot;this.src=&#39;https://dl.dropboxusercontent.com/u/28565502/images/LinkedIn-Logo.png&#39;;&quot; onmouseover=&quot;this.src=&#39;https://dl.dropboxusercontent.com/u/28565502/images/LinkedIn-Logohover.png&#39;;&quot; src=&quot;https://dl.dropboxusercontent.com/u/28565502/images/LinkedIn-Logo.png&quot; style=&quot;margin-right: 10px;&quot; width=&quot;50&quot; /&gt;

&lt;img alt=&quot;Compartir&quot; border=&quot;0&quot; height=&quot;50&quot; onclick=&quot;muestra_oculta(&#39;contenido_a_mostrar&#39;,4)&quot; onmouseout=&quot;this.src=&#39;https://dl.dropboxusercontent.com/u/28565502/images/rss.png&#39;;&quot; onmouseover=&quot;this.src=&#39;https://dl.dropboxusercontent.com/u/28565502/images/rsshover.png&#39;;&quot; src=&quot;https://dl.dropboxusercontent.com/u/28565502/images/rss.png&quot; style=&quot;margin-right: 10px;&quot; width=&quot;50&quot; /&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br /&gt;
&lt;div id=&quot;contenido_a_mostrar&quot;&gt;
&lt;/div&gt;
&lt;br /&gt;
&lt;table style=&quot;height: 360px;&quot;&gt;
&lt;tbody&gt;
&lt;tr&gt;
  &lt;td&gt;&lt;img alt=&quot;Thebestandroide&quot; height=&quot;70&quot; src=&quot;https://dl.dropboxusercontent.com/u/28565502/thebestandroide/firma/logoSoloRuedasChico.jpg&quot; width=&quot;70&quot; /&gt; 
  &lt;a href=&quot;http://thebestandroide.blogspot.com.es/2014/07/iOS-aprende-ejercicios.html&quot;&gt;Indice&lt;/a&gt; 
  &lt;/td&gt;
 &lt;td align=&quot;right&quot;&gt;&lt;img alt=&quot;Thebestandroide&quot; height=&quot;70&quot; src=&quot;https://dl.dropboxusercontent.com/u/28565502/thebestandroide/firma/logoSoloRuedasChico.jpg&quot; width=&quot;70&quot; /&gt; 
 
 &lt;a href=&quot;http://thebestandroide.blogspot.com.es/2014/10/ios-ejercicio-19-reproduccion-mp3-en.html&quot;&gt;Ejercicio anterior&lt;/a&gt; &lt;/td&gt;
  &lt;td align=&quot;right&quot;&gt;&lt;img alt=&quot;Thebestandroide&quot; height=&quot;70&quot; src=&quot;https://dl.dropboxusercontent.com/u/28565502/thebestandroide/firma/logoSoloRuedasChico.jpg&quot; width=&quot;70&quot; /&gt; 
  
 &lt;a href=&quot;http://thebestandroide.blogspot.com.es/2014/10/ios-ejercicio-21-iuwebview-cargando.html&quot;&gt;Siguiente ejercicio&lt;/a&gt; &lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
</description><link>http://thebestandroide.blogspot.com/2014/10/ios-ejercicio-20-reproduciendo-un-mp3.html</link><author>noreply@blogger.com (David)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj_kokwcX4966nu5nmKjAOWfEeT5zpNreKezTjLcsMU97IToOIEXAwJ8xbtX5UP-xhslRQwt2irjGpfYJJP_XTRgLvjUZks20OxwgkUPocPJlPQE5-KIozsn9GCI9CeOcBw-q2wfKElP6BG/s72-c/cabezote2.jpg" height="72" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-1686662779713559896.post-5344019310866480911</guid><pubDate>Wed, 01 Oct 2014 20:49:00 +0000</pubDate><atom:updated>2014-10-05T16:35:54.548+01:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">developer iOS</category><category domain="http://www.blogger.com/atom/ns#">ejercicio iOS</category><category domain="http://www.blogger.com/atom/ns#">thebestandroide ejercicios ios</category><category domain="http://www.blogger.com/atom/ns#">xcode duration mp3</category><category domain="http://www.blogger.com/atom/ns#">xcode duration sonido</category><category domain="http://www.blogger.com/atom/ns#">xcode reproducir audio</category><category domain="http://www.blogger.com/atom/ns#">xcode reproducir mp3</category><category domain="http://www.blogger.com/atom/ns#">xcode song duration</category><title>iOS : Ejercicio 19. Reproducción .mp3 en XCode</title><description>Hola developers, continuamos con los ejercicios básicos en iOS con el numero 19.&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;http://thebestandroide.blogspot.com.es/&quot;&gt;&lt;span style=&quot;color: #a5130f;&quot;&gt;Blog &lt;/span&gt;&lt;/a&gt;
&lt;span style=&quot;color: #a5130f;&quot;&gt;&lt;a href=&quot;http://thebestandroide.blogspot.com.es/2014/07/iOS-aprende-ejercicios.html&quot;&gt;&amp;gt;Lista ejercicios &amp;gt;&amp;nbsp;&lt;/a&gt;&lt;/span&gt;
&lt;span style=&quot;color: #a5130f;&quot;&gt;&lt;b&gt;Ejercicio 19&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&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/AVvXsEgAwRth5zfWh3PVYGWKeqJB0Ho4Y3HPfOal1qJI0UNB-Yv5qxzMQWcWlIlIH7WoYjOzV-s4_N-dd8-MFdErnUTKKas4qD457cbx_uN8ksV77FKRqPTq1qthb8a8VbC-RGkBFDGpFkIfsHro/s1600/cabezote2.jpg&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/AVvXsEgAwRth5zfWh3PVYGWKeqJB0Ho4Y3HPfOal1qJI0UNB-Yv5qxzMQWcWlIlIH7WoYjOzV-s4_N-dd8-MFdErnUTKKas4qD457cbx_uN8ksV77FKRqPTq1qthb8a8VbC-RGkBFDGpFkIfsHro/s1600/cabezote2.jpg&quot; height=&quot;131&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: x-large;&quot;&gt;Ejercicio 19 : Reproducción audio en nuestro iPhone&lt;/span&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Para reproducir sonidos el software de iOS nos proporciona el framework AVFoundation. Este software puede reproducir casi la mayoría de los formatos de audio, y aunque el principal es el .mp3, también puede reproducir .caf, .aiff o .wav .&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Clases del framework AVFoundation :&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;b&gt;AVAudioMix :&lt;/b&gt; Clase que maneja los parámetros de entrada para mezclar distintas pistas de audio.
&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;b&gt;AVMutableAudioMix :&lt;/b&gt; Clase que gestiona los parámetros de entrada para mezclar el audio.
&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;b&gt;AVAsset :&lt;/b&gt; Clase abstracta que representa medios como videos o audios cronometrados.
&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;b&gt;AVCaptureDevice :&lt;/b&gt; Clase que representa un dispositivo físico de captura junto a sus propiedades asociadas.
&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;b&gt;AVPlayer :&lt;/b&gt; Clase para implementar controladores o interfaces para reproducir uno o varios sonidos.
&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;b&gt;AVPlayerLayer :&lt;/b&gt; Subclase de CALayer a la cual un objeto AVPlayer puede dirigir su salida visual.
&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Creamos un proyecto de la forma habitual:  create new proyect - single view application&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&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/AVvXsEgsyEsctqPCWlErxRORw_4hQ4GMwT2XR92IW1y0osdTpmI4k8qxBazU9eqOB8Z3Xn10vRguJ-qsiVFOKQ8ev0XHOS0P36xBFvkdSbbs_0I0MRMpFoJ0oJeAxgwoDxypho_HESJ8id1U-1mA/s1600/screenshot1.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/AVvXsEgsyEsctqPCWlErxRORw_4hQ4GMwT2XR92IW1y0osdTpmI4k8qxBazU9eqOB8Z3Xn10vRguJ-qsiVFOKQ8ev0XHOS0P36xBFvkdSbbs_0I0MRMpFoJ0oJeAxgwoDxypho_HESJ8id1U-1mA/s1600/screenshot1.png&quot; height=&quot;270&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Agregamos el framework necesario para hacer el objeto &lt;b&gt;AVFoundation&lt;/b&gt;, así que sobre el proyecto hacemos click y en Build Phases, en la opción Link Binary With Libraries pulsando el + añadimos la libreria framework AVFoundation e importamos la libreria, seguidamente arrastramos .mp3 al proyecto.
&lt;/span&gt;&lt;br /&gt;
&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/AVvXsEgT2NdPAaINJJ-c5gmlJ5JmAZy3Lh_dX_reBLUrDc0epfPwIFbV5LwZrSBiDaK8tyTkpIgZBhuyl3Z-R_aBlnFx9arsT9UQ2Wd4J3k-ZRlRuSDEg4YWTCvwhp5zsqql31oZl4zbm7VBbt-_/s1600/screenshot2.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/AVvXsEgT2NdPAaINJJ-c5gmlJ5JmAZy3Lh_dX_reBLUrDc0epfPwIFbV5LwZrSBiDaK8tyTkpIgZBhuyl3Z-R_aBlnFx9arsT9UQ2Wd4J3k-ZRlRuSDEg4YWTCvwhp5zsqql31oZl4zbm7VBbt-_/s1600/screenshot2.png&quot; height=&quot;400&quot; width=&quot;346&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Vamos a nuestro storyboard y agregamos 2 botones y 2 labels con sus conexiones pertinentes
&lt;/span&gt;&lt;br /&gt;
&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/AVvXsEhkfknlR_6E9QA68kbg2_VwVeb1KDbBbeb8gLGjNXHVJ9NJlB7nelxGfbDTOEOcuNxzKvuqlOpt2RHMFAbTW5wBYs98-e3hklQwkSwbnQeP40qLT7w_4vWbRvm4Cy02jp3lzQGFnVyfAizC/s1600/screenshot3.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/AVvXsEhkfknlR_6E9QA68kbg2_VwVeb1KDbBbeb8gLGjNXHVJ9NJlB7nelxGfbDTOEOcuNxzKvuqlOpt2RHMFAbTW5wBYs98-e3hklQwkSwbnQeP40qLT7w_4vWbRvm4Cy02jp3lzQGFnVyfAizC/s1600/screenshot3.png&quot; height=&quot;206&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Ahora tenemos que hacer una variable global de AVAudioPlayer para poder reproducir el sonido, añadimos una cancion al proyecto pulsando botón derecho sobre la carpeta del proyecto y pulsando sobre &quot;Add files to &quot;nombreproyecto&quot;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&amp;nbsp;&lt;/span&gt;
&lt;br /&gt;
Y este es el código para reproducir el sonido :&lt;br /&gt;
&lt;br /&gt;
.h 
&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush: objc;&quot;&gt;#import &lt;uikit it.h=&quot;&quot;&gt;
#import &lt;avfoundation oundation.h=&quot;&quot;&gt;
@interface ViewController : UIViewController 
@property (nonatomic,strong) AVAudioPlayer *reproductor;
@property (weak, nonatomic) IBOutlet UILabel *nombre;
@property (weak, nonatomic) IBOutlet UILabel *duracion;
- (IBAction)play:(id)sender;
- (IBAction)Stop:(id)sender;
@end
&lt;/avfoundation&gt;&lt;/uikit&gt;&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
.m
&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush: objc;&quot;&gt;#import &quot;ViewController.h&quot;
@interface ViewController ()

@end

@implementation ViewController
@synthesize reproductor;
@synthesize duracion;
- (void)viewDidLoad
{
    [super viewDidLoad];
    NSError *error;
    //INSTANCIA DE LA CANCION
    NSString *ruta = [[NSBundle mainBundle] pathForResource:@&quot;Enloquecer&quot; ofType:@&quot;mp3&quot;];
    //NSLog(@&quot;LA RUTA ES %@&quot;,ruta);
    //LO CONVERTIMOS EN URL
    NSURL *direccion = [[NSURL alloc] initFileURLWithPath:ruta];
    //Lo asociamos al reproductor
    self.reproductor = [[AVAudioPlayer alloc]initWithContentsOfURL:direccion error:&amp;amp;error];    
    //ES para darle balance
    //0 - Igual altavoz izquierdo que altavoz derecho
    //-1 - Solo izquierdo
    //1 - solo derecho
    self.reproductor.pan=0;
    self.reproductor.numberOfLoops=1; //NUMERO DE REPETICIONES : VALOR NEGATIVO INFINITAS VECES
    self.reproductor.volume=1;        //MANEJA VOLUMEN rango 0 - 1
    [self.reproductor prepareToPlay]; //Preparamos la reproducción
}
- (IBAction)play:(id)sender {
    [self.reproductor play];
}
- (IBAction)Stop:(id)sender {
    [self.reproductor stop];
}
@end
&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Bien, vamos a mostrar ahora el tiempo que queda para que acabe la canción, haremos un timer, lo que pasa que nos dará el resultado en segundos y milisegundos, además que queremos hacerlo regresivo, es decir desde el final a 0. Esto lo conseguimos restando el tiempo transcurrido al tiempo total de la canción, y aplicandole el formato correcto para que aparezcan minutos y segundos, ¿Como se hace? Así...
&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
.m
&lt;br /&gt;
&lt;pre class=&quot;brush: objc;&quot;&gt;#import &quot;ViewController.h&quot;

@interface ViewController ()
@end

@implementation ViewController
@synthesize reproductor;
@synthesize duracion;
NSTimer *timer ;
- (void)viewDidLoad
{
    [super viewDidLoad];
    NSError *error;
    //INSTANCIA DE LA CANCION
    NSString *ruta = [[NSBundle mainBundle] pathForResource:@&quot;Enloquecer&quot; ofType:@&quot;mp3&quot;];
    //NSLog(@&quot;LA RUTA ES %@&quot;,ruta);
    //LO CONVERTIMOS EN URL
    NSURL *direccion = [[NSURL alloc] initFileURLWithPath:ruta];
    //Lo asociamos al reproductor
    self.reproductor = [[AVAudioPlayer alloc]initWithContentsOfURL:direccion error:&amp;amp;error];
    //ES para darle balance
    //0 - Igual altavoz izquierdo que altavoz derecho
    //-1 - Solo izquierdo
    //1 - solo derecho
    self.reproductor.pan=0;
    self.reproductor.numberOfLoops=1; //NUMERO DE REPETICIONES : VALOR NEGATIVO INFINITAS VECES
    self.reproductor.volume=1;        //MANEJA VOLUMEN rango 0 - 1
    [self.reproductor prepareToPlay]; //Preparamos la reproducción
    //CREAMOS TIMER PARA MOSTRAR EL TIEMPO TRANSCURRIDO
    timer = [NSTimer scheduledTimerWithTimeInterval:1.0
                              target:self
                              selector:@selector(updateTime)
                              userInfo:nil
                              repeats:YES];
    //Texto label action
    self.nombre.text = [NSString stringWithFormat:@&quot;Cargando...&quot;];
}
//FUNCION TIMER
-(void)updateTime{
    //DURACION CANCION - DURACION TIEMPO TRANSCURRIDO
    NSTimeInterval timeLeft = self.reproductor.duration - self.reproductor.currentTime;
    //FORMATO MINUTOS
    div_t m = div(timeLeft, 60);
    int minutos =m.quot;
    //FORMATO SEGUNDOS
    int seconds =m.rem;
    //ACTUALIZAR TIEMPO CONSTANTEMENTE
    self.duracion.text=[NSString stringWithFormat:@&quot;%d.%d&quot;,minutos,seconds];
}
- (IBAction)play:(id)sender {
    [self.reproductor play];
    self.nombre.text = [NSString stringWithFormat:@&quot;Reproduciendo&quot;];
}
- (IBAction)Stop:(id)sender {
    [self.reproductor pause];
    self.nombre.text = [NSString stringWithFormat:@&quot;Pausado&quot;];
}
@end
&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
Y este es el resultado...
&lt;br /&gt;
&lt;br /&gt;
&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/AVvXsEh_QxJeB7EwqS_PI1gAmUKWijhtlMXyTt9_Nf3Ci1pYEuQYOCgsiuadXwYQPYNL_sUGl4NDnQnIiKyEqpiBQmID_pyWG0VLfIWyT9pYDM_swGbFVrb0tM5PtHAbH4TAshRUJiZLCEAqVKOG/s1600/screenshot4.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/AVvXsEh_QxJeB7EwqS_PI1gAmUKWijhtlMXyTt9_Nf3Ci1pYEuQYOCgsiuadXwYQPYNL_sUGl4NDnQnIiKyEqpiBQmID_pyWG0VLfIWyT9pYDM_swGbFVrb0tM5PtHAbH4TAshRUJiZLCEAqVKOG/s1600/screenshot4.png&quot; height=&quot;320&quot; width=&quot;200&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;script language=&quot;JavaScript&quot;&gt;
function muestra_oculta(id,tipo){
 var resultado=tipo
 var dir = document.location.href;
 var tit = document.title;
 var tit2 = encodeURIComponent(tit);
 var url =&quot;&quot;;
if(resultado==1){
 var url =&quot;http://www.facebook.com/share.php?u=&quot;+dir+&quot;&amp;t=&quot;+tit2
 window.open(url, &#39;TheBestAndroide&#39;);
}
if(resultado==2){
  var url =&quot;http://twitter.com/home?status=Estoy en &quot;+dir+&quot; leyendo &quot;+tit2
  window.open(url, &#39;TheBestAndroide&#39;);
}
if(resultado==3){
 var url =&quot;http://www.linkedin.com/shareArticle?mini=true&amp;url=&quot;+dir+&quot;&amp;title=&quot;+tit2+&quot;&amp;source=http://thebestandroide.blogspot.com.es/&quot;;
  window.open(url, &#39;TheBestAndroide&#39;);
}
if(resultado==4){
  var url =&quot;http://feeds.feedburner.com/Thebestandroide&quot;
  window.open(url, &#39;TheBestAndroide&#39;);
}

if (document.getElementById){ //se obtiene el id
var el = document.getElementById(id); //se define la variable &quot;el&quot; igual a nuestro div
el.style.display = (el.style.display == &#39;none&#39;) ? &#39;block&#39; : &#39;none&#39;; //damos un atributo display:none que oculta el div
}
}
window.onload = function(){/*hace que se cargue la función lo que predetermina que div estará oculto hasta llamar a la función nuevamente*/
muestra_oculta(&#39;contenido_a_mostrar&#39;);/* &quot;contenido_a_mostrar&quot; es el nombre que le dimos al DIV */
}
&lt;/script&gt;

&lt;br /&gt;
&lt;table style=&quot;width: 260px;&quot;&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;img alt=&quot;Compartir&quot; border=&quot;0&quot; height=&quot;50&quot; onclick=&quot;muestra_oculta(&#39;contenido_a_mostrar&#39;,1)&quot; onmouseout=&quot;this.src=&#39;https://dl.dropboxusercontent.com/u/28565502/images/redface.png&#39;;&quot; onmouseover=&quot;this.src=&#39;https://dl.dropboxusercontent.com/u/28565502/images/redfacehover.png&#39;;&quot; src=&quot;https://dl.dropboxusercontent.com/u/28565502/images/redface.png&quot; style=&quot;margin-right: 10px;&quot; width=&quot;50&quot; /&gt;

&lt;img alt=&quot;Compartir&quot; border=&quot;0&quot; height=&quot;50&quot; onclick=&quot;muestra_oculta(&#39;contenido_a_mostrar&#39;,2)&quot; onmouseout=&quot;this.src=&#39;https://dl.dropboxusercontent.com/u/28565502/images/twitterRed.png&#39;;&quot; onmouseover=&quot;this.src=&#39;https://dl.dropboxusercontent.com/u/28565502/images/twitterRedhover.png&#39;;&quot; src=&quot;https://dl.dropboxusercontent.com/u/28565502/images/twitterRed.png&quot; style=&quot;margin-right: 10px;&quot; width=&quot;50&quot; /&gt;

&lt;img alt=&quot;Compartir&quot; border=&quot;0&quot; height=&quot;50&quot; onclick=&quot;muestra_oculta(&#39;contenido_a_mostrar&#39;,3)&quot; onmouseout=&quot;this.src=&#39;https://dl.dropboxusercontent.com/u/28565502/images/LinkedIn-Logo.png&#39;;&quot; onmouseover=&quot;this.src=&#39;https://dl.dropboxusercontent.com/u/28565502/images/LinkedIn-Logohover.png&#39;;&quot; src=&quot;https://dl.dropboxusercontent.com/u/28565502/images/LinkedIn-Logo.png&quot; style=&quot;margin-right: 10px;&quot; width=&quot;50&quot; /&gt;

&lt;img alt=&quot;Compartir&quot; border=&quot;0&quot; height=&quot;50&quot; onclick=&quot;muestra_oculta(&#39;contenido_a_mostrar&#39;,4)&quot; onmouseout=&quot;this.src=&#39;https://dl.dropboxusercontent.com/u/28565502/images/rss.png&#39;;&quot; onmouseover=&quot;this.src=&#39;https://dl.dropboxusercontent.com/u/28565502/images/rsshover.png&#39;;&quot; src=&quot;https://dl.dropboxusercontent.com/u/28565502/images/rss.png&quot; style=&quot;margin-right: 10px;&quot; width=&quot;50&quot; /&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br /&gt;
&lt;div id=&quot;contenido_a_mostrar&quot;&gt;
&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;table style=&quot;height: 360px;&quot;&gt;
&lt;tbody&gt;
&lt;tr&gt;
  &lt;td&gt;&lt;img alt=&quot;Thebestandroide&quot; height=&quot;70&quot; src=&quot;https://dl.dropboxusercontent.com/u/28565502/thebestandroide/firma/logoSoloRuedasChico.jpg&quot; width=&quot;70&quot; /&gt; 
  &lt;a href=&quot;http://thebestandroide.blogspot.com.es/2014/07/iOS-aprende-ejercicios.html&quot;&gt;Indice&lt;/a&gt; 
  &lt;/td&gt;
 &lt;td align=&quot;right&quot;&gt;&lt;img alt=&quot;Thebestandroide&quot; height=&quot;70&quot; src=&quot;https://dl.dropboxusercontent.com/u/28565502/thebestandroide/firma/logoSoloRuedasChico.jpg&quot; width=&quot;70&quot; /&gt; 
 
 &lt;a href=&quot;http://thebestandroide.blogspot.com.es/2014/10/ios-ejercicio-18-haciendo-transicion.html&quot;&gt;Ejercicio anterior&lt;/a&gt; &lt;/td&gt;
  &lt;td align=&quot;right&quot;&gt;&lt;img alt=&quot;Thebestandroide&quot; height=&quot;70&quot; src=&quot;https://dl.dropboxusercontent.com/u/28565502/thebestandroide/firma/logoSoloRuedasChico.jpg&quot; width=&quot;70&quot; /&gt; 
  
 &lt;a href=&quot;http://thebestandroide.blogspot.com.es/2014/10/ios-ejercicio-20-reproduciendo-un-mp3.html&quot;&gt;Siguiente ejercicio&lt;/a&gt; &lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
</description><link>http://thebestandroide.blogspot.com/2014/10/ios-ejercicio-19-reproduccion-mp3-en.html</link><author>noreply@blogger.com (David)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgAwRth5zfWh3PVYGWKeqJB0Ho4Y3HPfOal1qJI0UNB-Yv5qxzMQWcWlIlIH7WoYjOzV-s4_N-dd8-MFdErnUTKKas4qD457cbx_uN8ksV77FKRqPTq1qthb8a8VbC-RGkBFDGpFkIfsHro/s72-c/cabezote2.jpg" height="72" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-1686662779713559896.post-3625509908240207171</guid><pubDate>Wed, 01 Oct 2014 19:26:00 +0000</pubDate><atom:updated>2014-10-05T16:30:09.781+01:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">developer iOS</category><category domain="http://www.blogger.com/atom/ns#">ejercicio iOS</category><category domain="http://www.blogger.com/atom/ns#">thebestandroide ejercicios ios</category><category domain="http://www.blogger.com/atom/ns#">XCode core animation</category><category domain="http://www.blogger.com/atom/ns#">xcode transicion vistas</category><category domain="http://www.blogger.com/atom/ns#">xcode view</category><title>iOS : Ejercicio 18. Haciendo transición entre vistas</title><description>&lt;a href=&quot;http://thebestandroide.blogspot.com.es/&quot;&gt;&lt;span style=&quot;color: #a5130f;&quot;&gt;Blog &lt;/span&gt;&lt;/a&gt;
&lt;span style=&quot;color: #a5130f;&quot;&gt;&lt;a href=&quot;http://thebestandroide.blogspot.com.es/2014/07/iOS-aprende-ejercicios.html&quot;&gt;&amp;gt;Lista ejercicios &amp;gt;&amp;nbsp;&lt;/a&gt;&lt;/span&gt;
&lt;span style=&quot;color: #a5130f;&quot;&gt;&lt;b&gt;Ejercicio 18&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Hola developers, continuamos con el tutorial de ejercicios básicos de iOS, esta vez vamos a hacer una transición entre vistas mediante Core Animation.&lt;br /&gt;
&lt;br /&gt;
&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/AVvXsEgAwRth5zfWh3PVYGWKeqJB0Ho4Y3HPfOal1qJI0UNB-Yv5qxzMQWcWlIlIH7WoYjOzV-s4_N-dd8-MFdErnUTKKas4qD457cbx_uN8ksV77FKRqPTq1qthb8a8VbC-RGkBFDGpFkIfsHro/s1600/cabezote2.jpg&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/AVvXsEgAwRth5zfWh3PVYGWKeqJB0Ho4Y3HPfOal1qJI0UNB-Yv5qxzMQWcWlIlIH7WoYjOzV-s4_N-dd8-MFdErnUTKKas4qD457cbx_uN8ksV77FKRqPTq1qthb8a8VbC-RGkBFDGpFkIfsHro/s1600/cabezote2.jpg&quot; height=&quot;131&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: x-large;&quot;&gt;Ejercico 18 : Transición entre vistas mediante Core Animation&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
Creamos un proyecto de la forma habitual : create new Proyect - Single View Application.&lt;br /&gt;
&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/AVvXsEgQRzqCAzmP25fmliKBH3S6YobqEozpzu2X6Z0Ks2r4b0WSawEKfgqQgmeccHMf3d7lGefLiQz1NjCJXTfB7MzVB2z1i1AwmxPUyHGLR34KwjMoUU8CVw93PrtjxODkcJPNWYE1yP9COcqa/s1600/Screenshot1.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/AVvXsEgQRzqCAzmP25fmliKBH3S6YobqEozpzu2X6Z0Ks2r4b0WSawEKfgqQgmeccHMf3d7lGefLiQz1NjCJXTfB7MzVB2z1i1AwmxPUyHGLR34KwjMoUU8CVw93PrtjxODkcJPNWYE1yP9COcqa/s1600/Screenshot1.png&quot; height=&quot;270&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Vamos a nuestro storyboard, y ahi insertamos una View y un label, a esa View la cambiamos el color :&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&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/AVvXsEjXAXK84jN3mMbZ_B-SvGLbGu9dj70Qq3mQJFoC1lr2IAVwXFndioCxHiWLq5bovuHdozaN_DEhpOEnHbWjSAKBSHjGivAQG52lDGHwNQsPryPm03P-pS6LBhryBEbgTFYPVXCVkdrBrg-0/s1600/Screenshot2.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/AVvXsEjXAXK84jN3mMbZ_B-SvGLbGu9dj70Qq3mQJFoC1lr2IAVwXFndioCxHiWLq5bovuHdozaN_DEhpOEnHbWjSAKBSHjGivAQG52lDGHwNQsPryPm03P-pS6LBhryBEbgTFYPVXCVkdrBrg-0/s1600/Screenshot2.png&quot; height=&quot;339&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
Repetimos el mismo proceso, solo que ahora en el label pondremos Vista 2 y un botón :&lt;br /&gt;
&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/AVvXsEjl_l5g0bkUFRUtlo9mkq4mRGIiUCDJHe0z9tXXzL_Sw-sWmu35mtLEMbOmU_JVz9Qrjbxe327Uoxm0zEuUT9ndhjybg9ZKeCJJ-S-NuLYkXRMKDNvaGF_z6cbmXwGgKtSLjmoUSprU3t0F/s1600/Screenshot3.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/AVvXsEjl_l5g0bkUFRUtlo9mkq4mRGIiUCDJHe0z9tXXzL_Sw-sWmu35mtLEMbOmU_JVz9Qrjbxe327Uoxm0zEuUT9ndhjybg9ZKeCJJ-S-NuLYkXRMKDNvaGF_z6cbmXwGgKtSLjmoUSprU3t0F/s1600/Screenshot3.png&quot; height=&quot;354&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Ahora realizamos las conexiones pertinentes :&lt;/span&gt;&lt;br /&gt;
&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/AVvXsEgq9wfaSRF4ncjbdQG-7ON8IadWzxImCMldNZ9aVEf1HNAAS-X-q51Q3w9s6vn_WaI3DlWtjTzYgm0vB6eqcpD3BBItsBcRxqtBhWZSR5gP6-WJEeZjTcNcjwdm-Nh91OlMuJoTcwCuU9yR/s1600/Screenshot4.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/AVvXsEgq9wfaSRF4ncjbdQG-7ON8IadWzxImCMldNZ9aVEf1HNAAS-X-q51Q3w9s6vn_WaI3DlWtjTzYgm0vB6eqcpD3BBItsBcRxqtBhWZSR5gP6-WJEeZjTcNcjwdm-Nh91OlMuJoTcwCuU9yR/s1600/Screenshot4.png&quot; height=&quot;364&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
Bien es hora de llevar a cabo el cambio de vista mediante la programación, crearemos una variable booleana, que es la que nos va a decir que vista hay puesta, y después usaremos el método UIView transitionFromView para realizar el cambio.

Bien, ahora ejecutamos el proyecto :&lt;br /&gt;
&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/AVvXsEhKC8kP0kr64bR2cpI_wktQEQvt0LmVg2UbQ417WI5M8sPzvmhRY6bVV8H6r0VDvk1ck8guhRz7Z0P5bYWzRTVq1JgQWNPaHviyy3GvA7KCykgghbe59C4aO-ssqSNnHDiHQ-znRb7gdFF_/s1600/Screenshot5.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/AVvXsEhKC8kP0kr64bR2cpI_wktQEQvt0LmVg2UbQ417WI5M8sPzvmhRY6bVV8H6r0VDvk1ck8guhRz7Z0P5bYWzRTVq1JgQWNPaHviyy3GvA7KCykgghbe59C4aO-ssqSNnHDiHQ-znRb7gdFF_/s1600/Screenshot5.png&quot; height=&quot;400&quot; width=&quot;253&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Y al pulsar el botón :&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&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/AVvXsEjSeIK4vUhUPBODSF8o42FOjWkeJNqT1tTSvfrcI2vOGS9t9GJcmvX0RUgzYX6e5sXgt9LSlZrnDA6oGIuvEdPdnXchBjtuJIu6saSoB2o2tKvHntK7teqw_vnQqEhirvd2f0aSPS6i3oxl/s1600/Screenshot6.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/AVvXsEjSeIK4vUhUPBODSF8o42FOjWkeJNqT1tTSvfrcI2vOGS9t9GJcmvX0RUgzYX6e5sXgt9LSlZrnDA6oGIuvEdPdnXchBjtuJIu6saSoB2o2tKvHntK7teqw_vnQqEhirvd2f0aSPS6i3oxl/s1600/Screenshot6.png&quot; height=&quot;400&quot; width=&quot;252&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Pero si volvemos a pulsar el botón :&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&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/AVvXsEi3rW1uZ0sHrQK-GNXgT3MtsRMq_1e1PJxsymdJYbr0H51Ey4NtrLtTVSuh9p75ldbJy5_JBd6LVJcXRZlNOTUvmFQcqmbjtsP3OgogAxdI6c1yNyfsaB1RWJdAjYa9GDgy7nKHBEWoQe-A/s1600/Screenshot7.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/AVvXsEi3rW1uZ0sHrQK-GNXgT3MtsRMq_1e1PJxsymdJYbr0H51Ey4NtrLtTVSuh9p75ldbJy5_JBd6LVJcXRZlNOTUvmFQcqmbjtsP3OgogAxdI6c1yNyfsaB1RWJdAjYa9GDgy7nKHBEWoQe-A/s1600/Screenshot7.png&quot; height=&quot;400&quot; width=&quot;250&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Vemos que se ha ocultado, por ahí dicen las malas lenguas que este error se produce porque las vistas no estan cuadradas una con la otra... así que a cuadrarlo hasta que funcione (tarde 40 minutos... es lo que tiene)&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;script language=&quot;JavaScript&quot;&gt;
function muestra_oculta(id,tipo){
 var resultado=tipo
 var dir = document.location.href;
 var tit = document.title;
 var tit2 = encodeURIComponent(tit);
 var url =&quot;&quot;;
if(resultado==1){
 var url =&quot;http://www.facebook.com/share.php?u=&quot;+dir+&quot;&amp;t=&quot;+tit2
 window.open(url, &#39;TheBestAndroide&#39;);
}
if(resultado==2){
  var url =&quot;http://twitter.com/home?status=Estoy en &quot;+dir+&quot; leyendo &quot;+tit2
  window.open(url, &#39;TheBestAndroide&#39;);
}
if(resultado==3){
 var url =&quot;http://www.linkedin.com/shareArticle?mini=true&amp;url=&quot;+dir+&quot;&amp;title=&quot;+tit2+&quot;&amp;source=http://thebestandroide.blogspot.com.es/&quot;;
  window.open(url, &#39;TheBestAndroide&#39;);
}
if(resultado==4){
  var url =&quot;http://feeds.feedburner.com/Thebestandroide&quot;
  window.open(url, &#39;TheBestAndroide&#39;);
}

if (document.getElementById){ //se obtiene el id
var el = document.getElementById(id); //se define la variable &quot;el&quot; igual a nuestro div
el.style.display = (el.style.display == &#39;none&#39;) ? &#39;block&#39; : &#39;none&#39;; //damos un atributo display:none que oculta el div
}
}
window.onload = function(){/*hace que se cargue la función lo que predetermina que div estará oculto hasta llamar a la función nuevamente*/
muestra_oculta(&#39;contenido_a_mostrar&#39;);/* &quot;contenido_a_mostrar&quot; es el nombre que le dimos al DIV */
}
&lt;/script&gt;

&lt;br /&gt;
&lt;table style=&quot;width: 260px;&quot;&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;img alt=&quot;Compartir&quot; border=&quot;0&quot; height=&quot;50&quot; onclick=&quot;muestra_oculta(&#39;contenido_a_mostrar&#39;,1)&quot; onmouseout=&quot;this.src=&#39;https://dl.dropboxusercontent.com/u/28565502/images/redface.png&#39;;&quot; onmouseover=&quot;this.src=&#39;https://dl.dropboxusercontent.com/u/28565502/images/redfacehover.png&#39;;&quot; src=&quot;https://dl.dropboxusercontent.com/u/28565502/images/redface.png&quot; style=&quot;margin-right: 10px;&quot; width=&quot;50&quot; /&gt;

&lt;img alt=&quot;Compartir&quot; border=&quot;0&quot; height=&quot;50&quot; onclick=&quot;muestra_oculta(&#39;contenido_a_mostrar&#39;,2)&quot; onmouseout=&quot;this.src=&#39;https://dl.dropboxusercontent.com/u/28565502/images/twitterRed.png&#39;;&quot; onmouseover=&quot;this.src=&#39;https://dl.dropboxusercontent.com/u/28565502/images/twitterRedhover.png&#39;;&quot; src=&quot;https://dl.dropboxusercontent.com/u/28565502/images/twitterRed.png&quot; style=&quot;margin-right: 10px;&quot; width=&quot;50&quot; /&gt;

&lt;img alt=&quot;Compartir&quot; border=&quot;0&quot; height=&quot;50&quot; onclick=&quot;muestra_oculta(&#39;contenido_a_mostrar&#39;,3)&quot; onmouseout=&quot;this.src=&#39;https://dl.dropboxusercontent.com/u/28565502/images/LinkedIn-Logo.png&#39;;&quot; onmouseover=&quot;this.src=&#39;https://dl.dropboxusercontent.com/u/28565502/images/LinkedIn-Logohover.png&#39;;&quot; src=&quot;https://dl.dropboxusercontent.com/u/28565502/images/LinkedIn-Logo.png&quot; style=&quot;margin-right: 10px;&quot; width=&quot;50&quot; /&gt;

&lt;img alt=&quot;Compartir&quot; border=&quot;0&quot; height=&quot;50&quot; onclick=&quot;muestra_oculta(&#39;contenido_a_mostrar&#39;,4)&quot; onmouseout=&quot;this.src=&#39;https://dl.dropboxusercontent.com/u/28565502/images/rss.png&#39;;&quot; onmouseover=&quot;this.src=&#39;https://dl.dropboxusercontent.com/u/28565502/images/rsshover.png&#39;;&quot; src=&quot;https://dl.dropboxusercontent.com/u/28565502/images/rss.png&quot; style=&quot;margin-right: 10px;&quot; width=&quot;50&quot; /&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br /&gt;
&lt;div id=&quot;contenido_a_mostrar&quot;&gt;
&lt;/div&gt;
&lt;br /&gt;
&lt;table style=&quot;height: 360px;&quot;&gt;
&lt;tbody&gt;
&lt;tr&gt;
  &lt;td&gt;&lt;img alt=&quot;Thebestandroide&quot; height=&quot;70&quot; src=&quot;https://dl.dropboxusercontent.com/u/28565502/thebestandroide/firma/logoSoloRuedasChico.jpg&quot; width=&quot;70&quot; /&gt; 
  &lt;a href=&quot;http://thebestandroide.blogspot.com.es/2014/07/iOS-aprende-ejercicios.html&quot;&gt;Indice&lt;/a&gt; 
  &lt;/td&gt;
 &lt;td align=&quot;right&quot;&gt;&lt;img alt=&quot;Thebestandroide&quot; height=&quot;70&quot; src=&quot;https://dl.dropboxusercontent.com/u/28565502/thebestandroide/firma/logoSoloRuedasChico.jpg&quot; width=&quot;70&quot; /&gt; 
 
 &lt;a href=&quot;http://thebestandroide.blogspot.com.es/2014/09/ios-ejercicio-17-cargar-imagen-en.html&quot;&gt;Ejercicio anterior&lt;/a&gt; &lt;/td&gt;
  &lt;td align=&quot;right&quot;&gt;&lt;img alt=&quot;Thebestandroide&quot; height=&quot;70&quot; src=&quot;https://dl.dropboxusercontent.com/u/28565502/thebestandroide/firma/logoSoloRuedasChico.jpg&quot; width=&quot;70&quot; /&gt; 
  
 &lt;a href=&quot;http://thebestandroide.blogspot.com.es/2014/10/ios-ejercicio-19-reproduccion-mp3-en.html&quot;&gt;Siguiente ejercicio&lt;/a&gt; &lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
</description><link>http://thebestandroide.blogspot.com/2014/10/ios-ejercicio-18-haciendo-transicion.html</link><author>noreply@blogger.com (David)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgAwRth5zfWh3PVYGWKeqJB0Ho4Y3HPfOal1qJI0UNB-Yv5qxzMQWcWlIlIH7WoYjOzV-s4_N-dd8-MFdErnUTKKas4qD457cbx_uN8ksV77FKRqPTq1qthb8a8VbC-RGkBFDGpFkIfsHro/s72-c/cabezote2.jpg" height="72" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-1686662779713559896.post-7358147791450784069</guid><pubDate>Thu, 11 Sep 2014 09:30:00 +0000</pubDate><atom:updated>2014-09-11T10:30:16.448+01:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">cursos informatica gratis</category><category domain="http://www.blogger.com/atom/ns#">cursos online gratis</category><category domain="http://www.blogger.com/atom/ns#">cursos universitarios</category><title>Cursos universitarios gratuitos</title><description>Hola amiguetes developers!!&lt;br /&gt;
&lt;br /&gt;
He recibido la notificación de esta tanda de cursos universitarios de origen anglosajon y español que imparten varias universidades, son online y gratuitos, van desde Phyton a desarrollo de app´s android, e incluso OpenGL. Espero que le sirva a más de uno :&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: x-large;&quot;&gt;Cursos universitarios online gratuitos&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&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/AVvXsEhprrkgXCpLBmTsZm5d02-jPIVGpGVGYt_FzbZ4cdL5DhQLFg2AJ90ZV-4P9n_wpALqDVlcrS7J2fgHtbRvKKm1p3XaLe-XKZyDt1lDlMsf2Xxq7pJKnfr8NnBvqjiXGJu0SSwr6qOjPH-3/s1600/MOOCs.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/AVvXsEhprrkgXCpLBmTsZm5d02-jPIVGpGVGYt_FzbZ4cdL5DhQLFg2AJ90ZV-4P9n_wpALqDVlcrS7J2fgHtbRvKKm1p3XaLe-XKZyDt1lDlMsf2Xxq7pJKnfr8NnBvqjiXGJu0SSwr6qOjPH-3/s1600/MOOCs.png&quot; height=&quot;247&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;http://nr.news-republic.com/Web/ArticleWeb.aspx?regionid=7&amp;amp;articleid=28582572&amp;amp;m=d&quot;&gt;http://nr.news-republic.com/Web/ArticleWeb.aspx?regionid=7&amp;amp;articleid=28582572&amp;amp;m=d&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;script language=&quot;JavaScript&quot;&gt;
function muestra_oculta(id,tipo){
 var resultado=tipo
 var dir = document.location.href;
 var tit = document.title;
 var tit2 = encodeURIComponent(tit);
 var url =&quot;&quot;;
if(resultado==1){
 var url =&quot;http://www.facebook.com/share.php?u=&quot;+dir+&quot;&amp;t=&quot;+tit2
 window.open(url, &#39;TheBestAndroide&#39;);
}
if(resultado==2){
  var url =&quot;http://twitter.com/home?status=Estoy en &quot;+dir+&quot; leyendo &quot;+tit2
  window.open(url, &#39;TheBestAndroide&#39;);
}
if(resultado==3){
 var url =&quot;http://www.linkedin.com/shareArticle?mini=true&amp;url=&quot;+dir+&quot;&amp;title=&quot;+tit2+&quot;&amp;source=http://thebestandroide.blogspot.com.es/&quot;;
  window.open(url, &#39;TheBestAndroide&#39;);
}
if(resultado==4){
  var url =&quot;http://feeds.feedburner.com/Thebestandroide&quot;
  window.open(url, &#39;TheBestAndroide&#39;);
}

if (document.getElementById){ //se obtiene el id
var el = document.getElementById(id); //se define la variable &quot;el&quot; igual a nuestro div
el.style.display = (el.style.display == &#39;none&#39;) ? &#39;block&#39; : &#39;none&#39;; //damos un atributo display:none que oculta el div
}
}
window.onload = function(){/*hace que se cargue la función lo que predetermina que div estará oculto hasta llamar a la función nuevamente*/
muestra_oculta(&#39;contenido_a_mostrar&#39;);/* &quot;contenido_a_mostrar&quot; es el nombre que le dimos al DIV */
}
&lt;/script&gt;

&lt;br /&gt;
&lt;table style=&quot;width: 260px;&quot;&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;img alt=&quot;Compartir&quot; border=&quot;0&quot; height=&quot;50&quot; onclick=&quot;muestra_oculta(&#39;contenido_a_mostrar&#39;,1)&quot; src=&quot;https://dl.dropboxusercontent.com/u/28565502/images/redface.png&quot; 
onmouseover=&quot;this.src=&#39;https://dl.dropboxusercontent.com/u/28565502/images/redfacehover.png&#39;;&quot;
onmouseout=&quot;this.src=&#39;https://dl.dropboxusercontent.com/u/28565502/images/redface.png&#39;;&quot;
 style=&quot;margin-right: 10px;&quot; width=&quot;50&quot; /&gt;

&lt;img alt=&quot;Compartir&quot; border=&quot;0&quot; height=&quot;50&quot; onclick=&quot;muestra_oculta(&#39;contenido_a_mostrar&#39;,2)&quot; src=&quot;https://dl.dropboxusercontent.com/u/28565502/images/twitterRed.png&quot; 
onmouseover=&quot;this.src=&#39;https://dl.dropboxusercontent.com/u/28565502/images/twitterRedhover.png&#39;;&quot;
onmouseout=&quot;this.src=&#39;https://dl.dropboxusercontent.com/u/28565502/images/twitterRed.png&#39;;&quot;
 style=&quot;margin-right: 10px;&quot; width=&quot;50&quot; /&gt;

&lt;img alt=&quot;Compartir&quot; border=&quot;0&quot; height=&quot;50&quot; onclick=&quot;muestra_oculta(&#39;contenido_a_mostrar&#39;,3)&quot; src=&quot;https://dl.dropboxusercontent.com/u/28565502/images/LinkedIn-Logo.png&quot;
onmouseover=&quot;this.src=&#39;https://dl.dropboxusercontent.com/u/28565502/images/LinkedIn-Logohover.png&#39;;&quot;
onmouseout=&quot;this.src=&#39;https://dl.dropboxusercontent.com/u/28565502/images/LinkedIn-Logo.png&#39;;&quot;
 style=&quot;margin-right: 10px;&quot; width=&quot;50&quot; /&gt;

&lt;img alt=&quot;Compartir&quot; border=&quot;0&quot; height=&quot;50&quot; onclick=&quot;muestra_oculta(&#39;contenido_a_mostrar&#39;,4)&quot; src=&quot;https://dl.dropboxusercontent.com/u/28565502/images/rss.png&quot;
onmouseover=&quot;this.src=&#39;https://dl.dropboxusercontent.com/u/28565502/images/rsshover.png&#39;;&quot;
onmouseout=&quot;this.src=&#39;https://dl.dropboxusercontent.com/u/28565502/images/rss.png&#39;;&quot;
 style=&quot;margin-right: 10px;&quot; width=&quot;50&quot; /&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br /&gt;
&lt;div id=&quot;contenido_a_mostrar&quot;&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;</description><link>http://thebestandroide.blogspot.com/2014/09/cursos-universitarios-gratuitos.html</link><author>noreply@blogger.com (David)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhprrkgXCpLBmTsZm5d02-jPIVGpGVGYt_FzbZ4cdL5DhQLFg2AJ90ZV-4P9n_wpALqDVlcrS7J2fgHtbRvKKm1p3XaLe-XKZyDt1lDlMsf2Xxq7pJKnfr8NnBvqjiXGJu0SSwr6qOjPH-3/s72-c/MOOCs.png" height="72" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-1686662779713559896.post-5258915439569226961</guid><pubDate>Thu, 04 Sep 2014 10:03:00 +0000</pubDate><atom:updated>2014-10-05T16:27:53.107+01:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">developer iOS</category><category domain="http://www.blogger.com/atom/ns#">ejercicio iOS</category><category domain="http://www.blogger.com/atom/ns#">iOS imagen internet</category><category domain="http://www.blogger.com/atom/ns#">objetive C cargar imagen internet</category><category domain="http://www.blogger.com/atom/ns#">thebestandroide ejercicios ios</category><category domain="http://www.blogger.com/atom/ns#">UIImageview desde server</category><title>iOS : Ejercicio 17. Cargar imagen en UIImageView desde internet</title><description>&lt;a href=&quot;http://thebestandroide.blogspot.com.es/&quot;&gt;&lt;span style=&quot;color: #a5130f;&quot;&gt;Blog &lt;/span&gt;&lt;/a&gt;
&lt;span style=&quot;color: #a5130f;&quot;&gt;&lt;a href=&quot;http://thebestandroide.blogspot.com.es/2014/07/iOS-aprende-ejercicios.html&quot;&gt;&amp;gt;Lista ejercicios &amp;gt;&amp;nbsp;&lt;/a&gt;&lt;/span&gt;
&lt;span style=&quot;color: #a5130f;&quot;&gt;&lt;b&gt;Ejercicio 17&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Hola desarrolladores,vamos con el tutorial de ejercicios completando la parte de multihilos de iOS.
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&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/AVvXsEhaKNtoyoxpIinqKG7A9Lm3qDQ0vTu6BDrRcswPRtjJnxnwLyEKfzWhsjZaE4pFNA56NozLDVZcVoN18ttkrmyqBTuPB20l9uMOkBPB6R3wUHletYf6InucKErJMlomA7fNdWcpxE6eAkHC/s1600/cabezote2.jpg&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/AVvXsEhaKNtoyoxpIinqKG7A9Lm3qDQ0vTu6BDrRcswPRtjJnxnwLyEKfzWhsjZaE4pFNA56NozLDVZcVoN18ttkrmyqBTuPB20l9uMOkBPB6R3wUHletYf6InucKErJMlomA7fNdWcpxE6eAkHC/s1600/cabezote2.jpg&quot; height=&quot;131&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: x-large;&quot;&gt;Ejercicio 17: Conectarse a la red y cargar una imagen desde internet
&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Creamos un proyecto de la forma habitual,create new proyect - single view application. Ahí crearemos en el storyboard 2 objetos con sus correspondientes conexiones : una ImageView y un Button :&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&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/AVvXsEi8QbS46IbEL_6ePZAyXWBwGsXNQzWiOcoWStnnmrFRmK5zLBodB-WmAf_iOu1i3bjr8kILpSy0mGscUlQFha5ZNlVExeVoQ07_HhjPd4xEpxZYT5T_K99bNYTk_trk-IvB1xfTXXGVdlyQ/s1600/screenshot2.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/AVvXsEi8QbS46IbEL_6ePZAyXWBwGsXNQzWiOcoWStnnmrFRmK5zLBodB-WmAf_iOu1i3bjr8kILpSy0mGscUlQFha5ZNlVExeVoQ07_HhjPd4xEpxZYT5T_K99bNYTk_trk-IvB1xfTXXGVdlyQ/s1600/screenshot2.png&quot; height=&quot;369&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
Vamos a utilizar una variable de tipo NSData :&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: x-large;&quot;&gt;&lt;b&gt;NSData&lt;/b&gt; es un objeto  genérico para empaquetar buffers de datos, se usa para transmitir o guardar datos en estado puro.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Pero antes de eso, vamos a subir una imagen a un servidor para poder utilizarla, yo personalmente y entre otros uso dropbox, es gratuito, así que sino teneis no se que haceis con vuestra vida pero deberiais, se hace muy rapido, te registras y te bajas el cliente desde &lt;a href=&quot;http://www.dropbox.com/&quot; target=&quot;_blank&quot;&gt;aquí&lt;/a&gt;.&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&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/AVvXsEiRPmSpXGMT3wKX6pskupxDk464qj310BkEEBtt-UEDrpLdWnffDz8Z5fRdhaCKPMyAERyF9Ujxztqj5c4QUNfWJrDLNLbJKer6LwxWVe4yOE9ttfuDInkUc2eSO0wL6Apolc7qevE82vES/s1600/screenshot3.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/AVvXsEiRPmSpXGMT3wKX6pskupxDk464qj310BkEEBtt-UEDrpLdWnffDz8Z5fRdhaCKPMyAERyF9Ujxztqj5c4QUNfWJrDLNLbJKer6LwxWVe4yOE9ttfuDInkUc2eSO0wL6Apolc7qevE82vES/s1600/screenshot3.png&quot; height=&quot;224&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
Ahora subimos esta imagen o la que elijamos (que friquis somos los informáticos) :&lt;br /&gt;
&lt;br /&gt;
&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/AVvXsEj32DcbEp4tXjtdG_pKkFwjiZ8ZMKeA7FKJ5qSD1TPP8FqJQVsf3rvxgNYJwM8ZsQNminMozRaMHkU5sObfv99xQxci2bSxNmSfWc1zIb85ht2pwAAtzvbBFEGrOglTtDQJPuIypIXTX65E/s1600/image.jpg&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/AVvXsEj32DcbEp4tXjtdG_pKkFwjiZ8ZMKeA7FKJ5qSD1TPP8FqJQVsf3rvxgNYJwM8ZsQNminMozRaMHkU5sObfv99xQxci2bSxNmSfWc1zIb85ht2pwAAtzvbBFEGrOglTtDQJPuIypIXTX65E/s1600/image.jpg&quot; height=&quot;300&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Y una vez la imágen ha sido subida a arriba botón derecho - copiar enlace publico. Bien por la política de dropbox para que sea público tenemos 2 opciones, o moverla a la carpeta que nos crea por defecto dropbox llamada &quot;Public&quot; o cambiamos las tres www por dl de tal manera que nos queda el enlace así :
&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
https://dl.dropbox.com/s/oulaen0jeknx718/img.jpg?dl=0
&lt;br /&gt;
&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/AVvXsEipWBtFdycaX62V1Fa4cprNALrkulH8vxIGB1jaPLLQHdtS8NlRMBgfLyV3hN8JKhuHVB0hcSxkrbGdYYEdzM-xKYl71flKXlX24DhuViw8r6EM6l9ITwVvHxifIqIz_hzopyouZe8U9aDF/s1600/screenshot4.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/AVvXsEipWBtFdycaX62V1Fa4cprNALrkulH8vxIGB1jaPLLQHdtS8NlRMBgfLyV3hN8JKhuHVB0hcSxkrbGdYYEdzM-xKYl71flKXlX24DhuViw8r6EM6l9ITwVvHxifIqIz_hzopyouZe8U9aDF/s1600/screenshot4.png&quot; height=&quot;202&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Volvamos a XCode y en el .m donde la función de acción del botón, creamos el archivo NSData junto a otra variable NSUrl donde esta la url de nuestra imagen :
&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush: objc;&quot;&gt;@interface ViewController : UIViewController
@property (weak, nonatomic) IBOutlet UIImageView *Img;
- (IBAction)botonAccionImg:(id)sender;
@end
- (IBAction)botonAccionImg:(id)sender {
    //URL IMAGEN
    NSURL *url= [NSURL URLWithString:@&quot;https://dl.dropbox.com/s/oulaen0jeknx718/image.jpg?dl=0&quot;];
    //NSDATA CON URL
    NSData *dato=[NSData dataWithContentsOfURL:url];
    //LO CARGAMOS EN LA IMAGEN
    [self.Img setImage=[UIImage imageWithData:dato]];
}
&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Ejecutamos el proyecto y al pulsar el boton de &quot;Cargar Imagen&quot; se carga nuestra imagen perfectamente, sólo que hay una pega, desde que se pulsa el botón, hasta que se carga la imagen, no podemos hacer nada es decir, en este proyecto sólo hay un boton con el que interactuar, pero si hubiera más elementos con los que interactuar, no podríamos tocarlos.
&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
(Podeis probar insertando un tab-bar y pulsando sobre las opciones, ya vereis que no os deja)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Para que esto no ocurra, ya que de cara al usuario no queda bien que mientras se ande cargando algo se quede el teléfono como colgado,ya que tecnicamente no es así, pero da esa impresión, hay que meter este proceso en un hilo, y eso lo hacemos de la siguiente manera :

&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush: objc;&quot;&gt; @implementation ViewController

- (void)viewDidLoad

{
    [super viewDidLoad];
}

- (IBAction)botonAccionImg:(id)sender {
    //GESTOR DE HILOS (COLA)
    NSOperationQueue *cola=[NSOperationQueue new];
    //OPERACION A LANZAR
    //initwITHtARGET:self (sobre esta clase)
    //selector:metodo a ejecutar en el hilo que estamos creando
    //object: objeto a mandar a ese metodo
    NSInvocationOperation *operacion = [[NSInvocationOperation alloc]initWithTarget:self selector:@selector(cargarImagen) object:nil];
    //añadimos la operacion a la cola
    [cola addOperation:operacion];
}

-(void) cargarImagen{
    //URL IMAGEN
    NSURL *url= [NSURL URLWithString:@&quot;https://dl.dropbox.com/s/oulaen0jeknx718/image.jpg?dl=0&quot;];
    //NSDATA CON URL
    NSData *dato=[NSData dataWithContentsOfURL:url];
    //LO CARGAMOS EN UN OBJETO IMAGE
    UIImage *Img = [UIImage imageWithData:dato];
    //Volvemos al hilo principal
    [self.Img performSelectorOnMainThread:@selector(setImage:) withObject:Img waitUntilDone:YES];
}
@end 
&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&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/AVvXsEjsm1fqulq1ekMxtJE-nLmF-o3LYVy6GwK7Jmp0Mydow8-fwE5gg3Y2RQtwEJqzm9Q02TijhXv4qQ6d2NHRt8RmvILT1pa9Plba8y3ymEmWSgHFOkqWMNy-HtdnuNG88TXX7Ig20d-nKlWp/s1600/screenshot5.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/AVvXsEjsm1fqulq1ekMxtJE-nLmF-o3LYVy6GwK7Jmp0Mydow8-fwE5gg3Y2RQtwEJqzm9Q02TijhXv4qQ6d2NHRt8RmvILT1pa9Plba8y3ymEmWSgHFOkqWMNy-HtdnuNG88TXX7Ig20d-nKlWp/s1600/screenshot5.png&quot; height=&quot;640&quot; width=&quot;425&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;script language=&quot;JavaScript&quot;&gt;
function muestra_oculta(id,tipo){
 var resultado=tipo
 var dir = document.location.href;
 var tit = document.title;
 var tit2 = encodeURIComponent(tit);
 var url =&quot;&quot;;
if(resultado==1){
 var url =&quot;http://www.facebook.com/share.php?u=&quot;+dir+&quot;&amp;t=&quot;+tit2
 window.open(url, &#39;TheBestAndroide&#39;);
}
if(resultado==2){
  var url =&quot;http://twitter.com/home?status=Estoy en &quot;+dir+&quot; leyendo &quot;+tit2
  window.open(url, &#39;TheBestAndroide&#39;);
}
if(resultado==3){
 var url =&quot;http://www.linkedin.com/shareArticle?mini=true&amp;url=&quot;+dir+&quot;&amp;title=&quot;+tit2+&quot;&amp;source=http://thebestandroide.blogspot.com.es/&quot;;
  window.open(url, &#39;TheBestAndroide&#39;);
}
if(resultado==4){
  var url =&quot;http://feeds.feedburner.com/Thebestandroide&quot;
  window.open(url, &#39;TheBestAndroide&#39;);
}

if (document.getElementById){ //se obtiene el id
var el = document.getElementById(id); //se define la variable &quot;el&quot; igual a nuestro div
el.style.display = (el.style.display == &#39;none&#39;) ? &#39;block&#39; : &#39;none&#39;; //damos un atributo display:none que oculta el div
}
}
window.onload = function(){/*hace que se cargue la función lo que predetermina que div estará oculto hasta llamar a la función nuevamente*/
muestra_oculta(&#39;contenido_a_mostrar&#39;);/* &quot;contenido_a_mostrar&quot; es el nombre que le dimos al DIV */
}
&lt;/script&gt;

&lt;br /&gt;
&lt;table style=&quot;width: 260px;&quot;&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;img alt=&quot;Compartir&quot; border=&quot;0&quot; height=&quot;50&quot; onclick=&quot;muestra_oculta(&#39;contenido_a_mostrar&#39;,1)&quot; onmouseout=&quot;this.src=&#39;https://dl.dropboxusercontent.com/u/28565502/images/redface.png&#39;;&quot; onmouseover=&quot;this.src=&#39;https://dl.dropboxusercontent.com/u/28565502/images/redfacehover.png&#39;;&quot; src=&quot;https://dl.dropboxusercontent.com/u/28565502/images/redface.png&quot; style=&quot;margin-right: 10px;&quot; width=&quot;50&quot; /&gt;

&lt;img alt=&quot;Compartir&quot; border=&quot;0&quot; height=&quot;50&quot; onclick=&quot;muestra_oculta(&#39;contenido_a_mostrar&#39;,2)&quot; onmouseout=&quot;this.src=&#39;https://dl.dropboxusercontent.com/u/28565502/images/twitterRed.png&#39;;&quot; onmouseover=&quot;this.src=&#39;https://dl.dropboxusercontent.com/u/28565502/images/twitterRedhover.png&#39;;&quot; src=&quot;https://dl.dropboxusercontent.com/u/28565502/images/twitterRed.png&quot; style=&quot;margin-right: 10px;&quot; width=&quot;50&quot; /&gt;

&lt;img alt=&quot;Compartir&quot; border=&quot;0&quot; height=&quot;50&quot; onclick=&quot;muestra_oculta(&#39;contenido_a_mostrar&#39;,3)&quot; onmouseout=&quot;this.src=&#39;https://dl.dropboxusercontent.com/u/28565502/images/LinkedIn-Logo.png&#39;;&quot; onmouseover=&quot;this.src=&#39;https://dl.dropboxusercontent.com/u/28565502/images/LinkedIn-Logohover.png&#39;;&quot; src=&quot;https://dl.dropboxusercontent.com/u/28565502/images/LinkedIn-Logo.png&quot; style=&quot;margin-right: 10px;&quot; width=&quot;50&quot; /&gt;

&lt;img alt=&quot;Compartir&quot; border=&quot;0&quot; height=&quot;50&quot; onclick=&quot;muestra_oculta(&#39;contenido_a_mostrar&#39;,4)&quot; onmouseout=&quot;this.src=&#39;https://dl.dropboxusercontent.com/u/28565502/images/rss.png&#39;;&quot; onmouseover=&quot;this.src=&#39;https://dl.dropboxusercontent.com/u/28565502/images/rsshover.png&#39;;&quot; src=&quot;https://dl.dropboxusercontent.com/u/28565502/images/rss.png&quot; style=&quot;margin-right: 10px;&quot; width=&quot;50&quot; /&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br /&gt;
&lt;div id=&quot;contenido_a_mostrar&quot;&gt;
&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;table style=&quot;height: 360px;&quot;&gt;
&lt;tbody&gt;
&lt;tr&gt;
  &lt;td&gt;&lt;img alt=&quot;Thebestandroide&quot; height=&quot;70&quot; src=&quot;https://dl.dropboxusercontent.com/u/28565502/thebestandroide/firma/logoSoloRuedasChico.jpg&quot; width=&quot;70&quot; /&gt; 
  &lt;a href=&quot;http://thebestandroide.blogspot.com.es/2014/07/iOS-aprende-ejercicios.html&quot;&gt;Indice&lt;/a&gt; 
  &lt;/td&gt;
 &lt;td align=&quot;right&quot;&gt;&lt;img alt=&quot;Thebestandroide&quot; height=&quot;70&quot; src=&quot;https://dl.dropboxusercontent.com/u/28565502/thebestandroide/firma/logoSoloRuedasChico.jpg&quot; width=&quot;70&quot; /&gt; 
 
 &lt;a href=&quot;http://thebestandroide.blogspot.com.es/2014/09/ios-ejercicio-16-multitasking-preparar.html&quot;&gt;Ejercicio anterior&lt;/a&gt; &lt;/td&gt;
  &lt;td align=&quot;right&quot;&gt;&lt;img alt=&quot;Thebestandroide&quot; height=&quot;70&quot; src=&quot;https://dl.dropboxusercontent.com/u/28565502/thebestandroide/firma/logoSoloRuedasChico.jpg&quot; width=&quot;70&quot; /&gt; 
  
 &lt;a href=&quot;http://thebestandroide.blogspot.com.es/2014/10/ios-ejercicio-18-haciendo-transicion.html&quot;&gt;Siguiente ejercicio&lt;/a&gt; &lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
</description><link>http://thebestandroide.blogspot.com/2014/09/ios-ejercicio-17-cargar-imagen-en.html</link><author>noreply@blogger.com (David)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhaKNtoyoxpIinqKG7A9Lm3qDQ0vTu6BDrRcswPRtjJnxnwLyEKfzWhsjZaE4pFNA56NozLDVZcVoN18ttkrmyqBTuPB20l9uMOkBPB6R3wUHletYf6InucKErJMlomA7fNdWcpxE6eAkHC/s72-c/cabezote2.jpg" height="72" width="72"/><thr:total>0</thr:total></item></channel></rss>