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?

2
  • @sree Yes i searched but i can't found an answer Commented Jan 8, 2018 at 11:18
  • decode your byte array to bitmap, create BitmapDrawable from bitmap and use this method getActionBar().setIcon(yourBitmapDrawable); Commented Jan 8, 2018 at 11:19

1 Answer 1

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);
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.