Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-11645] Android: Allow changing title of an action bar

GitHub Issuen/a
TypeSub-task
PriorityHigh
StatusClosed
ResolutionFixed
Resolution Date2012-11-13T22:06:31.000+0000
Affected Version/sn/a
Fix Version/sn/a
ComponentsAndroid
Labelsactionbar, qe-testadded
ReporterAllen Yeung
AssigneeAllen Yeung
Created2012-11-02T00:37:14.000+0000
Updated2016-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

Comments

  1. Allen Yeung 2012-11-06

    Test case: 1. Set your target sdk version to 14 by adding the entry if your tiapp.xml"
           <android xmlns:android="http://schemas.android.com/apk/res/android">
               <manifest>
                   <uses-sdk android:minSdkVersion="8" android:targetSdkVersion="14"/>
               </manifest>
           </android>
       
    2. Run the following code:
       var win = Ti.UI.createWindow({
       	fullscreen : true,
       	backgroundColor : 'black'
       });
       
       win.addEventListener('open', function() {
       	var actionBar = win.activity.actionBar;
       	actionBar.setTitle('TITANIUM APP');
       });
       
       win.open();  
       
    Expect result: You should see 'TITANIUM APP' as the title of the action bar
  2. Igor Santos 2012-11-15

    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.
  3. Arthur Evans 2012-11-15

    Good catch, Igor. Yes, it seems like the actionBar property is not getting set on windows in TabGroups. I'll open a ticket.
  4. Paras Mishra 2013-03-21

    '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
  5. James O'Leary 2016-02-29

    @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');
       });
       

JSON Source