0

I have problem, I am using this answer:https://stackoverflow.com/a/7442725/3569225 to make images url automatically change to images. But when I try to create the URLImageParser I need to give him context. I am doing this in the ViewHandler and I dont have there getApplicationContext command. This is the code I am trying to do:
@Override public void onBindViewHolder(ViewHolder holder, int position) { ... UrlImageParser p = new UrlImageParser(holder.message, this); holder.message.setText(Html.fromHtml(MessageItems.get(position).getMessage())); ... }

I need to replace 'this' with the context, But I dont have it, What can I do?

Community
  • 1
  • 1
Haim127
  • 585
  • 2
  • 8
  • 29

1 Answers1

0

Follow sample example to understand how to pass a context to an adapter.

private Context context; 
public myAdapter(Context context,....){  
    this.context = context;  
} 

Now you can use the context from anywhere inside of your adapter.

Kosh
  • 6,140
  • 3
  • 36
  • 67