3

リモートビューで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" />

ウィジェットが起動しますが、imageViewに画像が印刷されていません。

4

2 に答える 2

3

あなたの質問はここで答えられます:https ://groups.google.com/forum/?fromgroups =#!topic / android-developers / jupslaeAEuo

于 2013-03-01T05:41:59.853 に答える
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);
于 2017-03-01T01:47:26.130 に答える