Reputation: 6657
I'm using Picasso to pull a jpg from a URL and then append to an EditText. As can be seen I am using the Target method to input the image from the URL into my Drawable, which is then appended to my EditText. However, an error occurs:
The method BitmapDrawable(Resources, Bitmap) is undefined for the type new Target(){}
at location:
BitmapDrawable(getBaseContext().getResources(), bitmap);
What appears to be going wrong? How is this Target class implementation properly configured for my actions?
Method to append to EditText:
public void appendToMessageHistory(final String username,
final String message) {
if (username != null && message != null) {
Picasso.with(getBaseContext()).load("http://localhost:3000/uploads/campaign/image/2/2.jpg").into(new Target() {
@Override
public void onPrepareLoad(Drawable arg0) {
}
@Override
public void onBitmapLoaded(Bitmap bitmap, LoadedFrom arg1) {
Drawable drawImage = BitmapDrawable(
getBaseContext().getResources(), bitmap);
messageHistoryText.append(Html.fromHtml("<b>" + username
+ ":" + "</b>" + "<br>"));
messageHistoryText.append(Html.fromHtml(message + "<hr>"
+ "<br>")
+ System.getProperty("line.separator") + "");
messageHistoryText.append(Html.fromHtml("<img src = '"
+ drawImage + "'/>", imageGetter, null));
}
@Override
public void onBitmapFailed(Drawable arg0) {
}
});
}
}
Upvotes: 0
Views: 332
Reputation: 1007296
I suspect that you forgot the new
keyword before BitmapDrawable
.
Drawable drawImage = BitmapDrawable(
getBaseContext().getResources(), bitmap);
should be
Drawable drawImage = new BitmapDrawable(
getBaseContext().getResources(), bitmap);
Upvotes: 1