Instantiating Custom Adapter by passing Activity
<p>I am trying to call the <code>LazyAdapter</code> constructor for setting the <code>ListView</code>. And I always see a <code>red line</code> on <code>new LazyAdapter(this, mStrings);</code> asking to resolve this. I am not sure what should I add here in place of this, so that it can start working. When I try to replace this with <code>getApplicationContext</code> then I always get error as <code>ClassCastException</code>. Any thoughts what I need to add inplace of <code>this</code>?</p>

<pre><code>@Override
protected void onPostExecute(ArrayList&lt;User&gt; response) {

    if (response!=null) {
           adapter=new LazyAdapter(this, mStrings);
           listView.setAdapter(adapter);
    }

for(User user : response){
 //Doing Some Stuff Here    

}

}
</code></pre>

<p>And <code>LazyAdapter</code> constructor is something like this-</p>

<pre><code>public LazyAdapter(Activity a, String[] d) {
        activity = a;
        data=d;
        inflater = (LayoutInflater)activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        imageLoader=new ImageLoader(activity.getApplicationContext());
    }
</code></pre>

<p><strong>Update:-</strong></p>

<p>My LazyAdapter full code-</p>

<pre><code>public class LazyAdapter extends BaseAdapter {

    private Activity activity;
    private String[] data;
    private static LayoutInflater inflater=null;
    public ImageLoader imageLoader; 

    public LazyAdapter(Activity a, String[] d) {
        activity = a;
        data=d;
        inflater = (LayoutInflater)activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        imageLoader=new ImageLoader(activity.getApplicationContext());
    }

    public int getCount() {
        return data.length;
    }

    public Object getItem(int position) {
        return position;
    }

    public long getItemId(int position) {
        return position;
    }

    public View getView(int position, View convertView, ViewGroup parent) {
        View vi=convertView;
        if(convertView==null)
            vi = inflater.inflate(R.layout.item, null);

        TextView text=(TextView)vi.findViewById(R.id.text);;
        ImageView image=(ImageView)vi.findViewById(R.id.image);
        text.setText("item "+position);
        imageLoader.DisplayImage(data[position], image);
        return vi;
    }
}
</code></pre>
