<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>
質問する
900 次
3 に答える
1
SAXよりもDOMを使用する方がよいでしょう。「img」という名前のすべての要素を繰り返し処理し、「src」属性を取得し、URLを作成し、AsyncTaskを起動してストリームをダウンロードするだけです。
于 2012-10-30T09:40:58.400 に答える
0
于 2012-10-30T07:57:50.173 に答える
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;
}
これがお役に立てば幸いです。
于 2012-10-30T08:22:17.973 に答える