0

I want to get user image like byte array from server and show this image instead of icon in Actionbar. I searched and founded, i can set image in icon with drawable like getActionBar().setIcon(R.drawable.my_icon) but i want to set image dynamically and i have not image in drawable folder . How can do this?

Fahim
  • 384
  • 5
  • 20

1 Answers1

2
byte[] imageFromServer = getImageFromServer(); // assuming you get byte array from server
Bitmap bitmap = BitmapFactory.decodeByteArray(imageFromServer , 0, imageFromServer .length);
BitmapDrawable icon = new BitmapDrawable(getResources(),bitmap);
getActionBar().seticon(icon);
Rajan Kali
  • 12,627
  • 3
  • 25
  • 37