In my android app, I can't use AppCompatActivity. I have no source code of this part of the project. So I use
androidx.fragment.app.FragmentActivity
app theme:
<style name="MainAppBaseTheme" parent="Theme.AppCompat.Light.DarkActionBar">
my layout with toolbar:
<androidx.drawerlayout.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<androidx.appcompat.widget.Toolbar
android:id="@+id/toolBar"
android:layout_width="match_parent"
android:layout_height="@dimen/tool_bar_height"/>
<!-- Framelayout to display Fragments -->
<FrameLayout
android:id="@+id/frame_container"
android:layout_width="match_parent"
android:layout_height="match_parent">
</FrameLayout>
</LinearLayout>
</androidx.drawerlayout.widget.DrawerLayout>
Here is my code snippet:
import androidx.appcompat.app.ActionBarDrawerToggle;
import androidx.appcompat.widget.Toolbar;
public class MainNavigationDrawerFragmentActivity extends androidx.fragment.app.FragmentActivity
mToolbar = (Toolbar) findViewById(R.id.toolBar);
toolbaTitleTextView = (TextView) findViewById(R.id.toolbaTitleTextView);
actionBarDrawerToggle = new ActionBarDrawerToggle(
this,
mDrawerLayout,
mToolbar,
R.string.application_name,
R.string.application_name) {
public void onDrawerClosed(View view) {
toolbaTitleTextView.setText(mTitle);
invalidateOptionsMenu();
}
as result toolbar is show but menu not show. To show the menu I need to use
setSupportActionBar(toolbar);
but I can't use this method, because I can't use AppCompatActivity
.
Is it possible to replace setSupportActionBar(toolbar);
by another method or maybe settings/styles to show menu it toolbar?