Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-17279] Android: MenuItem's actionView property is not working

GitHub Issuen/a
TypeBug
PriorityHigh
StatusClosed
ResolutionFixed
Resolution Date2014-08-18T21:55:58.000+0000
Affected Version/sn/a
Fix Version/sRelease 3.4.0
ComponentsAndroid
Labelsactionview, menuItem, module_android, qe-manualtest
ReporterManojkumar Murugesan
AssigneeSunila
Created2014-07-04T09:29:08.000+0000
Updated2014-08-18T22:23:56.000+0000

Description

  var menu = e.menu;
  var rightSymbolView = Ti.UI.createView({
	width : Ti.UI.SIZE,
	height : Ti.UI.SIZE
  });
 var rightSymbol = Alloy.createWidget("ti.ux.iconfont", "widget", {
	right : 10,
	size : 30,
        color : "#fff",
	icon : "fa-gear"
 });
 rightSymbol.setParent(rightSymbolView);
 var menuItem = menu.add({
	itemId : 0,
        actionView: rightSymbolView,
	showAsAction : Ti.Android.SHOW_AS_ACTION_ALWAYS
  });
The above code doesn't work. The below one works as expected.
var menuItem = menu.add({
	itemId : 0,
	showAsAction : Ti.Android.SHOW_AS_ACTION_ALWAYS
  });
menuItem.setActionView(rightSymbolView);

Comments

  1. Shuo Liang 2014-07-07

    Can reproduce this problem which Titanium SDK 3.3.0 RC and 3.2.3. Here is a simpler test case I wrote:
       var win = Ti.UI.createWindow({
       	fullscreen: true
       });
       
       var activity = win.activity;
       
       var rightSymbolView = Ti.UI.createView({
          	width : Ti.UI.SIZE,
          	height : Ti.UI.SIZE,
        });
        
       var label = Ti.UI.createLabel({
        	text: "test view"
       });
       rightSymbolView.add(label);
       
       activity.onCreateOptionsMenu = function(e){
         	var menu = e.menu;
         	var menuItem = menu.add({ 
           	itemId:0,
           	actionView: rightSymbolView,   // property actionView doesn't work when place here
           	showAsAction: Ti.Android.SHOW_AS_ACTION_ALWAYS
         });
         //menuItem.setActionView(rightSymbolView);     // add property actionView which works well
       };
       
       win.open();
       
  2. Sunila 2014-07-10

    Used getOrCreateView instead of peekView so that view will be created if it is not already created. https://github.com/appcelerator/titanium_mobile/pull/5900
  3. Lokesh Choudhary 2014-08-18

    Verified the fix. MenuItem's actionView property is working properly. Closing. Environment: Appc Studio : 3.4.0.201408051600 Ti SDK : 3.4.0.v20140815142514 Mac OSX : 10.8.5 Alloy : 1.4.1 CLI - 3.3.0 Code Processor: 1.1.1 Nexus 5 - android 4.4.4
  4. Lokesh Choudhary 2014-08-18

    testadded

JSON Source