Picasso ImageView 中的 null drawable
null drawable from Picasso ImageView
基本上,我正在尝试转换 URI -> ImageView(通过 Picasso)-> Drawable。
var tempimg = ImageView(this)
var a: String
var d: Drawable
a = pageURIFd + page
Picasso.get().load(a).into(tempimg)
d = tempimg.getDrawable() as BitmapDrawable
bitmaps.add(d)
我知道 Picasso 加载后 ImageView 不是空的,因为我可以显示图像。但是下面的行返回空值。我正在尝试将每个可绘制对象添加到数组列表中。
d = tempimg.getDrawable() as BitmapDrawable
首先,Picasso.get().load(a).into(tempimg)
是异步的。 Picasso
将在一个线程中执行请求,当它得到结果时,将其设置为 ImageView
。下一行代码无法得到Picasso的结果
如果你想得到一个Bitmap
,你可以问Picasso
到return它。参见 Use Picasso to get a callback with a Bitmap
基本上,我正在尝试转换 URI -> ImageView(通过 Picasso)-> Drawable。
var tempimg = ImageView(this)
var a: String
var d: Drawable
a = pageURIFd + page
Picasso.get().load(a).into(tempimg)
d = tempimg.getDrawable() as BitmapDrawable
bitmaps.add(d)
我知道 Picasso 加载后 ImageView 不是空的,因为我可以显示图像。但是下面的行返回空值。我正在尝试将每个可绘制对象添加到数组列表中。
d = tempimg.getDrawable() as BitmapDrawable
首先,Picasso.get().load(a).into(tempimg)
是异步的。 Picasso
将在一个线程中执行请求,当它得到结果时,将其设置为 ImageView
。下一行代码无法得到Picasso的结果
如果你想得到一个Bitmap
,你可以问Picasso
到return它。参见 Use Picasso to get a callback with a Bitmap