我想將整數傳遞給異步任務,並通過該索引訪問列表。不能使用整數作爲數組索引
但是我得到這個錯誤「在列表不能應用」。
這裏是相關的代碼。
異步任務不接受原始int作爲參數。
src = new ArrayList<String>();
String message = "";
for (int i=0; i<src.size(); i++) {
new AsyncTask<Integer, Void, Void>() {
@Override
protected Void doInBackground(Integer... pos) {
...
message += **src.get(pos)**;
...
}
}.execute(i);
}