android - Load a remote image in a MenuItem using Glide -


usually if want load image glide write following:

glide.with(context)      .load(theurloftheimage)      .error(r.drawable.ic_error_image)      .into(theimageview); 

but if need load image of url menuitem has changed in real time?

the following not possible because method into not accept parameter:

@override public boolean onprepareoptionsmenu(menu menu) {     menuitem settingsitem = menu.finditem(r.id.actionbar_menu_profile_actions);     if (changeimage) {         glide.with(this).load(theurloftheimage).error(r.drawable.ic_error_image).into(settingsitem);     }     return super.onprepareoptionsmenu(menu); } 

using approach suggested in responses this question worked

@override public boolean onprepareoptionsmenu(menu menu) {     menuitem settingsitem = menu.finditem(r.id.actionbar_menu_profile_actions);     if (changeimage) {          glide.with(this).load(theurloftheimage).asbitmap().into(new simpletarget<bitmap>(100,100) {             @override             public void onresourceready(bitmap resource, glideanimation glideanimation) {                 settingsitem.seticon(new bitmapdrawable(getresources(), resource));             }         });     }     return super.onprepareoptionsmenu(menu); } 

Comments

Popular posts from this blog

javascript - Laravel datatable invalid JSON response -

java - Exception in thread "main" org.springframework.context.ApplicationContextException: Unable to start embedded container; -

sql server 2008 - My Sql Code Get An Error Of Msg 245, Level 16, State 1, Line 1 Conversion failed when converting the varchar value '8:45 AM' to data type int -