Monday, 15 June 2015

add action button (add a button on the nav bar)





If you want to implement a button like this on your android app, do like this:

First if you want to have icon for the button, down load the icons from here: https://www.google.com/design/icons/index.html#ic_search

The document for introduction of action bar and buttons are here (less important for you, if you just want to implement with your new phone, and you don't care too much about which version balabalabala, you don't have to check this out): https://developer.android.com/training/basics/actionbar/setting-up.html

For how to coding:  https://developer.android.com/training/basics/actionbar/adding-buttons.html

Very simple and easy, if you use the latest version of android studio, it should set all things for you.




Only one things you should take care of is: "showAsAction"

You should use app namespace (which is already created by android studio)


One more thing for the button:

if you want to show the text only without icon, you should not specify it on the xml, and that is it.




No comments:

Post a comment