如何在Android中将菜单设置为工具栏
我想使用ToolBar代替ActionBar,但不要在工具栏上显示菜单!!!我想要设置菜单,如刷新或设置按钮ActionBar。 Toolbar.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"/> 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 …