[TIMOB-11645] Android: Allow changing title of an action bar
| GitHub Issue | n/a |
|---|---|
| Type | Sub-task |
| Priority | High |
| Status | Closed |
| Resolution | Fixed |
| Resolution Date | 2012-11-13T22:06:31.000+0000 |
| Affected Version/s | n/a |
| Fix Version/s | n/a |
| Components | Android |
| Labels | actionbar, qe-testadded |
| Reporter | Allen Yeung |
| Assignee | Allen Yeung |
| Created | 2012-11-02T00:37:14.000+0000 |
| Updated | 2016-02-29T15:23:37.000+0000 |
Description
We need to be able to set the title fo the action bar. We need to figure where we should be placing this API point in Titanium
Test case: 1. Set your target sdk version to 14 by adding the entry if your tiapp.xml"
2. Run the following code:<android xmlns:android="http://schemas.android.com/apk/res/android"> <manifest> <uses-sdk android:minSdkVersion="8" android:targetSdkVersion="14"/> </manifest> </android>Expect result: You should see 'TITANIUM APP' as the title of the action barvar win = Ti.UI.createWindow({ fullscreen : true, backgroundColor : 'black' }); win.addEventListener('open', function() { var actionBar = win.activity.actionBar; actionBar.setTitle('TITANIUM APP'); }); win.open();Currently the title obeys the window title as expected. Although, I'm not able to change the ActionBar text while using a TabGroup. The ActionBar remains empty. I have tried to set title for the TabGroup, for the Tabs and for the Window inside the active Tab: - TabGroup: does nothing - Tab: obviously changes the title in the tab only - Window of Tab: does nothing I also have no idea about where to add that event listener, since my main object is a TabGroup and not a Window.
Good catch, Igor. Yes, it seems like the actionBar property is not getting set on windows in TabGroups. I'll open a ticket.
'TITANIUM APP' is displayed on the title of the action bar as expected. Hence closing it. Verified on: Device : Google Nexus 7, Android Version: 4.1 SDK version: 3.1.0.v20130320190115 CLI version : 3.0.24 OS : MAC OSX 10.7.5 XCode : 4.5.1
@Allen, The documentation for a window states that the activity property will be undefined if its a lightweight activity (aka if it's a window in a tabgroup). Instead of trying to get the activity reference from the window, you must get it from the tabgroup instead.
var tabGroup = .........; tabGroup.addEventListener('open', function() { var actionBar = tabGroup.activity.actionBar; actionBar.setTitle('TITANIUM APP'); });