Details
-
Type:
Bug
-
Status: Closed
-
Priority:
Critical
-
Resolution: Fixed
-
Affects Version/s: Release 3.0.0
-
Fix Version/s: Release 3.0.2, Release 3.1.0, 2013 Sprint 02 API, 2013 Sprint 02
-
Component/s: Android
-
Labels:
Description
Starting from API 11, menuItem methods must be run from the main thread, otherwise a Java exception will occur. MenuItemProxy needs to be refactor to address this issue.
Testing code:
|
var win1 = Ti.UI.createWindow({
|
backgroundColor: 'blue',
|
fullscreen: false
|
});
|
var tab1 = Ti.UI.createTab({
|
window: win1,
|
title: 'Tab 1'
|
});
|
|
var win2 = Ti.UI.createWindow({
|
backgroundColor: 'yellow'
|
});
|
var tab2 = Ti.UI.createTab({
|
window: win2,
|
title: 'Tab 2'
|
});
|
|
var tabGroup = Ti.UI.createTabGroup({
|
activity: {
|
onCreateOptionsMenu: function(e) {
|
var menu = e.menu;
|
var menuItem = menu.add({
|
title : "Item 1",
|
itemId: 1
|
});
|
var menuItem2 = menu.add({
|
title : "Item 2",
|
itemId: 2
|
});
|
menuItem.addEventListener("click", function(e) {
|
Ti.API.info("I was clicked");
|
});
|
},
|
|
onPrepareOptionsMenu: function(e) {
|
var menu = e.menu;
|
if (tab1.active) {
|
menu.findItem(1).setVisible(false);
|
var menuItem2 = menu.findItem(2);
|
menuItem2.setVisible(true);
|
Ti.API.info("item2 is checked: " + menuItem2.isChecked());
|
Ti.API.info("item2 is enabled: " + menuItem2.isEnabled());
|
|
}
|
|
if (tab2.active) {
|
var menuItem = menu.findItem(1);
|
menuItem.setVisible(true);
|
Ti.API.info("item1 is checked: " + menuItem.isChecked());
|
Ti.API.info("item1 is enabled: " + menuItem.isEnabled());
|
menu.findItem(2).setVisible(false);
|
}
|
}
|
}
|
});
|
|
tabGroup.addTab(tab1);
|
tabGroup.addTab(tab2);
|
tabGroup.open();
|
|
1. Run app.js
2. Click on menu/optionMenu button: you should see Item 2 in tab1 and Item 1 in tab2. You should also see "is checked" and "is enabled" in logcat.
Attachments
Issue Links
- relates to
-
TIMOB-1512 Android: OptionMenu is not working with TabGroup
-
- Closed
-