diff --git a/android/titanium/src/java/org/appcelerator/titanium/proxy/ActionBarProxy.java b/android/titanium/src/java/org/appcelerator/titanium/proxy/ActionBarProxy.java index 988e87c6746..3d29ce309e2 100644 --- a/android/titanium/src/java/org/appcelerator/titanium/proxy/ActionBarProxy.java +++ b/android/titanium/src/java/org/appcelerator/titanium/proxy/ActionBarProxy.java @@ -15,6 +15,7 @@ import org.appcelerator.titanium.TiC; import org.appcelerator.titanium.util.TiConvert; import org.appcelerator.titanium.util.TiUIHelper; +import org.appcelerator.titanium.view.TiDrawableReference; @SuppressWarnings("deprecation") @Kroll.proxy(propertyAccessors = { TiC.PROPERTY_ON_HOME_ICON_ITEM_SELECTED, TiC.PROPERTY_CUSTOM_VIEW }) @@ -102,6 +103,17 @@ public void setBackgroundImage(String url) actionBar.setDisplayShowTitleEnabled(showTitleEnabled); actionBar.setBackgroundDrawable(backgroundImage); + } else { + // fallback check with TiDrawableReference + TiDrawableReference source = TiDrawableReference.fromUrl(this, url); + if (source.getDrawable() != null) { + actionBar.setDisplayShowTitleEnabled(!showTitleEnabled); + actionBar.setDisplayShowTitleEnabled(showTitleEnabled); + actionBar.setBackgroundDrawable(source.getDrawable()); + } else { + // fail - show error + Log.e(TAG, "Image " + url + " not found"); + } } } diff --git a/apidoc/Titanium/Android/ActionBar.yml b/apidoc/Titanium/Android/ActionBar.yml index 2450257cbde..db9f36e9bb5 100644 --- a/apidoc/Titanium/Android/ActionBar.yml +++ b/apidoc/Titanium/Android/ActionBar.yml @@ -55,6 +55,15 @@ examples: ``` + + `app/controllers/index.js`: + ``` + function doMenuClick() {} + function openSettings() {} + function doSearch() {} + $.index.open(); + ``` + `app/styles/index.tss`: ``` "MenuItem": { @@ -85,7 +94,7 @@ examples: win.activity.onCreate = () => { const actionBar = win.activity.actionBar; if (actionBar) { - actionBar.backgroundImage = "/bg.png"; + actionBar.backgroundImage = Ti.Filesystem.getFile(Ti.Filesystem.resourcesDirectory, 'bg.png').nativePath; actionBar.title = "New Title"; actionBar.onHomeIconItemSelected = () => { Ti.API.info("Home icon clicked!");