0
You need to add a method called onCreateOptionsMenu, example:
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
Inside the directory res, you must create the directory menu, and within the directory menu, you create the file main.xml.
Follow an example of the XML menu:
<menu
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
tools:context=".MainActivity">
<item
android:id="@+id/action_back"
android:icon="@drawable/ic_back"
android:orderInCategory="100"
app:showAsAction="always" />
</menu>
Each item which you add in XML, will be a button in your Actionbar.