我必须创建一个使用android的应用程序,它具有查看用户图像到circularimageview for circularimageview的设施我正在使用com.pkmmte.view.CircularImageView库并使用位图来显示来自URL的图像但我无法显示图像在imageview中它显示了一些错误
D/dalvikvm: GC_FOR_ALLOC freed 277K, 5% free 7693K/8044K, paused 2ms, total 2ms
D/dalvikvm: GC_FOR_ALLOC freed 747K, 9% free 8469K/9288K, paused 8ms, total 8ms
E/BitmapFactory: Unable to decode stream: java.io.FileNotFoundException: /http:/hennasilks.com/jijo/informe/profile_images/galimg2017-02- 16T11:16:02.403+0530178.jpeg: open failed: ENOENT (No such file or directory)
I/System.out: jijonull
E/BitmapFactory: Unable to decode stream: java.io.FileNotFoundException: /http:/hennasilks.com/jijo/informe/profile_images/galimg2017-02-16T11:16:02.403+0530178.jpeg: open failed: ENOENT (No such file or directory)
I/System.out: jijonull
E/BitmapFactory: Unable to decode stream: java.io.FileNotFoundException: /http:/hennasilks.com/jijo/informe/profile_images/galimg2017-02-16T11:16:02.403+0530178.jpeg: open failed: ENOENT (No such file or directory)
I/System.out: jijonull
D/dalvikvm: GC_FOR_ALLOC freed 325K, 7% free 9612K/10284K, paused 5ms, total 6ms
I/dalvikvm-heap: Grow heap (frag case) to 11.409MB for 2048012-byte allocation
D/dalvikvm: GC_FOR_ALLOC freed 5K, 6% free 11606K/12288K, paused 7ms, total 7ms
D/dalvikvm: GC_FOR_ALLOC freed 34K, 6% free 11604K/12288K, paused 5ms, total 5ms
I/dalvikvm-heap: Grow heap (frag case) to 29.683MB for 19170444-byte allocation
D/dalvikvm: GC_FOR_ALLOC freed 4K, 3% free 30320K/31012K, paused 4ms, total 4ms
V/FA: Inactivity, disconnecting from the service
V/FA: onUnbind called for intent. action: com.google.android.gms.measurement.START
V/FA: Local AppMeasurementService is shutting down
这是我使用显示图像的代码
BitmapFactory.Options options = new BitmapFactory.Options();
options.inSampleSize = 4;
String profurl="http://hennasilks.com/jijo/informe/profile_images/galimg2017-02-16T11:16:02.403+0530178.jpeg";
Bitmap bitmap = BitmapFactory.decodeFile(profurl,options);
System.out.println("jijo"+bitmap);
int height = bitmap.getHeight(), width = bitmap.getWidth();
if (height > 1280 && width > 960)
{
Bitmap imgbitmap = BitmapFactory.decodeFile(profurl);
holder.prof.setImageURI(Uri.parse(String.valueOf(imgbitmap)));
holder.prof.setVisibility(View.VISIBLE);
}
else {
holder.prof.setImageURI(Uri.parse(String.valueOf(bitmap)));
holder.prof.setVisibility(View.VISIBLE);
}
请提前帮助我找到解决方案
答案 0 :(得分:1)
使用picasso库或首先将图像下载到本地存储中并使用本地路径进行解码文件
String profurl="http://hennasilks.com/jijo/informe/profile_images/galimg2017-02-16T11:16:02.403+0530178.jpeg";
Picasso.with(yourActiviy.this).load(pic_url).error(R.drawable.profile_pic).into(iv__pic);
在build.gradle
中添加 compile 'com.squareup.picasso:picasso:2.5.2'
答案 1 :(得分:0)
首先,您需要下载图像,然后将其转换为位图。 或者你可以使用滑动来加载图像。 如果您正在使用eclips edt,那么请下载glide.jar文件并将其放入您的libs文件夹中,或者如果您使用的是工作室,则将此sigle行放入您的gradle文件编译中,然后滑动:3.7。 0' 。 之后使用这一行来显示图像。
Glide.with(context).load(image url).into(your image view).