I am trying to load some images from the array and the following is my schedule adapter. Just getting undefined context. Not sure what to do ? Also no images are being loaded
public class Schedule_ArrayAdapter extends ArrayAdapter<String> {
private final Activity activity;
private final String[] name, category, image;
Typeface colab, colab_bold, Bebas;
int selected = -1;
public Schedule_ArrayAdapter(Activity activity, String[] name, String[] category, String[] image) {
super(activity, R.layout.schedule_item, category);
this.activity = activity;
this.name = name;
this.category = category;
this.image = image;
this.colab = Typeface.createFromAsset(activity.getAssets(), "ColabThi.otf");
this.colab_bold = Typeface.createFromAsset(activity.getAssets(), "ColabMed.otf");
this.colab_bold = Typeface.createFromAsset(activity.getAssets(), "BebasNeue.otf");
// ImageLoader.getInstance().init(config);
imageLoader = ImageLoader.getInstance();
}
ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(getApplicationContext())
.memoryCache(new WeakMemoryCache())
.denyCacheImageMultipleSizesInMemory()
.threadPoolSize(5)
.enableLogging()
.build();
DisplayImageOptions options = new DisplayImageOptions.Builder()
.cacheOnDisc()
.cacheInMemory()
.build();
ImageLoader imageLoader= ImageLoader.getInstance();
Simply use activity.getApplicationContext()
instead of getApplicationContext()
Your current class inherits from ArrayAdapter, which is not a subclass of Context. The getApplicationContext()
method is only available in classes inheriting from Context, like Activities
, Services
and BroadcastReceivers
.