Note that there are some explanatory texts on larger screens.

plurals
  1. POfragment not being removed
    text
    copied!<p>After many days of trying to find a solution for having a dual pane fragment along with tabs, i gave up and made my own listview that's in a an x-large layout for tablets, and having only fragments to manage my tabs. All my code works except one part, where i am trying to remove the old fragment in the tab and create a new fragment based on the item clicked in the list. </p> <p>Here is where the fragments for the tabs are generated:</p> <pre><code>public class AppSectionsPagerAdapter extends FragmentPagerAdapter { public AppSectionsPagerAdapter(FragmentManager fm) { super(fm); } //THESE FRAGMENTS ARE GENERATED WITH TABS AT START @Override public Fragment getItem(int i) { switch (i) { case 0: return new DescriptionFragment(); case 1: return new ImagesFragment(); default: return new DescriptionFragment(); } } </code></pre> <p>where i add fragments from a listview click:</p> <pre><code>public void addfragment() { //THIS FRAGMENT GOES ON TOP AFTER LISTVIEW CLICK kick_activity.this.getSupportFragmentManager().popBackStack(); DescriptionFragment fragment = new DescriptionFragment(); android.support.v4.app.FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); ft.replace(R.id.container, fragment); ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN); ft.commit(); } </code></pre> <p>my DescriptionFragment fragment: </p> <pre><code> public static class DescriptionFragment extends Fragment { @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_section_description, container, false); text = ((TextView) rootView.findViewById(R.id.description)); text.setText(Html.fromHtml(description_text)); return rootView; } </code></pre> <p>I know what i'm doing wrong, I just don't know how to fix it. It seems that the fragment from getItem() is created and when i click on my listview and addfragment() is called, it overlays due to the fragments not being linked. What can i place in 'case 0' instead of 'return new DescriptionFragment' so that all my fragments are linked and don't overlay?</p> <p>Note - when i try and use ft.repalce in getItem() the app crashes and according to the LogCat, it cannot find R.id.container, so i cannot simply move that code in.</p> <p>Thanks in advance for your help, i will greatly appreciate any solutions as I have been stuck on this for quite a few days.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload