簡體   English   中英

片段導航問題

[英]Fragment navigation issue

我有一個包含列表的片段。從列表中選擇一個元素后,它會導航到具有某些特定數據的另一個片段。 當我從片段 2 向后按下時,我得到片段 1,其中列表顯示了兩次。

后按前的片段1

受壓前

后按后的 Fragment1

背壓后

下面是我從 Fragment1 到 Fragment2 的片段交易代碼

    fragmentManager = mainActivityContext.getSupportFragmentManager();
    fragmentTransaction = fragmentManager.beginTransaction();
    SurveyOverView surveyOverView = new SurveyOverView();
    Bundle bundle = new Bundle();
    bundle.putParcelable("SURVEY_QUESTION",surveys.get(position));
    surveyOverView.setArguments(bundle);      fragmentTransaction.replace(R.id.fragment_container,surveyOverView,FRAG_TAG);
    fragmentTransaction.addToBackStack(null);

    fragmentTransaction.commit();

請幫助我不知道如何解決這個問題。

此問題最可能的原因是您在沒有先清除其當前數據的情況下將數據添加到現有列表。 發布您的代碼以獲取更多詳細信息。

暫無
暫無

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

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