[英]android picasso .into(new Target() causing method error
我們使用以下代碼將圖像加載到 android webview 應用程序的 notification.setLargeicon 參數中。 但不幸.into(new Target() {
顯示以下警告:
Class 'Anonymous class derived from Target' 必須聲明為抽象或在'Target' 中實現抽象方法'value()'。 我們不知該如何解決這個問題。
Picasso.get().load("https://mbracecloud.com/appln_enterprise/images/reconnect_feature7.jpg")
.into(new Target() {
@Override
public void onBitmapLoaded(final Bitmap bitmap, final Picasso.LoadedFrom from) {
notificationBuilder1.setLargeIcon(bitmap);
notificationManager.notify(notification_id, notificationBuilder1.build());
}
@Override
public void onBitmapFailed(final Drawable errorDrawable) {
// Do nothing
}
@Override
public void onPrepareLoad(final Drawable placeHolderDrawable) {
// Do nothing
}
});
更新:
根據下面給出的輸入,我們進行以下導入:
import com.squareup.picasso.Target;
並嘗試加載圖像,但我們遇到了一個新錯誤:
Class 'Anonymous class derived from Target' must either be declared abstract or implement abstract method 'onBitmapFailed(Exception, Drawable)' in 'Target'
請幫助我們解決這個問題。
猜測您正在導入錯誤的Target
,特別是注釋目標。 改變
import java.lang.annotation.Target;
到
import com.squareup.picasso.Target;
根據您的錯誤onBitmapFailed(Exception, Drawable)
,您僅使用Drawable
參數覆蓋此方法,但Target
class 想要使用Exception
和Drawable
參數覆蓋抽象方法。 因此,嘗試用下面的實現替換onBitmapFailed
:
@Override
public void onBitmapFailed(final Exception exception, final Drawable errorDrawable) {
// Do nothing
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.