Reputation: 101
I tried to load the image into the imageview on the widget using Picasso but when i run imageview return blank, no image is displayed just white blank
this is my code
internal class StackRemoteViewsFactory(private val context: Context, intent: Intent) :
RemoteViewsService.RemoteViewsFactory {
private val appWidgetId: Int = intent.getIntExtra(
AppWidgetManager.EXTRA_APPWIDGET_ID,
AppWidgetManager.INVALID_APPWIDGET_ID
)
......
override fun getViewAt(position: Int): RemoteViews {
val rv = RemoteViews(context.packageName, R.layout.widget_favorite_item)
GlobalScope.launch(Dispatchers.Main) {
Picasso.get().load(data[position].image_path)
.into(rv, R.id.img_widget_banner, intArrayOf(appWidgetId))
}
return rv
}
}
Upvotes: 3
Views: 1033
Reputation: 734
I think the problem is in your Picasso code. First check data[position].imagepath return the correct image path. If you still have the problem then try to show image into only one view. For example you use: rv is a image view
Picasso.get()
.load(data[position].image_path)
.into(rv)
Upvotes: 1