2013-02-21 28 views
3

我嘗試使用遠程視圖從url設置圖像。下面是我使用的代碼:setImageViewUri從遠程視圖中的Android小部件的URL

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

而且佈局代碼:

<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啓動,但沒有在ImageView的打印圖像。

回答

0
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); 
相關問題