Uploaded image for project: 'Titanium SDK/CLI'
  1. Titanium SDK/CLI
  2. TIMOB-17480

Android: Android menuItem with actionView can't handle invalidateOptionsMenu()

    Details

    • Story Points:
      8
    • Sprint:
      2014 Sprint 20 SDK

      Description

      Android menuItem with actionView can’t handle invalidateOptionsMenu() with Titanium SDK 3.3.0.GA.

      TESTING ENVIRONMENT:

      Mac OS X 10.9
      Ti CLI 3.3.0
      Titanium SDK: 3.3.0.RC, 3.3.0.GA and 3.2.3.GA
      Android emulator and device 4.4.3

      TEST CODE

      var searchView = Ti.UI.Android.createSearchView();
      var win = Ti.UI.createWindow({
      	backgroundColor : 'blue',
      	fullscreen : false,
      	activity : {
      		onCreateOptionsMenu : function(e) {
      			var menu = e.menu;
      			var menuItem = menu.add({
      				actionView : searchView,
      				icon : Ti.Android.R.drawable.ic_menu_search,
      				showAsAction : Ti.Android.SHOW_AS_ACTION_IF_ROOM | Ti.Android.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW
      			});
      			menuItem.addEventListener("click", function(e) {
      				Ti.API.info("I was clicked");
      			});
      		}
      	}
      });
       
      var data = [];
       
      data[0] = Ti.UI.createTableViewRow({
      	hasChild : true,
      	title : 'Row 1'
      });
      data[1] = Ti.UI.createTableViewRow({
      	hasDetail : true,
      	title : 'Row 2'
      });
      data[2] = Ti.UI.createTableViewRow({
      	hasCheck : true,
      	title : 'Row 3'
      });
      data[3] = Ti.UI.createTableViewRow({
      	title : 'Row 4'
      });
       
      var tableview = Titanium.UI.createTableView({
      	data : data,
      	search : searchView,
      	searchAsChild : false
      });
       
      tableview.addEventListener('click', function(e) {
      	// event data
      	win.getActivity().invalidateOptionsMenu();
      	var index = e.index;
      	var section = e.section;
      	var row = e.row;
      	var rowdata = e.rowData;
      	Titanium.UI.createAlertDialog({
      		title : 'Table View',
      		message : 'row ' + row + ' index ' + index + ' section ' + section + ' row data ' + rowdata
      	}).show();
      });
       
      win.add(tableview);
      win.open();
      

      STEPS TO TEST

      • Create a new project
      • Update app.js file with sample code
      • Run on android emulator/device
      • Click the search button, see the searchView appear and works fine.
      • Click a row, see the alert (win.getActivity().invalidateOptionsMenu(); i called)
      • Click the search button again, now the searchView is not displayed

      EXPECTED RESULT

      It’s not working as expected in Ti SDK 3.3.0 but works fine in 3.2.3.GA

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                gmathews Gary Mathews
                Reporter:
                thomas.neerup@eg.dk Thomas Neerup Andersen
                Reviewer:
                Hieu Pham
                Tester:
                Lokesh Choudhary
              • Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Backbone Issue Sync

                  • Titanium SDK/CLI <> Titanium Mobile
                    Synced with:
                    TIMOB-19060
                    Sync status:
                    ERROR
                    Last received:
                    Last sent:

                    Git Source Code