java - Logo is not showing up on action bar -
i'm trying put logo on actionbar in android nothing seems working. have literally tried every solution find on website , others without luck. appreciated,
jacob
here java:
public class home extends actionbaractivity { @override protected void oncreate(bundle savedinstancestate) { settheme(r.style.apptheme); super.oncreate(savedinstancestate); setcontentview(r.layout.activity_home); getsupportactionbar().setdisplayuselogoenabled(true); getsupportactionbar().setdisplayhomeasupenabled(true); getsupportactionbar().setlogo(r.drawable.ic_launcher); mnavitems.add(new navitem("home", "find need know in 1 place", r.drawable.home_icon)); mnavitems.add(new navitem("learn our programs", "learn city", r.drawable.list)); mnavitems.add(new navitem("about us", "get know on personal level", r.drawable.info_circled_alt)); mnavitems.add(new navitem("contact us", "want know more something? send email or phone call", r.drawable.questionm)); // drawerlayout mdrawerlayout = (drawerlayout) findviewbyid(r.id.drawerlayout); mdrawerlayout.setdrawershadow(r.drawable.drawer_shadow, gravitycompat.start); // populate navigtion drawer options mdrawerpane = (relativelayout) findviewbyid(r.id.drawerpane); mdrawerlist = (listview) findviewbyid(r.id.navlist); drawerlistadapter adapter = new drawerlistadapter(this, mnavitems); mdrawerlist.setadapter(adapter); // drawer item click listeners mdrawerlist.setonitemclicklistener(new adapterview.onitemclicklistener() { @override public void onitemclick(adapterview<?> parent, view view, int position, long id) { selectitemfromdrawer(position); } }); mdrawertoggle = new actionbardrawertoggle(this, mdrawerlayout, r.string.drawer_opem, r.string.drawer_close) { @override public void ondraweropened(view drawerview) { super.ondraweropened(drawerview); invalidateoptionsmenu(); } @override public void ondrawerclosed(view drawerview) { super.ondrawerclosed(drawerview); log.d(tag, "ondrawerclosed: " + gettitle()); invalidateoptionsmenu(); } }; mdrawerlayout.setdrawerlistener(mdrawertoggle); } @override protected void onpostcreate(bundle savedinstancestate) { super.onpostcreate(savedinstancestate); mdrawertoggle.syncstate(); } @override public boolean onoptionsitemselected(menuitem item) { // pass event actionbardrawertoggle // if returns true, has handled // nav drawer indicator touch event if (mdrawertoggle.onoptionsitemselected(item)) { return true; } // handle other action bar items... return super.onoptionsitemselected(item); } private void selectitemfromdrawer(int position) { // close drawer mdrawerlayout.closedrawer(mdrawerpane); intent intent; switch (position) { case 0: new handler().postdelayed(new runnable() { @override public void run() { intent = new intent(home.this, home.class); i.addflags(intent.flag_activity_single_top | intent.flag_activity_no_animation); startactivity(i); overridependingtransition(r.animator.animation1, r.animator.animation2); } }, 300); break; case 1: new handler().postdelayed(new runnable() { @override public void run() { intent = new intent(home.this, findopp.class); i.addflags(intent.flag_activity_single_top | intent.flag_activity_no_animation); startactivity(i); overridependingtransition(r.animator.animation1, r.animator.animation2);; } }, 300); break; case 2: new handler().postdelayed(new runnable() { @override public void run() { intent = new intent(home.this, about_us.class); i.addflags(intent.flag_activity_single_top | intent.flag_activity_no_animation); startactivity(i); overridependingtransition(r.animator.animation1, r.animator.animation2);; } }, 300); break; } } } class navitem { string mtitle; string msubtitle; int micon; public navitem(string title, string subtitle, int icon) { mtitle = title; msubtitle = subtitle; micon = icon; } } class drawerlistadapter extends baseadapter { context mcontext; arraylist<navitem> mnavitems; public drawerlistadapter(context context, arraylist<navitem> navitems) { mcontext = context; mnavitems = navitems; } @override public int getcount() { return mnavitems.size(); } @override public object getitem(int position) { return mnavitems.get(position); } @override public long getitemid(int position) { return 0; } @override public view getview(int position, view convertview, viewgroup parent) { view view; if (convertview == null) { layoutinflater inflater = (layoutinflater) mcontext.getsystemservice(context.layout_inflater_service); view = inflater.inflate(r.layout.drawer_item, null); } else { view = convertview; } textview titleview = (textview) view.findviewbyid(r.id.title); textview subtitleview = (textview) view.findviewbyid(r.id.subtitle); imageview iconview = (imageview) view.findviewbyid(r.id.icon); titleview.settext( mnavitems.get(position).mtitle ); subtitleview.settext( mnavitems.get(position).msubtitle ); iconview.setimageresource(mnavitems.get(position).micon); return view; } } class preferencesfragment extends fragment { public preferencesfragment() { // required empty public constructor } @override public view oncreateview(layoutinflater inflater, viewgroup container, bundle savedinstancestate) { // inflate layout fragment return inflater.inflate(r.layout.fragment_prefences, container, false); } }
this may , try this
getsupportactionbar().setdisplayshowhomeenabled(true); getsupportactionbar().seticon(r.drawable.ic_launcher);
Comments
Post a Comment