Titanium JIRA Archive
Appcelerator Community (AC)

[AC-1389] Actionbar is undefined on Android < 3.0

GitHub Issuen/a
TypeBug
Priorityn/a
StatusClosed
ResolutionInvalid
Resolution Date2014-10-15T02:14:50.000+0000
Affected Version/sn/a
Fix Version/sn/a
Componentsn/a
Labels3.3.0.GA, actionbar, android, appcompat
ReporterManuel Lehner
AssigneeShuo Liang
Created2014-07-24T10:16:43.000+0000
Updated2016-03-08T07:37:48.000+0000

Description

Titanium.Android.ActionBar is not defined on Android version 2.3.7 (API 10) and prior. Since Titanium 3.3.0 using AppCombat this should be possible as the ActionBar is available.

Steps to reproduce:

1. Create new default app 2. Copy below example code into app.js 3. Run on Android emulator / device with Android 2.3.7 (API 10)

Expected result:

actionbar should return a valid reference

Actual result:

actionbar is undefined
var win = Ti.UI.createWindow();
win.addEventListener('open', doOpen);

function doOpen(){
    var activity = win.activity;
    var actionbar = activity.actionbar;
    
    Ti.API.info(activity);
    Ti.API.info(actionbar);
}

win.open();
Q&A: http://developer.appcelerator.com/question/176443/hide-actionbar-on-tisdk330-with-android-2x-devices

Comments

  1. Shuo Liang 2014-08-01

    Hi, Can you try this sample code in your device, as it works in my android 2.3.6.
       var win = Ti.UI.createWindow({
           title: "Old Title",
           navBarHidden: false
       });
       var actionBar;
       
       win.addEventListener("open", function() {
           if (Ti.Platform.osname === "android") {
               if (! win.activity) {
                   Ti.API.error("Can't access action bar on a lightweight window.");
               } else {
                   actionBar = win.activity.actionBar;
                   if (actionBar) {
                       actionBar.backgroundImage = "/bg.png";
                       actionBar.title = "New Title";
                       actionBar.onHomeIconItemSelected = function() {
                           Ti.API.info("Home icon clicked!");
                       };
                   }
               }
           }
       });
       
       win.open();
       

JSON Source