{"id":818,"date":"2013-10-23T20:18:25","date_gmt":"2013-10-23T12:18:25","guid":{"rendered":"http:\/\/blog.dayandcarrot.net\/?p=818"},"modified":"2013-10-23T20:18:25","modified_gmt":"2013-10-23T12:18:25","slug":"how-to-change-the-android-actionbar-title-and-icon-%e5%a6%82%e4%bd%95%e8%ae%be%e7%bd%aeactionbar%e7%9a%84%e5%9b%be%e6%a0%87%e5%92%8c%e6%96%87%e5%ad%97","status":"publish","type":"post","link":"https:\/\/dayandcarrot.space\/?p=818","title":{"rendered":"How to change the android actionbar title and icon &#124; \u5982\u4f55\u8bbe\u7f6eActionBar\u7684\u56fe\u6807\u548c\u6587\u5b57"},"content":{"rendered":"<p>Source : <a href=\"http:\/\/stackoverflow.com\/questions\/14483393\/how-do-i-change-the-android-actionbar-title-and-icon\" target=\"_blank\" rel=\"noopener noreferrer\">http:\/\/stackoverflow.com\/questions\/14483393\/how-do-i-change-the-android-actionbar-title-and-icon<\/a><br \/>\nThis is very simple to accomplish<br \/>\nIf you want to change it in code call<br \/>\n<code lang=\"java\"><br \/>\nsetTitle(\"My new title\");<br \/>\ngetActionBar().setIcon(R.drawable.my_icon);<br \/>\n<\/code><br \/>\nIn XML:<br \/>\n<code lang=\"xml\"><br \/>\n<activity android:name=\".MyActivity\"\n       android:icon=\"@drawable\/my_icon\"\n       android:label=\"My new title\" \/><br \/>\n<\/code><br \/>\nTo enable the back button in your app use<br \/>\n<code lang=\"java\"><br \/>\ngetActionBar().setHomeButtonEnabled(true);<br \/>\n getActionBar().setDisplayHomeAsUpEnabled(true);<br \/>\n<\/code><br \/>\nThe code should all be placed in your onCreate so that the label\/icon changing is transparent to the user, but in reality it can be called anywhere during the activity&#8217;s lifecycle<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Source : http:\/\/stackoverflow.com\/questions\/14483393\/how-do-i-change-the-android-actionbar-title-and-icon This is very simple to accomplish If you want to change it in code call setTitle(&#8220;My new title&#8221;); getActionBar().setIcon(R.drawable.my_icon); In XML: To enable the back button in your app use getActionBar().setHomeButtonEnabled(true); getActionBar().setDisplayHomeAsUpEnabled(true); The code should all be placed in your onCreate so that the label\/icon changing is transparent to the user, but [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8],"tags":[19],"class_list":["post-818","post","type-post","status-publish","format-standard","hentry","category-technical","tag-android"],"_links":{"self":[{"href":"https:\/\/dayandcarrot.space\/index.php?rest_route=\/wp\/v2\/posts\/818","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/dayandcarrot.space\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/dayandcarrot.space\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/dayandcarrot.space\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/dayandcarrot.space\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=818"}],"version-history":[{"count":0,"href":"https:\/\/dayandcarrot.space\/index.php?rest_route=\/wp\/v2\/posts\/818\/revisions"}],"wp:attachment":[{"href":"https:\/\/dayandcarrot.space\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=818"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dayandcarrot.space\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=818"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dayandcarrot.space\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=818"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}