Created
June 27, 2013 20:45
-
-
Save egomez99/5880254 to your computer and use it in GitHub Desktop.
TIMOB-2433 Android: OptionMenu MenuItem's click callbacks don't persist w/ tabbed window switching
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Ti.API.info("@ win_test.js"); | |
var win = Ti.UI.createWindow(); | |
win.backgroundColor = "#b5aea5"; | |
win.open(); | |
var button = Ti.UI.createButton({ | |
title: 'new window' | |
}); | |
button.addEventListener('click', function(e) { | |
var subwin = Ti.UI.createWindow({url: 'main.js', navBarHidden: 'true'}); | |
subwin.open(); | |
}); | |
win.add(button); | |
win.open(); | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Ti.API.info("@ win_test.js"); | |
var win = Ti.UI.currentWindow; | |
win.backgroundColor = "#b5aea5"; | |
var activity = Ti.Android.currentActivity; | |
activity.onCreateOptionsMenu = function(e) { | |
var aMenu = e.menu; | |
var test1 = aMenu.add({ | |
title: 'Test1', | |
}); | |
test1.addEventListener('click', function() { | |
alert("alert: Test1"); | |
}); | |
var test2 = aMenu.add({ | |
title: 'Test2', | |
}); | |
test2.addEventListener('click', function() { | |
alert("alert: Test2"); | |
Ti.API.info("Ti.API.info: Test"); | |
}); | |
//Now, make a request and add a menu item from a non-UI thread... | |
var request = Ti.Network.createHTTPClient({ | |
timeout: 15000 //15 seconds | |
}); | |
request.onload = function(e) { | |
Ti.API.info('HTTPClient onload, status: ' + this.status); | |
Ti.API.info("Adding additional menu item (this will fail)"); | |
var test3 = aMenu.add({ | |
title: 'Test3', | |
}); | |
test3.addEventListener('click', function() { | |
alert("alert: Test3"); | |
}); | |
/* | |
Ti.API.error ("getItem: " + aMenu.getItem(0)); | |
Ti.API.error ("setGroupEnabled: " + aMenu.setGroupEnabled(0, true)); | |
Ti.API.error ("setGroupVisible: " + aMenu.setGroupVisible(0, true)); | |
Ti.API.error ("removeGroup: " + aMenu.removeGroup(0)); | |
Ti.API.error ("removeItem: " + aMenu.removeItem(0)); | |
Ti.API.error ("clear: " + aMenu.clear()); | |
Ti.API.error ("close: " + aMenu.close()); | |
*/ | |
}; | |
var url = "http://www.google.com/"; | |
Ti.API.info('Making GET call to: ' + url); | |
request.open("GET", url, true); | |
request.send(); | |
} | |
var displayName = Ti.UI.createLabel({ | |
top: 0, | |
left: 0, | |
font:{fontSize: 20, fontWeight:'bold'}, | |
height: 30, | |
width: 320, | |
color:'#000000', | |
text:"Testing 123" | |
}); | |
win.add(displayName); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment