2012-11-08 109 views

回答

3

只要您可以使用此library

它采用延迟加载的概念。

-1

试试下面的代码:

try 
{ 
    URL img_value = null; 
    img_value = new URL("ImageUrl"); 
    Bitmap mIcon1 = BitmapFactory.decodeStream(img_value.openConnection().getInputStream()); 
    Image.setImageBitmap(mIcon1); 
} 
catch(Exception e) 
{ 
} 
+0

你会得到NetworkOnUiThreadException – njzk2

+0

@ njzk2:没有。它没有得到任何错误。和它的工作!好吧 –

+0

不后,Android 2.3(或东西从你的代码失踪) – njzk2

0

我的ListView适配器使用这getView()。

Webview kWebview = new Webview(context); 
kWebview.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)); 
kWebview.setFocusable(false); 
kWebview.setClickable(false); 
kWebview.setLongClickable(false); 
kWebview.setFocusableInTouchMode(false); 
kWebview.setInitialScale(100); 
kWebview.setBackgroundColor(Color.BLACK); 

WebSettings kSet = kWebview.getSettings(); 
kSet.setLoadWithOverviewMode(false); 
kSet.setLoadsImagesAutomatically(true); 
kSet.setAppCacheEnabled(true); 
kSet.setAppCachePath(_context.getCacheDir().toString()); 
kSet.setCacheMode(WebSettings.LOAD_DEFAULT); 
kSet.setAllowFileAccess(true); 
kSet.setDomStorageEnabled(true); 

kWebview.loadUrl("http://image_url"); 

Webview是更流畅加载超过ImageView的

0

试试这个代码:

string path = item.ImgPath; 
URL url = new URL(path); 
URI uri = new URI(url.Protocol, url.UserInfo, url.Host, url.Port, url.Path, url.Query, url.Ref); 
url = uri.ToURL(); 

//convert it into bitmap 
var bitmap = Android.Graphics.BitmapFactory.DecodeStream(url.OpenStream()); 

//set bitmap drawable 
System.IO.Stream stream = url.OpenStream(); 
Img.SetImageBitmap(bitmap);