4

I have a link which contains an image. Usually with fresco I can parse the link and set the image. But, in this case I need to set that image as an icon to ActionBar. I've tried this, but it must be drawable and as I said I only have the link to the image.

((MainActivity) getActivity()).getSupportActionBar().setIcon(ContextCompat.getDrawable(getActivity(), R.drawable.rose_logo));

I access the ActionBar this way because I need it in fragment.

Esteban
  • 667
  • 9
  • 22
  • show how do you obtaining image. as a Bitmap in some callback? here you presented setting fixed drawable from resources – snachmsm Mar 21 '17 at 20:22
  • This is how I used to do it when it was in my application as a `drawable`. But, at the moment I only have an URL which leads to the image. – Esteban Mar 21 '17 at 20:25
  • then you have to implement some lib (fastest way) for obtain this image, as a Bitmap probably. [you can do this with Fresco](http://stackoverflow.com/questions/29476677/using-facebooks-fresco-to-load-a-bitmap) but there are better libs for this – snachmsm Mar 21 '17 at 20:33
  • How can I add fresco to the action bar on the far left and show/hide that icon accordingly? – Esteban Mar 21 '17 at 20:35
  • what is `fresco`... Facebook's lib or anything else? show more code with your url – snachmsm Mar 21 '17 at 20:37
  • Yes, `fresco` is a library such as `Picasso` or `Glide`. – Esteban Mar 22 '17 at 09:48

1 Answers1

0

Hy! Here is a pretty easy way Picasso. You can find the description of this git on the github page of it. (on the link)