如何将数组列表更改为字符串数组以使用通用图像加载器? [英] How to change array list to string array for using Universal Image Loader?
问题描述
我是安卓新手.我只是尝试学习如何使用 Universal Image Loader
.我发现 Universal Image Loader
中图像的 url
是静态设置的或在 String[] IMAGES
中预设的.但我想从 URL
更改这些图像.所以我完成了解析 XML
并尝试从 XML Web 服务
获取这些数据.
I am a Novice of android. I just try to learn how to use Universal Image Loader
.
I find that the url
of the images in Universal Image Loader
are set statically or preset in String[] IMAGES
. But I would like to change those image from URL
. So I am done with parsing the XML
and try to get those data from XML Web service
.
但是,我不知道如何将数组列表更改为字符串数组.有人可以教我吗?
However, I don't know how to change array list to string array. Can someone teach me?
xml web service
代码如下:
class showCategoryTask extends AsyncTask<Void, Void, Void> {
@Override
protected Void doInBackground(Void... params) {
try {
URL url = new URL("http://garyhui86.er-webs.com/monstersxml.php");
HttpURLConnection urlConn =
(HttpURLConnection)url.openConnection();
if (urlConn.getResponseCode() == HttpURLConnection.HTTP_OK) {
DocumentBuilder builder = DocumentBuilderFactory
.newInstance().newDocumentBuilder();
Document document = builder.parse(urlConn.getInputStream());
NodeList nodeList = document.getElementsByTagName("Info");
for (int i = 0; i < nodeList.getLength(); i++) {
NamedNodeMap attributes=nodeList.item(i).getAttributes();
String monstersname=attributes.getNamedItem("monsters_name").getNodeValue();
String monstersimage=attributes.getNamedItem("monsters_image").getNodeValue();
Log.i("ttt", monstersname);
Monsters_image.add(monstersimage);
}
}
urlConn.disconnect();
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
}
推荐答案
Convert your String ArrayList
to String Array
like
Convert your String ArrayList
to String Array
like
String[] str=list.toArray(new String[list.size()]);
这篇关于如何将数组列表更改为字符串数组以使用通用图像加载器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!