这是我的代码,带有此构造函数的自定义数组适配器
public class CustomArrayAdapter extends ArrayAdapter<String> {
RowItems RowItems;
List<RowData> DataList;
public CustomArrayAdapter(Context context, int textViewId, String[] id, RowItems rowItems, List<RowData> listData)
并且 Eclipse 尝试在我的 asyncTask 中更改它,这是我的 asyncTask
private class asyncTaskProduct extends AsyncTask<Void, Void, Boolean>{
String Url;
String Result;
Context MyContex;
ProgressDialog PD;
String[] id;
List<RowData> L;
ListView lvProduct;
public asyncTaskProduct(String url, Context contex,ListView lv) {
Url = url;
MyContex = contex;
lvProduct = lv;
}
@Override
protected void onPreExecute() {
super.onPreExecute();
PD = new ProgressDialog(MyContex);
PD.setMessage("File downloading ...");
PD.setCancelable(false);
PD.setProgressStyle(ProgressDialog.STYLE_SPINNER);
PD.show();
}
@Override
protected Boolean doInBackground(Void... arg0) {
boolean State = false;
getJsonResult Con = new getJsonResult();
Result = Con.postForJson(Url);
if (Result != null){
State = true;
Result = Result.substring(10, Result.length() - 1);
}
return State;
};
protected void onPostExecute(Boolean State) {
if (State) {
for (int i = 0; i < L.size(); i++) {
id [i]=String.valueOf(i);
}
lvProduct.setAdapter(new CustomArrayAdapter(this,R.id.lvRow_tv_ID, id, new RowItems(), L));
Toast.makeText(MyContex,Result, Toast.LENGTH_SHORT).show();
}else {
Toast.makeText(MyContex,"Error", Toast.LENGTH_SHORT).show();
}
PD.cancel();
}
我的错误是 lvProduct.setAdapter。eclips 说构造函数未定义并尝试将其更改为
CustomArrayAdapter(**asyncTaskProduct**, int textViewId, String[] id, RowItems rowItems, List<RowData> listData)
为什么将 Context 更改为 asyncTaskProduct?!