Quantcast
Channel: Appcelerator Developer Center Q&A Unanswered Questions 20
Viewing all articles
Browse latest Browse all 8068

Android MenuItem actionView doesn't work

$
0
0

Hi, I'm currently having a problem with actionView for a menu item on android: this will never shown into actionbar. I'm on Mac OSX Yosemite and I'm testing it on HTC One M8 (Android 5.1). I'm using Titanium SDK 3.5.1 and the last version of Titanium Studio.

This 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,
 
        });
 
    //This is the test 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");
        });
    };
}
The problem is on menu_notification_item. How I can solve this? Thank you.

Viewing all articles
Browse latest Browse all 8068

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>