Problem Description
When adding a menuItem to the actionBar with an actionView and
showAsAction : Ti.Android.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW | Ti.Android.SHOW_AS_ACTION_ALWAYS
to a TabGroup, the item never expands to show the actionView. This is with a TabGroup, and nothing happens when i click the 'search' icon.
Test Case
var win = Ti.UI.createTabGroup({
backgroundColor: 'blue',
fullscreen: false
});
var tab = Ti.UI.createTab({title: "test"});
var tabWin = Ti.UI.createWindow({title: "testWin"});
tab.window = tabWin;
win.add(tab);
var search;
var searchAsChild = false;
if (Ti.Platform.name == 'android' && Ti.Platform.Android.API_LEVEL > 11) {
// Use action bar search view
search = Ti.UI.Android.createSearchView({
hintText: "Table Search"
});
win.addEventListener("open", function(e) {
win.getActivity().onCreateOptionsMenu = function(e) {
var menu = e.menu;
var menuItem = menu.add({
title: 'Table Search',
actionView : search,
icon: (Ti.Android.R.drawable.ic_menu_search ? Ti.Android.R.drawable.ic_menu_search : "my_search.png"),
showAsAction: Ti.Android.SHOW_AS_ACTION_IF_ROOM | Ti.Android.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW
});
};
});
}
else {
// Use search bar
search = Ti.UI.createSearchBar({
hintText: "Table Search"
});
searchAsChild = true;
}
var data = [];
data.push(Ti.UI.createTableViewRow({title:'Apple'}));
data.push(Ti.UI.createTableViewRow({title:'Banana'}));
data.push(Ti.UI.createTableViewRow({title:'Orange'}));
data.push(Ti.UI.createTableViewRow({title:'Raspberry'}));
var tableview = Titanium.UI.createTableView({
data:data,
search:search,
searchAsChild:searchAsChild
});
win.add(tableview);
win.open();
Extra info
However, when i try it with a Window instead of a TabGroup, it does work: (note: this is identical to previous case except for changing the tabgroup to a window)
var win = Ti.UI.createWindow({
backgroundColor: 'blue',
fullscreen: false
});
//var tab = Ti.UI.createTab({title: "test"});
//var tabWin = Ti.UI.createWindow({title: "testWin"});
//tab.window = tabWin;
//win.add(tab);
var search;
var searchAsChild = false;
if (Ti.Platform.name == 'android' && Ti.Platform.Android.API_LEVEL > 11) {
// Use action bar search view
search = Ti.UI.Android.createSearchView({
hintText: "Table Search"
});
win.addEventListener("open", function(e) {
win.getActivity().onCreateOptionsMenu = function(e) {
var menu = e.menu;
var menuItem = menu.add({
title: 'Table Search',
actionView : search,
icon: (Ti.Android.R.drawable.ic_menu_search ? Ti.Android.R.drawable.ic_menu_search : "my_search.png"),
showAsAction: Ti.Android.SHOW_AS_ACTION_IF_ROOM | Ti.Android.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW
});
};
});
}
else {
// Use search bar
search = Ti.UI.createSearchBar({
hintText: "Table Search"
});
searchAsChild = true;
}
var data = [];
data.push(Ti.UI.createTableViewRow({title:'Apple'}));
data.push(Ti.UI.createTableViewRow({title:'Banana'}));
data.push(Ti.UI.createTableViewRow({title:'Orange'}));
data.push(Ti.UI.createTableViewRow({title:'Raspberry'}));
var tableview = Titanium.UI.createTableView({
data:data,
search:search,
searchAsChild:searchAsChild
});
win.add(tableview);
win.open();
I can confirm that in TiAlloy 1.3 and SDK 3.2.0.GA on Android 4.1.2 and Android 4.3.
+1 I have the same issue in my project
Issue reproduces Titanium SDK version 3.4.0 master, 3.1.3.GA Titanium Studio, build: 3.3.0.201407100905 Titanium Command-Line Interface CLI version 3.3.0, Android device : Motorola Moto G, Android version : 4.4.4 Note : in SDK 3.4.0 master search button is displayed.
Tested with 7.0.0.GA the issue can't be reproduced. Closing as such.