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?
Asked
Active
Viewed 125 times
0

Fahim
- 384
- 5
- 20
-
@sree Yes i searched but i can't found an answer – Fahim Jan 08 '18 at 11:18
-
decode your byte array to bitmap, create BitmapDrawable from bitmap and use this method getActionBar().setIcon(yourBitmapDrawable); – Truong Giang Dam Jan 08 '18 at 11:19
1 Answers
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