Android Activitygroup's Child Activity Settitle Not Working
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.
- Home Activity
- Artists Activity
- 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"