ツールバーにオーバーフローメニューがあり、これを使ってアクティビティ間を移動できます。
<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=".HomePage">
<item
android:id="@+id/homeActionBar"
android:title="Home"
android:orderInCategory="100"
app:showAsAction="never" />
<item
android:id="@+id/allergiesActionBar"
android:title="Allergies"
android:orderInCategory="100"
app:showAsAction="never" />
<item
android:id="@+id/calendarActionBar"
android:title="Calendar"
android:orderInCategory="100"
app:showAsAction="never" />
<item
android:id="@+id/contactsActionBar"
android:title="Contacts"
android:orderInCategory="100"
app:showAsAction="never" />
これらのすべてのオプションを含むオーバーフローボタンが私のツールバーの右側に表示されます。それを左いっぱいに配置する方法を知っている人はいますか?
これは関連するが二次的な質問です。 断片はありません。それらはすべての活動を表します。ツールバーでそれらの間を移動したいです。何がこれに最善の解決策ですか?また、オーバーフローメニューを作成しました。これは問題なく機能しているようです。一般的には最善の方法ですか?フラグメントがないためにナビゲーション用の引き出しを避けています。
ありがとうございました。
回答:
回答№1は0本当に左側にオーバーフローメニューを表示したい場合は、独自のカスタムツールバーを作成する必要があります。 xml
この例のようなコードを使用して、既存のバージョンを既存のバージョンに置き換えるのではなく、
これが私にとって夢のように機能するものです。
//hiding default app icon ActionBar actionBar = getActionBar(); actionBar.setDisplayShowHomeEnabled(false); //displaying custom ActionBar View mActionBarView = getLayoutInflater().inflate(R.layout.my_action_bar, null); actionBar.setCustomView(mActionBarView); actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM) my_action_bar.xml: <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@color/turquoise"> <ImageButton android:id="@+id/btn_slide" android:layout_height="wrap_content" android:layout_width="wrap_content" android:background="@null" android:scaleType="centerInside" android:src="@drawable/btn_slide" android:paddingRight="50dp" android:onClick="toggleMenu" android:paddingTop="4dp"/> </RelativeLayout>
左側のAndroidアプリでは、以前はNavigation Drawerメニューだったことに注意してください。あなたがオーバーフローメニューの代わりにそれを持ちたいと思うならば、これをチェックしてください: Androidアクションバーの左メニュー
希望する