[英]Question about BottomNavigationView in Android
我有關於 BottomNavigationView 的一般性問題。 我想在應用程序中的每個活動中都有一個底部導航視圖,用於訂購某些東西(例如食物)。 它應該有 4 個按鈕:
使用“返回”,應用程序應該只是 go 回到上一個活動。 按鈕“統計”和“我的訂單”應切換到不顯示時不應被破壞的持久活動。 “我的訂單”應顯示最后的訂單。 按鈕“信息”應該只顯示有關當前項目或當前菜單的一些信息(取決於調用它的活動)。 所以基本上我有兩個問題:
我會很感激每一條評論,我真的很感激你的幫助。
Single Activity
和Multiple fragments
。 您可以使用Jetpack's Navigation Component
來執行此操作data from an Activity/Fragment to the new calling Fragment
,可以通過在調用 Fragment setting arguments on the calling fragment
被調用 Fragment 上getting it on the called fragment
完成。 如果有something which requires to be dynamic, for example- dishes fragment
, make a single fragment and common layout and load the data dynamically from the backend
。對於設置 Arguments ,這應該會有所幫助
如何將變量從 Activity 傳遞到 Fragment,並將其傳回?
注意:您可以在不使用Navigation Components
的情況下使用片段,但您必須使用FragmentManager and FragmentTransaction and also have to maintain the Backstack by yourself which could be quite complicated
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.