xml - Android action bar drop-down menu button doesn't show up -
i'm trying menu button show @ 11:41 in tutorial below. https://www.youtube.com/watch?v=bsb2jugxegs?t=11m41s
here's code:
first_layout.xml
<relativelayout 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" 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=".firstactivity" android:clickable="false"> <textview android:text="@string/hello_world" android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/textview" /> </relativelayout>
styles.xml
<resources> <!-- base application theme. --> <style name="apptheme" parent="theme.appcompat.light"> <!-- customize theme here. --> </style> </resources>
strings.xml
<resources> <string name="app_name">firstapp</string> <string name="hello_world">hello world!</string> <string name="action_settings">settings</string> </resources>
firstactivity.java
package lj.com.firstapp; import android.os.bundle; import android.support.v7.app.*; import android.view.menu; import android.view.menuitem; public class firstactivity extends appcompatactivity { @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.first_layout); } @override public boolean oncreateoptionsmenu(menu menu) { // inflate menu; adds items action bar if present. getmenuinflater().inflate(r.menu.menu_first, menu); return true; } @override public boolean onoptionsitemselected(menuitem item) { // handle action bar item clicks here. action bar // automatically handle clicks on home/up button, long // specify parent activity in androidmanifest.xml. int id = item.getitemid(); //noinspection simplifiableifstatement if (id == r.id.action_settings) { return true; } return super.onoptionsitemselected(item); } }
i'm using api 22, not sure if i'm missing or if it's suppose this? http://i.stack.imgur.com/gpysw.png
there no problem apparently. when ran app in emulator toolbar showed suppose to. it's isn't active in android studio preview window.
Comments
Post a Comment