【发布时间】:2012-11-05 18:32:16
【问题描述】:
<String, Void, Bitmap> 下面这部分代码是什么意思?我什至不知道这个语法叫什么。
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,其中<String, Void, Bitmap>是类型参数 -
伙计们!这不是一个坏问题。
-
@AmitD:实际上这些是类型参数而不是参数。