我正在尝试将数据从arrayList
填充到列表视图。但是由于某种原因,我得到了错误error: no suitable constructor found for ArrayAdapter(activity2.SendPostRequest,int,int,ArrayList<HashMap<String,String>>)
constructor ArrayAdapter.ArrayAdapter(Context,int,int,HashMap<String,String>[]) is not applicable
JSONArray json = new JSONArray(data);
ArrayList<HashMap<String, String>> arrayList = new ArrayList<HashMap<String, String>>();
HashMap<String, String> map = new HashMap<String, String>();
try {
for(int i=0;i<json.length();i++){
JSONObject e =json.getJSONObject(i);
map.put("id", String.valueOf(i));
map.put("Name", "Vorname: " + e.getString("meta_value"));
map.put("orderid", "id: " + e.getString("post_id"));
arrayList.add(map);
return map.toString();
}
ArrayAdapter<HashMap<String, String>> adapter = new ArrayAdapter<HashMap<String, String>>(this,android.R.layout.simple_list_item_1, android.R.id.text1, arrayList);
list.setAdapter(adapter);
}catch (JSONException e){
Log.e(this.getClass().getName(), "Some JSON error occurred" + e.getMessage());
}
无法找到任何解决方案
问题是您将其作为为适配器提供上下文的第一个参数。