According to the tutorials that I have read, the method addToBackStack(null) is the right way to get back to the previous fragment or activity loaded. But on my part, the addToBackStack() is missing on the ft
object that holds the FragmentManager class. Here's my code.
conteach.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
SpecificArticleFragment spcf = new SpecificArticleFragment();
Bundle args = new Bundle();
args.putString("art_id", v.getTag().toString());
spcf.setArguments(args);
FragmentManager ft = getFragmentManager();
ft.beginTransaction().replace(R.id.content_frame, spcf).commit();
//I know that I should put the ft.addToBackStack(null) code here but the addToBackStack(null) method does not exist on the ft object
}
});
Anyway, according to my understanding if the SpecificArticleFragment
fragment loads, I can go back to the existing fragment where the code above was located. What is the best way to fix this?