いくら頑張ってもActionBarにAction Buttonが表示されない。
<menu xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" tools:context="com.example.test.MainActivity" > <item android:id="@+id/hoge" android:icon="@drawable/ic_foo" android:showAsAction="always" /> </menu>上のように組んでも表示されない。
なぜかなーっと考えていたら
Actionbar not shown with AppCompat
に答えがありました。ずばり下のようにしたら表示された。
<menu xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" xmlns:compat="http://schemas.android.com/apk/res-auto" tools:context="com.example.test.MainActivity" > <item android:id="@+id/hoge" android:icon="@drawable/ic_foo" compat:showAsAction="always" /> </menu>単純にライブラリを使っているので、XML名前空間をそっちに設定しないといけないようです。
0 コメント:
コメントを投稿