title: How can i use custom fonts on ViewPager?
body: <p>i have an Android application which is using ViewPager and it works correctly, but now i want to add custom fonts to my view, when i slide across pages i change the layout.It is my code:</p>
  
  <pre><code>import com.viewpagerindicator.TitlePageIndicator;
  import com.viewpagerindicator.TitleProvider;
  import android.app.Activity;
  import android.content.Context;
  import android.graphics.Typeface;
  import android.os.Bundle;
  import android.os.Parcelable;
  import android.support.v4.view.PagerAdapter;
  import android.support.v4.view.ViewPager;
  import android.view.LayoutInflater;
  import android.view.View;
  import android.widget.LinearLayout;
  import android.widget.TextView;
  
  /** *************************************************************************************************
  /** Clase:   public class LCMeter extends Activity
  /** Notas:   esta Activity usa desplazamiento por paginas horizontal
  /** Funcion: obtiene de puerto USB los datos de frecuencia, inductancia, capacitancia y los muestra
  /**          con multiples funciones como creacion de graficos, logs, etc
  ****************************************************************************************************/
  public class LCMeter extends Activity {
  
      // titulos de las paginas
      private static String[] titulosPaginas = { "APP 1", "APP 2", "APP 3" };
      private Context cxt;
      private ViewPager columnas;
      private ColumnasAdapter myAdapter;
      TextView txt;
  
      /** Called when the activity is first created. */
      @Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.main);  //layout con PagerViewer
          cxt = this;
  
          myAdapter = new ColumnasAdapter();
          columnas = (ViewPager) findViewById(R.id.columnas);
          columnas.setAdapter(myAdapter);
  
          // Agrega los titulos
          TitlePageIndicator titleIndicator = (TitlePageIndicator) findViewById(R.id.titulos);    //layout XML
          titleIndicator.setViewPager(columnas);
      }
  
  /** *************************************************************************************************
  /** Clase:   private class ColumnasAdapter extends Pager Adapter implements TitleProvider
  /** Notas:   extends PagerAdapter hace uso de la libreria y al usar implements TitleProvider permite
  /**          colocar titulos a las paginas por las que nos movemos
  /** Funcion: crea paginas por las cuales deslizarse hotizontalmente cambiando los Layout
  ****************************************************************************************************/
      private class ColumnasAdapter extends PagerAdapter implements TitleProvider {
  
          /// Obtiene numero de paginas en este caso el numero de elementos en el String
          @Override
          public int getCount() {
              return titulosPaginas.length;
          }
  
          // Obtiene el titulo para ponerle a la pagina
          @Override
          public String getTitle(int position) {
              // TODO Auto-generated method stub
              return titulosPaginas[position];    // titulo de la pagina
          }
  
          //Cambia los layout de acuerdo a las paginas
          @Override
          public Object instantiateItem(View collection, int position) {
              LinearLayout v = (LinearLayout) LayoutInflater.from(cxt).inflate(R.layout.lcmeter, null);
  
              // Ejecuto una Activity de acuerdo a la pagina en la que este
              switch (position) {
              case 0:
                  v = (LinearLayout) LayoutInflater.from(cxt).inflate(R.layout.lcmeter, null);
                  break;
              }
  
              ((ViewPager) collection).addView(v, 0);
  
              return v;
          }
  
          //Destruye las paginas cuando dejan de usarse
          @Override
          public void destroyItem(View collection, int position, Object view) {
              ((ViewPager) collection).removeView((LinearLayout)view);
          }
  
          @Override
          public boolean isViewFromObject(View view, Object object) {
              return view == ((LinearLayout) object);
          }
  
          @Override
          public void finishUpdate(View arg0) {}
  
          @Override
          public void restoreState(Parcelable arg0, ClassLoader arg1) {}
  
          @Override
          public Parcelable saveState() {
              return null;
          }
  
          @Override
          public void startUpdate(View arg0) {}
  
      }
  }
  </code></pre>
  
  <p>I want to add custom fonts on the layout called "lcmeter" but when i put it:</p>
  
  <pre><code>TextView txt = (TextView) findViewById(R.id.custom_font);  
  Typeface font = Typeface.createFromAsset(getAssets(), "Chantelli_Antiqua.ttf");  
  txt.setTypeface(font);
  </code></pre>
  
  <p>I get FC when running application but when i put the same code on a simple Activity whitout ViewPager it works perfectly i think the problem is on:</p>
  
  <pre><code>Typeface font = Typeface.createFromAsset(getAssets(), "Chantelli_Antiqua.ttf");
  </code></pre>
  
  <p>Maybe the context is not the right but i am new at this so i dont know too much.
  Thanks you :)</p>