Skip to content

Instantly share code, notes, and snippets.

@skypanther
Created October 12, 2012 18:50
Show Gist options
  • Save skypanther/3880804 to your computer and use it in GitHub Desktop.
Save skypanther/3880804 to your computer and use it in GitHub Desktop.
Android 4 theme and menu
<?xml version="1.0" ?><manifest android:versionCode="1" android:versionName="1" package="com.appcelerator.holotheme" xmlns:android="http://schemas.android.com/apk/res/android">
<uses-sdk android:minSdkVersion="8"/>
<uses-sdk android:targetSdkVersion="14"/>
<!-- TI_MANIFEST -->
<application android:debuggable="false" android:icon="@drawable/appicon" android:label="HoloTheme" android:name="HolothemeApplication" android:theme="@android:style/Theme.Holo.Light">
<!-- TI_APPLICATION -->
<activity android:configChanges="keyboardHidden|orientation|screenSize" android:label="HoloTheme" android:name=".HolothemeActivity" android:theme="@android:style/Theme.Holo.Light">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<activity android:configChanges="keyboardHidden|orientation|screenSize" android:name="org.appcelerator.titanium.TiActivity"/>
<activity android:configChanges="keyboardHidden|orientation|screenSize" android:name="org.appcelerator.titanium.TiTranslucentActivity" android:theme="@android:style/Theme.Translucent"/>
<activity android:configChanges="keyboardHidden|orientation|screenSize" android:name="org.appcelerator.titanium.TiModalActivity" android:theme="@android:style/Theme.Translucent"/>
<activity android:configChanges="keyboardHidden|orientation|screenSize" android:name="ti.modules.titanium.ui.TiTabActivity"/>
<activity android:name="ti.modules.titanium.ui.android.TiPreferencesActivity"/>
<service android:exported="false" android:name="org.appcelerator.titanium.analytics.TiAnalyticsService"/>
</application>
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.INTERNET"/>
</manifest>
//
// On Android 3/4 creates a Holo themed app
//
var win = Titanium.UI.createWindow({
title:'Holo Theme with Titanium!',
backgroundColor:'#fff',
navBarHidden: false,
actionBar: true,
exitOnClose: true,
activity: {
onCreateOptionsMenu: function(e) {
var item = e.menu.add({title: 'Expand'});
item.showAsAction = Ti.UI.Android.SHOW_AS_ACTION_IF_ROOM | Ti.UI.Android.SHOW_AS_ACTION_WITH_TEXT;
var collapseActionButton = Ti.UI.createButton({
title: 'Collapse'
});
collapseActionButton.addEventListener('click', function() {
item.collapseActionView();
});
item.actionView = collapseActionButton;
item.addEventListener('expand', function() {
alert('Expanded menu item!');
});
item.addEventListener('collapse', function() {
alert('Collapsed menu item!');
});
item.addEventListener('click', function() {
alert('clicked!');
});
}
}
});
win.open();
<?xml version="1.0" encoding="UTF-8"?>
<ti:app xmlns:ti="http://ti.appcelerator.org">
<deployment-targets>
<target device="mobileweb">true</target>
<target device="iphone">true</target>
<target device="ipad">true</target>
<target device="android">true</target>
<target device="blackberry">false</target>
</deployment-targets>
<sdk-version>3.0.0.v20121002103353</sdk-version>
<id>com.appcelerator.holotheme</id>
<name>HoloTheme</name>
<version>1.0</version>
<publisher>tpoulsen</publisher>
<url>http://</url>
<description>not specified</description>
<copyright>2012 by tpoulsen</copyright>
<icon>appicon.png</icon>
<persistent-wifi>false</persistent-wifi>
<prerendered-icon>false</prerendered-icon>
<statusbar-style>default</statusbar-style>
<statusbar-hidden>false</statusbar-hidden>
<fullscreen>false</fullscreen>
<navbar-hidden>false</navbar-hidden>
<analytics>true</analytics>
<guid>b2d49741-e443-43e1-ae9b-7d607e0718f5</guid>
<property name="ti.ui.defaultunit">system</property>
<iphone>
<orientations device="iphone">
<orientation>Ti.UI.PORTRAIT</orientation>
</orientations>
<orientations device="ipad">
<orientation>Ti.UI.PORTRAIT</orientation>
<orientation>Ti.UI.UPSIDE_PORTRAIT</orientation>
<orientation>Ti.UI.LANDSCAPE_LEFT</orientation>
<orientation>Ti.UI.LANDSCAPE_RIGHT</orientation>
</orientations>
</iphone>
<android xmlns:android="http://schemas.android.com/apk/res/android">
<tool-api-level>14</tool-api-level>
</android>
<mobileweb>
<precache/>
<splash>
<enabled>true</enabled>
<inline-css-images>true</inline-css-images>
</splash>
<theme>default</theme>
</mobileweb>
<modules/>
</ti:app>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment