CopyPastor

Detecting plagiarism made easy.

Score: 0.8132228032866521; Reported for: String similarity Open both answers

Possible Plagiarism

Plagiarized on 2018-08-18
by Rishav Singla

Original Post

Original - Posted on 2014-01-20
by Ahmad Raza



            
Present in both answers; Present only in the new answer; Present only in the old answer;

you can replace fragment by FragmentTransaction.
Here you go.
Make an interface.
public interface FragmentChangeListener { public void replaceFragment(Fragment fragment); }
implements your Fragment holding activity with this interface.
public class HomeScreen extends FragmentActivity implements FragmentChangeListener {

@Override public void replaceFragment(Fragment fragment) { FragmentManager fragmentManager = getSupportFragmentManager();; FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction(); fragmentTransaction.replace(mContainerId, fragment, fragment.toString()); fragmentTransaction.addToBackStack(fragment.toString()); fragmentTransaction.commit(); }
}
Call this method from Fragments like this.
//In your fragment.
public void showOtherFragment() { Fragment fr=new NewDisplayingFragment(); FragmentChangeListener fc=(FragmentChangeListener)getActivity(); fc.replaceFragment(fr); } Hope this will work!
you can replace fragment by FragmentTransaction.

Here you go.

Make an interface.
public interface FragmentChangeListener { public void replaceFragment(Fragment fragment); }

implements your Fragment holding activity with this interface.
public class HomeScreen extends FragmentActivity implements FragmentChangeListener { @Override public void replaceFragment(Fragment fragment) { FragmentManager fragmentManager = getSupportFragmentManager();; FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction(); fragmentTransaction.replace(mContainerId, fragment, fragment.toString()); fragmentTransaction.addToBackStack(fragment.toString()); fragmentTransaction.commit(); } }

Call this method from Fragments like this.

//In your fragment.
public void showOtherFragment() { Fragment fr=new NewDisplayingFragment(); FragmentChangeListener fc=(FragmentChangeListener)getActivity(); fc.replaceFragment(fr); }
Hope this will work!


**NOTE: mContainerId is id of the view who is holding the fragments inside. You should override Fragment's onString() method as well.**


        
Present in both answers; Present only in the new answer; Present only in the old answer;