title: Custom TextView font not applied on setting text from java android
body: <p>I have created a Custom TextView to use Font Awesome support, its working fine when you add the text (unicode <code>&amp;#xf179;</code>) in layout xml. But if am trying to set the text from my Adapter dynamically using <code>view.setText()</code>, its not applying the font.</p>
  
  <p><strong>FontView class</strong></p>
  
  <pre><code>public class FontView extends TextView {
      private static final String TAG = FontView.class.getSimpleName();
      //Cache the font load status to improve performance
      private static Typeface font;
  
      public FontView(Context context) {
          super(context);
          setFont(context);
      }
  
      public FontView(Context context, AttributeSet attrs) {
          super(context, attrs);
          setFont(context);
      }
  
      public FontView(Context context, AttributeSet attrs, int defStyleAttr) {
          super(context, attrs, defStyleAttr);
          setFont(context);
      }
  
      private void setFont(Context context) {
          // prevent exception in Android Studio / ADT interface builder
          if (this.isInEditMode()) {
              return;
          }
  
          //Check for font is already loaded
          if(font == null) {
              try {
                  font = Typeface.createFromAsset(context.getAssets(), "fontawesome-webfont.ttf");
                  Log.d(TAG, "Font awesome loaded");
              } catch (RuntimeException e) {
                  Log.e(TAG, "Font awesome not loaded");
              }
          }
  
          //Finally set the font
          setTypeface(font);
      }
  }
  </code></pre>
  
  <p><strong>XML for Layout</strong></p>
  
  <pre><code> &lt;com.domain.app.FontView
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:textSize="60sp"
      android:textAlignment="center"
      android:text="&amp;#xf179;"
      android:gravity="center"
      android:id="@+id/iconView"
      android:background="@drawable/oval"
      android:padding="10dp"
      android:layout_margin="10dp" /&gt;
  </code></pre>
  
  <p><strong>My Adapter</strong> </p>
  
  <pre><code>@Override
  public View getView(int position, View convertView, ViewGroup parent) {
      View v = convertView;
      IconListHolder viewHolder;
  
      if( convertView == null ) {
          LayoutInflater layoutInflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
          v = layoutInflater.inflate(R.layout.icon, null);
          viewHolder = new IconListHolder(v);
          v.setTag(viewHolder);
      } else {
          viewHolder = (IconListHolder) v.getTag();
      }
  
      //Set the text and Icon
      viewHolder.textViewIcon.setText(pages.get(position).getIcon());
  
      viewHolder.textViewName.setText(pages.get(position).getTitle());
  
      return v;
  }
  
  private class IconListHolder {
      public FontView textViewIcon;
      public TextView textViewName;
  
      public IconListHolder(View base) {
          textViewIcon = (FontView) base.findViewById(R.id.iconView);
          textViewName = (TextView) base.findViewById(R.id.iconTextView);
      }
  }
  </code></pre>
  
  <p>Please help whats am doing wrong.</p>