title: Asynctask inside Adapterview class
body: <p>I'm trying to change fonts of listview items. Without AsyncTasc it takes too much time. Using AsyncTask activity with that listview emerges fast and then after instance application crashes. I know that I can't change UI from AsyncTasc directly.What could I use? Thanks in advance</p>
  
  <pre><code>import ru.ayratbadykov.feedhandler.FEED;
  import ru.ayratbadykov.feedhandler.RssMessage;
  import android.content.Context;
  import android.graphics.Typeface;
  import android.os.AsyncTask;
  import android.util.Log;
  import android.view.LayoutInflater;
  import android.view.View;
  import android.view.ViewGroup;
  import android.widget.BaseAdapter;
  import android.widget.TextView;
  
  public class CustomAdapter extends BaseAdapter {
      private FEED _data;
      Context _c;
  
      CustomAdapter(FEED data, Context c) {
          _data = data;
          _c = c;
      }
  
      @Override
      public View getView(int position, View convertView, ViewGroup parent) {
          // TODO Auto-generated method stub
          Log.w("here","here");
          View v = convertView;
          if (v == null) {
              LayoutInflater vi = (LayoutInflater) _c
                      .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
              v = vi.inflate(R.layout.customadapter, null);
          }
  
          TextView fromView = (TextView) v.findViewById(R.id.textView1);
          TextView subView = (TextView) v.findViewById(R.id.textView2);
          TextView View = (TextView) v.findViewById(R.id.textView3);
  
          RssMessage msg = _data.getMessages().get(position);
          new Font().execute(fromView,subView,View);
  
  
  
  
  
          fromView.setText(msg.getTitle());
          subView.setText(msg.getPUBDATE());
          View.setText(_data.getTitle());
  
          return v;
      }
      public class Font extends AsyncTask&lt;TextView, Void, Boolean&gt; {
  
          @Override
          protected Boolean doInBackground(TextView... params) {
              // TODO Auto-generated method stub
              String fontPath = "fonts/Qlassik_TB.ttf";
              Typeface tf = Typeface.createFromAsset(_c.getAssets(), fontPath);
              params[0].setTypeface(tf);
              fontPath="fonts/damase.ttf";
  
              tf = Typeface.createFromAsset(_c.getAssets(), fontPath);
              params[1].setTypeface(tf);
  
              tf = Typeface.createFromAsset(_c.getAssets(), fontPath);
              params[3].setTypeface(tf);
              return true;
  
          }
  
      }
  
      @Override
      public int getCount() {
          // TODO Auto-generated method stub
          return _data.getMessages().size();
  
      }
  
      @Override
      public Object getItem(int position) {
          // TODO Auto-generated method stub
          return _data.getMessages().get(position);
      }
  
      @Override
      public long getItemId(int position) {
          // TODO Auto-generated method stub
          return position;
      }
  }
  </code></pre>
  
  <p>log</p>
  
  <pre><code>05-31 22:32:27.602: E/AndroidRuntime(2803): FATAL EXCEPTION: AsyncTask #1
      05-31 22:32:27.602: E/AndroidRuntime(2803): java.lang.RuntimeException: An error occured while executing doInBackground()
      05-31 22:32:27.602: E/AndroidRuntime(2803):     at android.os.AsyncTask$3.done(AsyncTask.java:200)
      05-31 22:32:27.602: E/AndroidRuntime(2803):     at java.util.concurrent.FutureTask$Sync.innerSetException(FutureTask.java:274)
      05-31 22:32:27.602: E/AndroidRuntime(2803):     at java.util.concurrent.FutureTask.setException(FutureTask.java:125)
      05-31 22:32:27.602: E/AndroidRuntime(2803):     at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:308)
      05-31 22:32:27.602: E/AndroidRuntime(2803):     at java.util.concurrent.FutureTask.run(FutureTask.java:138)
      05-31 22:32:27.602: E/AndroidRuntime(2803):     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1088)
      05-31 22:32:27.602: E/AndroidRuntime(2803):     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:581)
      05-31 22:32:27.602: E/AndroidRuntime(2803):     at java.lang.Thread.run(Thread.java:1019)
      05-31 22:32:27.602: E/AndroidRuntime(2803): Caused by: java.lang.RuntimeException: Can't create handler inside thread that has not called Looper.prepare()
      05-31 22:32:27.602: E/AndroidRuntime(2803):     at android.os.Handler.&lt;init&gt;(Handler.java:121)
      05-31 22:32:27.602: E/AndroidRuntime(2803):     at ru.ayratbadykov.rssunion.CustomAdapter$Font$1.&lt;init&gt;(CustomAdapter.java:63)
      05-31 22:32:27.602: E/AndroidRuntime(2803):     at ru.ayratbadykov.rssunion.CustomAdapter$Font.doInBackground(CustomAdapter.java:63)
      05-31 22:32:27.602: E/AndroidRuntime(2803):     at ru.ayratbadykov.rssunion.CustomAdapter$Font.doInBackground(CustomAdapter.java:1)
      05-31 22:32:27.602: E/AndroidRuntime(2803):     at android.os.AsyncTask$2.call(AsyncTask.java:185)
      05-31 22:32:27.602: E/AndroidRuntime(2803):     at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:306)
      05-31 22:32:27.602: E/AndroidRuntime(2803):     ... 4 more
  </code></pre>