Android : Android: Change activity title when navigating fragments; Bring back same titles when back button clicked

on Wednesday, March 25, 2015


I Have a fragment called categories_collection the application initially launches with this fragment and the activity title is the application title.



Category 1

Category 2

- Category 2.1

- Category 2.2

Category 3



what i do is when a user clicks on a category that has children i re-call the same categories_collection fragment with an extra field called parent to load the categories that are the children of the clicked category. this is all done and working well.


What i need is the following



  1. User clicks on category 2. the Main activity title changes to "Category 2"

  2. The user is now browsing the children of "Category 2" when clicking on a child. the Activity title changes to the sub category name which is "Category 2.1" and so on..

  3. Most importantly when clicking the "Back Button" the title of the Activity changes to what it was. so lets say i went back from opening the sub category so the title changes to "Category 2" again as i keep browsing the children of "Category 2"


I hope this explains what i need.


Thanks.


0 comments:

Post a Comment