question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Using callback for CompoundDrawables

See original GitHub issue

Hi, I want, to use Picasso for compound drawables since It’s doing a great job for ImageViews. But it doesn’t really work. The place where the image should come just stays white.

This is what I’ve done so for. bitmap is the URL of the Image.

    Picasso.with(getActivity().getApplicationContext()).load(bitmap).into(new Target() {
        public void onBitmapLoaded(Bitmap bitmapPic, LoadedFrom from){
        Drawable d = new BitmapDrawable(getResources(), bitmapPic);
        textView[picassoCounter].setCompoundDrawablesWithIntrinsicBounds(d, null, null, null);
        textView[picassoCounter].setCompoundDrawablePadding(5);                       

        }

        public void onBitmapFailed(Drawable errorDrawable){
        Drawable d = getResources().getDrawable(R.drawable.nofavicon);
        textView.setCompoundDrawablesWithIntrinsicBounds(d, null, null, null);
        textView.setCompoundDrawablePadding(5); 
              }

public void onPrepareLoad(Drawable placeHolderDrawable){
                          }
                        });

Issue Analytics

  • State:closed
  • Created 10 years ago
  • Reactions:1
  • Comments:13 (1 by maintainers)

github_iconTop GitHub Comments

4reactions
JakeWhartoncommented, Nov 14, 2013

Subclass TextView and implement Target on that class. Have the onBitmapSuccess callback set the compound drawable. Use the subclass in your XML or code instead of TextView.

1reaction
ghostcommented, Mar 30, 2016
Read more comments on GitHub >

github_iconTop Results From Across the Web

Compound Drawables - Styling Android
In this article we'll have a look at what they are and see how we can use them to simplify some of our...
Read more >
Drawable | Android Developers
Levels: a compound drawable that selects one of a set of drawables based on its level. Scale: a compound drawable with a single...
Read more >
Button stays in pressed state after OnTouch callback
I'm defining a CompoundDrawable on a button and reacting for clicks on it: mFileSelector.setOnTouchListener(new View.
Read more >
graphics/java/android/graphics/drawable/Drawable.java - platform ...
interface (via {@link #setCallback}) so that animations will work. A ... <li> <b>Scale</b>: a compound drawable with a single child drawable,.
Read more >
Setting the Color of a TextView Drawable for Android
Hey, if you didn't already know, I'm currently working on an open world stealth exploration game called Farewell North in my spare time, ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found