【发布时间】:2019-02-08 00:49:41
【问题描述】:
我正在为我的应用程序使用this 示例。此示例没有操作栏。
这是我想在其中添加带有选项菜单的操作栏的活动布局:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="500dp"
android:layout_gravity="bottom"
android:background="#000"
tools:context="com.example.android.camera2basic.CameraActivity" />
</LinearLayout>
所以,LinearLayout 和其中的 FrameLayout 作为片段的容器。在主要活动中,我实现了onCreateOptionsMenu 并添加了setSupportActionBar((Toolbar)findViewById(R.id.my_toolbar));,但没有出现带有菜单的操作栏。
如何向此活动添加带有菜单的ActionBar?
【问题讨论】:
标签: android android-actionbar android-menu