Skip to content Skip to sidebar Skip to footer

Android Activitygroup's Child Activity Settitle Not Working

I have TabActivityGroup: MainActivity class contain some tab, that name loading from db. Sales, Admin, Inquiry like wise I have tab name For Sales I created SalesActivityGroup.Tha

Solution 1:

You can access the parent tab activity like

getParent().getParent().setTitle("New Tilte");

EXPLANATION:

Based on my understanding, When you call the getParent the first time, you get the activity group that started the child activity.

When you call getParent the second time, you will get the tab activity that started the activity group.

setTitle should work for the activity window which is held by the tabactivity. The sub activities are rendered in the framelayout of the tab activity. So in the child activities access the parent tab activity to set the title.

Solution 2:

The best way to do this is to implement the method

protected void onChildTitleChanged(Activity childActivity,CharSequence title) {
    super.onChildTitleChanged(childActivity, title);
    setTitle(title);
}

Implement this method in the parent activity. For example, In my case I have three activities.

  1. Home Activity
  2. Artists Activity
  3. Album Activity

My Home activity contains a TabHost with Artists activity and Album activity. I implemented the above method in the Home Activity. The title for Artists activity and Album activity is set in the OnResume methods of those respective activities.

Solution 3:

It is not advisable to use ActivityGroup, it has been deprecated. Refer to this link Please use Fragment and FragmentManager using Compatibility Library

Post a Comment for "Android Activitygroup's Child Activity Settitle Not Working"