volley display previous fragment response in new fragment when replacing previous fragment to new fragment via navigation drawer
Asked Answered
C

1

7

i have a total 12 fragment in navigation drawar.. each fragment has volley method. and each fragment display its own volley response except position = 1 and position = 5 fragment.

when my app start

Scenario 1: i open position 1 fragment and after i open position 5 fragment than both fragment has position 1 fragment response.

Scenario 2: if i open position 5 fragment and after open position 1 fragment than both fragment has position 1 fragment response.

Scenario 1 images:

FragmentInbox FragmentLaws

Scenario 2 images:

FragmentLaws FragmentInbox

My fragment transaction method class:

private void showFragment(Fragment fragment) {
    llContainer = (LinearLayout)findViewById(R.id.container);
    if (fragment != null) {
        llContainer.removeAllViewsInLayout();
        FragmentManager fragmentManager = getSupportFragmentManager();
        FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
        fragmentTransaction.replace(R.id.container, fragment, fragment.getClass().getName());
        fragmentTransaction.commit();
        fragmentManager.popBackStack();
    }
}


@Override
public void onItemSelected(int position) {
    Fragment frag = null;
    switch (position) {
        case POS_HOME:
            frag = FragmentHome.instance(screenTitles[position]);
            break;
        case POS_INBOX:
            txtToolbarTitle.setVisibility(View.VISIBLE);
            txtToolbarTitle.setText("Notifications");
            frag = FragmentInbox.instance(screenTitles[position]);
            break;
        case POS_LOG:
            frag = FragmentLog.instance(screenTitles[position]);;
            break;
        case POS_BOOK:
            frag = FragmentBook.instance(screenTitles[position]);
            break;
        case POS_BUILDING:
            frag = FragmentBuilding.instance(screenTitles[position]);
            break;
        case POS_LAWS:
            frag = FragmentLaws.instance();
            break;
        case POS_DOCUMENT:
            frag = FragmentDocument.instance(screenTitles[position]);
            break;
        case POS_EVENT:
            frag = FragmentEvent.instance(screenTitles[position]);
            break;
        case POS_BOARD:
            frag = FragmentBoard.instance(screenTitles[position]);
            break;
        case POS_AROUND:
            frag = FragmentAround.instance(screenTitles[position]);
            break;
        case POS_PROFILE:
            frag = FragmentProfile.instance(screenTitles[position]);
            break;
        case POS_CONCIERGE:
            frag = FragmentConcierge.instance(screenTitles[position]);
            break;
    }

    showFragment(frag);
    mSlideMenu.closeMenu();
}
Cluj answered 16/10, 2017 at 6:32 Comment(1)
Can you please tell us which fragment corresponds to which positionLongwise
C
0

The problem is in viewPagers, in both fragment viewpager has same id. So i just change fragmentInbox's viewpager id, and its working now.

Cluj answered 25/10, 2017 at 7:13 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.