Android 通用图像库上的getApplicationContext()未定义?

Android 通用图像库上的getApplicationContext()未定义?,android,universal-image-loader,Android,Universal Image Loader,我正在尝试从阵列加载一些图像,下面是我的时间表适配器。 只是获取未定义的上下文。不知道该怎么办? 此外,未加载任何图像 public class Schedule_ArrayAdapter extends ArrayAdapter<String> { private final Activity activity; private final String[] name, category, image; Typeface colab, colab_bold, Bebas; int

我正在尝试从阵列加载一些图像,下面是我的时间表适配器。 只是获取未定义的上下文。不知道该怎么办? 此外,未加载任何图像

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();
public class Schedule\u ArrayAdapter扩展了ArrayAdapter{
私人最终活动;
私有最终字符串[]名称、类别、图像;
字体为colab,colab_粗体,Bebas;
选定的整数=-1;
公共计划_ArrayAdapter(活动活动,字符串[]名称,字符串[]类别,字符串[]图像){
超级(活动、R.layout.schedule_项目、类别);
这个。活动=活动;
this.name=名称;
this.category=类别;
这个图像=图像;
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(配置);
imageLoader=imageLoader.getInstance();
}
ImageLoaderConfiguration配置=新建ImageLoaderConfiguration.Builder(getApplicationContext())
.memoryCache(新的WeakMemoryCache())
.DenycacheMageMultipleSizesInMemory()
.线程池大小(5)
.enableLogging()
.build();
DisplayImageOptions=new DisplayImageOptions.Builder()
.cacheOnDisc()
.cacheInMemory()
.build();
ImageLoader ImageLoader=ImageLoader.getInstance();

只需使用
activity.getApplicationContext()
而不是
getApplicationContext()


当前类继承自ArrayAdapter,而ArrayAdapter不是上下文的子类。
getApplicationContext()
方法仅在继承自上下文的类中可用,如
Activities
Services
BroadcastReceivers

只需使用
activity.getApplicationContext()
而不是
getApplicationContext()


当前类继承自ArrayAdapter,而ArrayAdapter不是上下文的子类。
getApplicationContext()
方法仅在从上下文继承的类中可用,如使用activity.getApplicationContext()时的
Activities
Services
BroadcastReceivers

它说,空白领域可能还没有被正式化。它指的是活动活动,并要求我删除最终。因此,从私人最终活动活动;到私人活动活动,“Sam You将不得不删除最终。当你宣布某事是最终的,这意味着你不能改变其创造后的价值,所以它不会得到驴。已签名。删除Final会在该行上出现空指针异常。我认为这可能是另一个问题。您确定接收到有效的活动实例吗?是的,它正在接收有效的活动实例。我认为我的代码中存在一些问题,应在适配器中设置映像。当我使用Activity.getApplication时上下文()它说,空白领域可能还没有被正式化。它指的是活动活动,并要求我删除最终。因此,从私人最终活动活动;到私人活动活动,“Sam You将不得不删除最终。当你宣布某事是最终的,这意味着你不能改变其创造后的价值,所以它不会得到驴。已签名。删除Final会在该行出现空指针异常。我认为这可能是另一个问题。是否确实接收到有效的活动实例?是的,它接收到有效的活动实例。我认为我的代码存在一些问题,应该在适配器中设置映像。