简体   繁体   English

片段导航问题

[英]Fragment navigation issue

I have a fragment which contains a list.Upon selecting one element from the list it navigate to another fragment with some specific data.我有一个包含列表的片段。从列表中选择一个元素后,它会导航到具有某些特定数据的另一个片段。 When I back pressed from fragment 2, I get fragment 1 where the list is showing twice.当我从片段 2 向后按下时,我得到片段 1,其中列表显示了两次。

fragment1 before back pressed后按前的片段1

受压前

Fragment1 after back pressed后按后的 Fragment1

背压后

Below is my fragment transaction code from Fragment1 to Fragment2下面是我从 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();

Please help I do not know how to resolve this.请帮助我不知道如何解决这个问题。

The most possible reason of this issue is you've added data to existing list without clearing its current data first.此问题最可能的原因是您在没有先清除其当前数据的情况下将数据添加到现有列表。 Post your code for more details.发布您的代码以获取更多详细信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM