Titanium JIRA Archive
Appcelerator Community (AC)

[AC-1112] Android MenuItem actionView doesn't work

GitHub Issuen/a
TypeBug
Priorityn/a
StatusClosed
ResolutionInvalid
Resolution Date2015-03-30T06:55:13.000+0000
Affected Version/sn/a
Fix Version/sn/a
ComponentsTitanium SDK & CLI
LabelsactionView, actionview, android, titanium
ReporterAndrea Vitale
AssigneeRadamantis Torres-Lechuga
Created2015-03-28T13:40:03.000+0000
Updated2016-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");
        });
    };
}

Comments

  1. Andrea Vitale 2015-03-28

    Mark it as closed, it was my fault. Sorry.

JSON Source