Overflow and other menu items not displayed on Android -
i trying add toolbar action bar , having trouble getting besides name of app display. adding toolbar appcompat , have created menu xml file. there necessary step need take in order link two?
here activity xml:
<?xml version="1.0" encoding="utf-8"?> <framelayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" xmlns:app="http://schemas.android.com/apk/res-auto" android:paddingleft="@dimen/activity_horizontal_margin" android:paddingright="@dimen/activity_horizontal_margin" android:paddingtop="@dimen/activity_vertical_margin" android:paddingbottom="@dimen/activity_vertical_margin" tools:context=".canvas.canvasactivity" > <com.alastech.andyluo.crowdshout_androidapp.canvas.canvastest android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/view" android:layout_gravity="center" /> <android.support.v7.widget.toolbar android:id="@+id/canvas_toolbar" android:layout_width="match_parent" android:elevation="0dp" android:layout_height="?attr/actionbarsize" android:background="?attr/colorprimary" android:theme="@style/themeoverlay.appcompat.actionbar" app:popuptheme="@style/themeoverlay.appcompat.light"/> </framelayout>
i sure toolbar being added layout correctly because have been able change size , has been reflected correctly when runs.
here xml menu:
<?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/action_new_shout" android:icon="@drawable/ic_add_black_48dp" android:title="@string/action_new_shout" app:showasaction="always" /> <item android:id="@+id/action_menu" android:title="@string/action_menu" app:showasaction="never" /> </menu>
and thing shows in action bar:
just clear pretty following tutorial exactly: http://developer.android.com/training/appbar/index.html
any appreciated, thank you!
add below method in activity
@override public boolean oncreateoptionsmenu(menu menu) { // use sample_actions or wheever xml menufile name below getmenuinflater().inflate(r.menu.sample_actions, menu); return true; }
Comments
Post a Comment