[AC-1112] Android MenuItem actionView doesn't work
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | n/a |
Status | Closed |
Resolution | Invalid |
Resolution Date | 2015-03-30T06:55:13.000+0000 |
Affected Version/s | n/a |
Fix Version/s | n/a |
Components | Titanium SDK & CLI |
Labels | actionView, actionview, android, titanium |
Reporter | Andrea Vitale |
Assignee | Radamantis Torres-Lechuga |
Created | 2015-03-28T13:40:03.000+0000 |
Updated | 2016-03-08T07:37:28.000+0000 |
Description
I'm currently having a problem with actionView for a menu item on android: never shown into actionbar.
Here is my code:
//On window open
if (this.getActivity()) {
this.getActivity().invalidateOptionsMenu();
this.getActivity().onCreateOptionsMenu = createAndroidOptionsMenu();
var action_bar = this.getActivity().getActionBar();
if (action_bar) {
action_bar.setTitle('MyAppTitle');
}
}
function createAndroidOptionsMenu(event) {
return function(event) {
var menu = event.menu;
var search = Ti.UI.Android.createSearchView({ hintText: 'Search..' ,id: "FlingerSearchBar"});
search.addEventListener("submit", function(event){
console.log(search.value);
});
var menu_search_item = menu.add({
title: "Ricerca fling",
actionView: search,
icon: Ti.Android.R.drawable.ic_menu_search,
showAsAction: Ti.Android.SHOW_AS_ACTION_IF_ROOM | Ti.Android.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW,
});
var action_view = Ti.UI.createView({
width: 20,
height: 20,
backgroundColor: "white"
});
var menu_notification_item = menu.add({
title: "Notifiche",
showAsAction: Titanium.Android.SHOW_AS_ACTION_ALWAYS,
});
//HERE'S THE PROBLEM!!! THE ACTIONVIEW WILL NEVER SHOWN
menu_notification_item.setActionView(action_view);
var menu_flingers_item = menu.add({
title: "Flingers",
icon: "images/ic_action_friends.png",
showAsAction: Ti.Android.SHOW_AS_ACTION_IF_ROOM | Ti.Android.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW
});
menu_flingers_item.addEventListener("click", $.DrawerWindow.toggleRightWindow);
menu_notification_item.addEventListener("click", function() {
Ti.API.info("CLICK");
});
};
}
Mark it as closed, it was my fault. Sorry.