如何从AsyncTask的postExecute方法中获取Map的结果?我无法在结果中获取结果?
@Override
protected void onPostExecute(Map<String,List<CommentModel>> results) {
super.onPostExecute(results);
for(int i=0;i<results.size();i++){
String ar =results.get(i).get(commentModelList);
// String content = commentModel.getContent();
Toast.makeText(getApplicationContext(),"Hello",Toast.LENGTH_LONG).show();
ExpandableListAdapter expandableListAdapter = new Expandablelistadapter(getApplicationContext(),parentlist,childlist);
list.setAdapter(expandableListAdapter);
}
}
答案 0 :(得分:0)
String ar =results.get(i).get(commentModelList);
应改为
CommentModel ar =results.get(commentModelList).get(i);
为了避免混淆,未来会尝试将每个步骤分成不同的行:
List<CommentModel> resultList = results.get(commentModelList);
CommentModel ar = resultList.get(i);
编辑: 另外,你在哪里关闭你的for循环?如果我正确理解您要在代码中尝试做什么,那么您希望迭代从地图中获取的列表,而不是遍历地图以获取列表。所以它应该更像是:
List<CommentModel> resultList = results.get(commentModelList);
for(int i=0;i<resultList.size();i++){
CommentModel ar = resultList.get(i);
// use 'ar' in the rest of your code
}