I am trying to create a custom title layout but I'd still want to use the activity's original label text. Is there a way to reference the window title (label attribute) in my custom title xml? Thanks.
Asked
Active
Viewed 795 times
1
-
What do you mean by a custom title layout? – Manish Burman Aug 14 '11 at 05:18
-
Like dis http://developer.android.com/resources/samples/ApiDemos/src/com/example/android/apis/app/CustomTitle.html – Eric Chen Aug 14 '11 at 07:41
1 Answers
0
You can try to override Activity.onTitleChanged()
method. I've never tried this solution but it must work according to the Android source code.

Michael
- 53,859
- 22
- 133
- 139
-
OK - it works. A pure xml solution would be better but I am happy with this for now. – Eric Chen Aug 14 '11 at 08:01
-
In theory, if a custom title contains a `TextView` with `android:id=@android:id/title` then it will be a pure xml solution. But it's only an assumption. – Michael Aug 14 '11 at 08:31
-
Right but the custom title has already overridden the original so this doesn't work. – Eric Chen Aug 14 '11 at 08:48
-
I don't understand what you mean. Have you tried this? I mean setting `TextView`'s id to `"@android:id/title"`? – Michael Aug 14 '11 at 15:53
-
Tried that. It doesn't display anything when placed into the title bar. – Eric Chen Aug 14 '11 at 16:18
-
-
@e_x_p let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/2476/discussion-between-pixie-and-e-x-p) – Michael Aug 15 '11 at 03:38