如何從網站中提取圖像並在網格或列表視圖中顯示?從網站提取圖像
Q
從網站提取圖像
0
A
回答
2
Bitmap bmImg;
void downloadfile(String fileurl,ImageView img)
{
URL myfileurl =null;
try
{
myfileurl= new URL(fileurl);
}
catch (MalformedURLException e)
{
e.printStackTrace();
}
try
{
HttpURLConnection conn= (HttpURLConnection)myfileurl.openConnection();
conn.setDoInput(true);
conn.connect();
int length = conn.getContentLength();
int[] bitmapData =new int[length];
byte[] bitmapData2 =new byte[length];
InputStream is = conn.getInputStream();
BitmapFactory.Options options = new BitmapFactory.Options();
options.inSampleSize =
bmImg = BitmapFactory.decodeStream(is,null,options);
img.setImageBitmap(bmImg);
//dialog.dismiss();
}
catch(IOException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
// Toast.makeText(PhotoRating.this, "Connection Problem. Try Again.", Toast.LENGTH_SHORT).show();
}
}
試試這個
0
這url解釋了有關使用異步任務,並在列表視圖中顯示被下載的圖像從遠程服務器下載圖像。
0
下面的代碼可以幫助你獲取圖像。如果你傳遞圖像的網址。
public Drawable loadImageFromWebOperations(String url)
{
try
{
DefaultHttpClient client = new DefaultHttpClient();
HttpGet httpGetRequest = new HttpGet(url);
HttpResponse response = client.execute(httpGetRequest);
InputStream is = response.getEntity().getContent();
Drawable d = Drawable.createFromStream(is, "src name");
return d;
} catch (Exception e) {
System.out.println("Exc="+e);
return null;
}
}
該代碼將返回您可以在ImageView的
imageView.setImageDrawable(d);
顯示您可以將一個ImageView的添加到列表中的每一行,並設置可繪製的可繪製。
0
如果你想分析整個網站,我更喜歡使用Jerico HTML Parser,它可以在Android上正常工作(試過),然後你可以搜索<img>
元素來獲取圖像的URL。
相關問題
- 1. 從網站中提取所有圖像
- 2. 從網站提取圖標
- 3. 從網站獲取圖像
- 4. 從網站獲取圖像
- 5. 從網站獲取驗證碼圖像
- 6. 如何從網站(iOS)提取圖像和標題
- 7. 腳本從網站中提取大量圖像?
- 8. 將數據和圖像從網站提取到ListView
- 9. 使用jQuery和/或AJAX從網站中提取當前圖像?
- 10. 從網站上託管的視頻中提取圖像
- 11. Jsoup,從網站中提取鏈接,圖像。運行時例外
- 12. 如何從簡單的html-dom網站提取圖像?
- 13. 從網站提取價值
- 14. 從網站提取信息
- 15. 從網站提取數據
- 16. 從網站中提取html
- 17. 從網站抓圖像
- 18. 從網站加載圖像
- 19. 寫圖像從網站
- 20. 從網站中提取網址?
- 21. 從網站抓取圖片
- 22. 網站圖像
- 23. 試圖從網站中使用Web Harvest提取網址
- 24. 從抓取的網站(ARC文件)中提取圖形
- 25. Node.js:提取網頁的圖像網址
- 26. Android,如何從圖片共享網站中提取圖片
- 27. 如何在網站中查找並提取「主」圖像
- 28. 從圖像中提取圖像
- 29. 從網站提取數據Jquery Grid
- 30. 從php其他網站提取數據