scratching my head. if someone could help that would be great. I am switching from extends ActionBarActivity
to extends AppCompatActivity
with Toolbar and need help displaying items on toolbar.
I am using extends AppCompatActivity
included android.support.v7.app.AppCompatActivity
; then inside onCreate()
have:
Toolbar jobListToolbar = (Toolbar) findViewById(R.id.job_list_toolbar);
setSupportActionBar(jobListToolbar);
then in xml file I have
<android.support.v7.widget.Toolbar
android:id="@+id/job_list_toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
android:elevation="4dp"
android:theme="@style/ThemeOverlay.AppCompat.ActionBar"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"/>
then in menu file I have items and everything seems to work, however not the way I want.
Toolbar/ActionBar is displayed on top of the screen, but no menu items showing on it. If I press phone original menu button then onCreateOptionsMenu(Menu menu)
is initiated for the first time, and menu is showing. But it shows just above this phone button. But I want those buttons to show on Toolbar/ActionBar on top of the screen. I read somewhere that if phone has hardware menu button it will not show menu items in Toolbar/ActionBar, but I had it somehow done with extends ActionBarActivity
, but there should be a way to do this with extends AppCompatActivity
. Need to move to newer recommended way by google, but not sure how to show items on that Toolbar/ActionBar on the top of the screen.