我试图在应用程序的主要类中使用AsyncTask作为练习。我包含了我试图理解的基本代码。错误是DownloadFilesTask must be declared abstract or implement abstract method doInBackground
Java代码;
import android.media.Image;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.os.AsyncTask;
import android.widget.ImageView;
public class MainActivity extends AppCompatActivity {
ImageView image = (ImageView)findViewById(R.id.BackGroundForAll);
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
private class DownloadFilesTask extends AsyncTask<Void, Void, Void> {
protected Long doInBackground(Void....Void) {
}
protected void onProgressUpdate(Integer... progress) {
}
protected void onPostExecute(Long result) {
}
}
}
答案 0 :(得分:1)
你的错误在于:
@Override
protected Long doInBackground(Void... params) {
}
您应该将其替换为:
@Override
protected Long doInBackground(Void... params) {
}
还记得在那里实际返回一些东西,否则你会得到另一个错误;)