這是<String, Void, Bitmap>
下面的代碼是什麼?我甚至不知道甚至調用了這個語法。Java泛型 - 這是什麼語法?
private class DownloadImageTask extends AsyncTask<String, Void, Bitmap> {
}
下面是原來的代碼(從這裏實測值:http://developer.android.com/guide/components/processes-and-threads.html):
public void onClick(View v) {
new DownloadImageTask().execute("http://example.com/image.png");
}
private class DownloadImageTask extends AsyncTask<String, Void, Bitmap> {
/** The system calls this to perform work in a worker thread and
* delivers it the parameters given to AsyncTask.execute() */
protected Bitmap doInBackground(String... urls) {
return loadImageFromNetwork(urls[0]);
}
/** The system calls this to perform work in the UI thread and delivers
* the result from doInBackground() */
protected void onPostExecute(Bitmap result) {
mImageView.setImageBitmap(result);
}
}
它在java中被稱爲['Generics'](http://docs.oracle.com/javase/tutorial/java/generics/),其中''是類型參數 –
閱讀泛型類http: //www.tutorialspoint.com/java/java_generics.htm – leonbloy
夥計們!這不是一個壞問題。 –