3

I try to set image from url with remote view. Here is the code that i use :

   rv = new RemoteViews(mContext.getPackageName(), R.layout.widget_item_default);
    WidgetItem item = mWidgetItems.get(position);
    rv.setImageViewUri(R.id.imageDeal, Uri.parse(item.urlImage));

And the code of the layout :

 <ImageView
     android:id="@+id/imageDeal"
     android:layout_width="fill_parent"
     android:layout_height="80dp"
     android:layout_marginBottom="2dp"
     android:layout_marginLeft="4dp"
     android:layout_marginRight="4dp"
     android:adjustViewBounds="true"
     android:scaleType="centerCrop"
     android:src="@drawable/mem" />

Widget is launched but there is no image printed in the imageView.

Wawanopoulos Ertz
  • 135
  • 1
  • 2
  • 7

2 Answers2

4

Your question is answered here: https://groups.google.com/forum/?fromgroups=#!topic/android-developers/jupslaeAEuo

SIr Codealot
  • 5,331
  • 9
  • 33
  • 45
1
FutureTarget<Bitmap> futureTarget = Glide.with(mContext)
                            .load(resizedImageUrl)
                            .asBitmap()
                            .into(Target.SIZE_ORIGINAL, Target.SIZE_ORIGINAL);
                    try
                    {
                        rv.setImageViewBitmap(R.id.icon, futureTarget.get());
                    } catch (InterruptedException | ExecutionException e)
                    {
                        e.printStackTrace();
                    }
                    Glide.clear(futureTarget);
Raghav Sharma
  • 780
  • 10
  • 18