Click here to Skip to main content
15,888,113 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have created a activity in which I placed a fragment and inside fragment I have used a card view. when I click on card view it moves to next fragment and set title of card view to next fragment toolbar. The problem is when I press back button previous fragment not showing its name and showing next fragment name. Is there any solution for this problem?

What I have tried:

cardLaw.setOnClickListener(new View.OnClickListener() {
           @Override
           public void onClick(View v) {
               replaceFragment(new CategoryDetailFragment());
               ((MainActivity) getActivity()).getSupportActionBar().setTitle("Law & Order");
           }
       });
Posted
Comments
David Crow 26-Jan-20 21:37pm    
I would recommend each Fragment setting its own title, not the Activity that "owns" the Fragment.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900