LoginSignup
3
3

More than 5 years have passed since last update.

Widgetでリモート画像を表示する(ImageViewを使う)

Last updated at Posted at 2013-09-28
setImageViewUri(R.id.imageview,Uri.parse("http://www.hogehoge.com/hoge.jpg");

とやっても、画像がうまく表示されない。
なので、Bitmapか、Drawableをセットするメソッドを使う。

しかし、

Widgetのviewを更新する際に利用するRemoteviewには、
setImageViewDrawableみたいなメソッドが存在しない。

setImageViewBitmapを使う

URL neturl = new URL(url);
Drawable drawable = Drawable.createFromStream(neturl.openStream(),"src");
Bitmap bitmap = ((BitmapDrawable)drawable).getBitmap();
remoteViews.setImageViewBitmap(R.id.isImage, bitmap);
3
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
3