簡體   English   中英

如何使用導航組件從一個活動導航到另一個活動,並從堆棧中刪除第一個活動?

[英]How can I navigate from an activity to another using Navigation Component and removing the first activity from the stack?

在我的應用程序中,我有兩個活動(AuthenticationActivity和MainActivity),每個活動都有一個導航圖和大量片段。 我創建了一個動作,以從AuthenticationActivity的圖的片段導航到MainActivity,但是即使將'popTo'設置為Authentication graph id,它也不會從堆棧中刪除AuthenticationActivity。

在導航方法之后完成身份驗證活動:

button2.setOnClickListener {
        view.findNavController().navigate(R.id.action_addItemFragment_to_mainActivity)
        (activity as AuthenticationActivity).finish()
    }

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM