public List<MiNi> getMiniData() {
list = new ArrayList<MiNi>();
try {
URL url = new URL("http://10.0.2.2:8080/carsclub/mini.xml");
SAXParserFactory factory = SAXParserFactory.newInstance();// 获得解析工厂
SAXParser sp = factory.newSAXParser();// 获得高层解析类
XMLReader xmlReader = sp.getXMLReader();// 获得低层解析类
xmlReader.setContentHandler(new MiniHandler(list));
xmlReader.parse(new InputSource(url.openStream())); } catch (Exception e) { e.printStackTrace();
}
return list;
} public List<Map<String, Object>> getCarsData() {
List<Map<String, Object>> lt = new ArrayList<Map<String, Object>>(); for (MiNi mini : list) {
Map<String, Object> map = new HashMap<String, Object>();
String name = mini.getName().toString();
String type = mini.getType().toString();
String price = mini.getPrice().toString();
String detail = mini.getDetail().toString();
String imagePath = mini.getImagePath(); Bitmap bitmap = getServiceImage(imagePath); map.put("bitmap", bitmap);
map.put("name", name);
map.put("type", type);
map.put("price", price);
map.put("detail", detail); lt.add(map); }
return lt;
} public Bitmap getServiceImage(String path) {
InputStream is = null;
OutputStream os = null;
Bitmap bitmap = null; try {
URL url = new URL(path);
HttpURLConnection hc = (HttpURLConnection) url.openConnection();
is = hc.getInputStream(); DataInputStream dis = new DataInputStream(is);
bitmap = BitmapFactory.decodeStream(dis);
} catch (Exception e) { e.printStackTrace();
} finally {
try {
if (is != null)
is.close();
if (os != null)
os.close();
} catch (IOException e) { e.printStackTrace();
} }
return bitmap;
}如何让图片和它相关的信息一起循环显示