//读图片URL
URLuri=new URL("http://10.1.5.42:8080/ru.png");
HttpURLConnectionconnection = (HttpURLConnection) uri.openConnection();
connection.setConnectTimeout(5000);
connection.setRequestMethod("GET");
connection.setReadTimeout(5000);
connection.connect();
int code = connection.getResponseCode();
if(code==200){
InputStream inputStream = connection.getInputStream();
Bitmap bitmap = BitmapFactory.decodeStream(inputStream);
}
//读图片HttpClient
Path:图片的网址;
HttpClientclient=new DefaultHttpClient();
HttpPost httpPost=new HttpPost(path);
try {
HttpResponse httpResponse =client.execute(httpPost);
//得到实体数据
HttpEntity entity =httpResponse.getEntity();
//从实体里获得流
InputStream inputStream =entity.getContent();
//把流转成bitmap
final Bitmap bitmap =BitmapFactory.decodeStream(inputStream);
runOnUiThread(new Runnable() {
@Override
public void run() {
imageView.setImageBitmap(bitmap);
}
//读图片HttpClient导包
<com.loopj.android.image.SmartImageView
android:id="@+id/imageView"
android:layout_width="100dp"
android:layout_height="100dp"/>
SmartImageView imageView= (SmartImageView)convertView.findViewById(R.id.imageView);
imageView.setImageUrl(list.get(position).pic);
//读图片导包Utils
BitmapUtils bitmap=new BitmapUtils(context);
bitmap.display(imageview, str[position]);