图像没有显示在List.In父类中我使用了setImage()和getImage()但我不知道如何在ExpandableListMain(MainActivity)中获取图像
private ArrayList<Parent> buildDummyData(String result) throws JSONException {
// Creating ArrayList of type parent class to store parent class objects
JSONArray json = new JSONArray(result);
ArrayList<Parent> list = new ArrayList<>();
for (int i = 1; i < json.length(); i++) {
JSONObject obj1 = json.getJSONObject(i);
Parent parent = new Parent();
parent.setName("" + i);
// parent.setImage(obj1.getImage("image"));----->this line shows an error
parent.setText1(obj1.getString("name"));
parent.setChildren(new ArrayList<Child>());
Child child = new Child();
child.setName("" + i);
child.setText1(obj1.getString("name"));
child.setText2(obj1.getString("mobile"));
child.setText3("hellooo");
child.setText4(obj1.getString("blood"));
//Add Child class object to parent class object
parent.getChildren().add(child);
list.add(parent);
}
return list;
答案 0 :(得分:0)
从您的服务器获取图片网址并使用该网址将图片加载到您的列表视图中。对于加载图像,您可以使用任何库项目,如
https://github.com/nostra13/Android-Universal-Image-Loader
https://github.com/facebook/fresco