Quero usar em ToolBar
vez de ActionBar
, mas não me mostre o menu na barra de ferramentas !!! desejo definir o menu, como os botões Atualizar ou ConfiguraçõesActionBar
.
Código da barra de ferramentas.xml:
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.Toolbar
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/colorPrimary"
android:minHeight="?attr/actionBarSize"
app:navigationContentDescription="@string/abc_action_bar_up_description"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:title="Main Page"
android:gravity="center"/>
Código MainPage.java:
public class MainPage extends AppCompatActivity {
private Toolbar toolbar;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main_page);
toolbar = (Toolbar) findViewById(R.id.main_toolbar);
setSupportActionBar(toolbar);
if (getSupportActionBar() != null) {
getSupportActionBar().setTitle("Main Page");
}
toolbar.setSubtitle("Test Subtitle");
toolbar.inflateMenu(R.menu.main_manu);
}
}
código main_menu.xml:
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<item
android:id="@+id/menu_main_setting"
android:icon="@drawable/ic_settings"
android:orderInCategory="100"
app:showAsAction="always"
android:actionLayout="@layout/toolbar"
android:title="Setting" />
<item
android:id="@+id/menu_main_setting2"
android:icon="@drawable/ic_settings"
android:orderInCategory="200"
app:showAsAction="always"
android:actionLayout="@layout/toolbar"
android:title="Setting" />
</menu>
Como resolver esse problema e mostrar o menu no Toolbar
? obrigado todos queridos <3