【发布时间】:2012-07-12 04:47:05
【问题描述】:
我有一个静态类需要调用另一个,第一个是静态的,阻止我调用第二个并出现以下错误:
No enclosing instance of type Studies is accessible. Must qualify the allocation with an enclosing instance of type Studies (e.g. x.new A() where x is
an instance of Studies).
AsyncTask 类
class DownloadFileAsync extends AsyncTask<String, String, String> {
@Override
protected void onPreExecute() {}
@Override
protected String doInBackground(String... aurl) {}
}
静态类
public static void startDownload(int id) {
ERROR LINE--> new DownloadFileAsync().execute("SOME URL");
}
谢谢!
【问题讨论】:
-
看来您的问题不是
AsyncTask本身,而是未正确启动或在此范围内无法访问的研究对象。 -
怎样才能做到无障碍?
-
如果研究是非静态的,那么您可以将其作为参数传递给 startDownload
-
研究是静态的:private static ArrayList
研究;
标签: android android-asynctask static-class