<description>
div class="field field-type-filefield field-field-book-review-image">
<div class="field-items">
<div class="field-item odd">
<img class="imagefield imagefield-field_book_review_image" width="500" height="741" alt="" src="**http://sampada.net/files/good%20earth.JPG?1327387980**" /> &
</description>
答案 0 :(得分:1)
你最好使用DOM而不是SAX。只需遍历名为“img”的所有元素,获取“src”属性,构建URL并激活AsyncTask以下载流。
答案 1 :(得分:0)
答案 2 :(得分:0)
如果您只想要1张照片,我会用它:
static final String image_URL = "http://sampada.net/files/good%20earth.JPG?1327387980";
//in the oncreate
ImageView bmImage = (ImageView)findViewById(R.id.<<your image id from the xml>>);
BitmapFactory.Options bmOptions;
bmOptions = new BitmapFactory.Options();
bmOptions.inSampleSize = 1;
Bitmap bm = LoadImage(image_URL, bmOptions);
bmImage.setImageBitmap(bm);
//under the oncreate
private Bitmap LoadImage(String URL, BitmapFactory.Options options)
{
Bitmap bitmap = null;
InputStream in = null;
try {
in = OpenHttpConnection(URL);
bitmap = BitmapFactory.decodeStream(in, null, options);
in.close();
} catch (IOException e1) {
}
return bitmap;
}
private InputStream OpenHttpConnection(String strURL) throws IOException{
InputStream inputStream = null;
URL url = new URL(strURL);
URLConnection conn = url.openConnection();
try{
HttpURLConnection httpConn = (HttpURLConnection)conn;
httpConn.setRequestMethod("GET");
httpConn.connect();
if (httpConn.getResponseCode() == HttpURLConnection.HTTP_OK) {
inputStream = httpConn.getInputStream();
}
}
catch (Exception ex)
{
}
return inputStream;
}
希望这会对你有所帮助。