{ "id": "128814", "key": "AC-987", "fields": { "issuetype": { "id": "1", "description": "A problem which impairs or prevents the functions of the product.", "name": "Bug", "subtask": false }, "project": { "id": "12217", "key": "AC", "name": "Appcelerator - INBOX", "projectCategory": { "id": "10000", "description": "", "name": "Customer Service" } }, "resolution": { "id": "3", "description": "The problem is a duplicate of an existing issue.", "name": "Duplicate" }, "resolutiondate": "2014-04-09T05:12:52.000+0000", "created": "2014-04-08T18:04:02.000+0000", "labels": [ "3.2.2.GA", "actionbar", "android", "menuitem", "searchview" ], "versions": [], "issuelinks": [ { "id": "36514", "type": { "id": "10002", "name": "Duplicate", "inward": "is duplicated by", "outward": "duplicates" }, "outwardIssue": { "id": "114702", "key": "TIMOB-13936", "fields": { "summary": "Support Ti.UI.Android.SearchView in ActionBar without TableView.search", "status": { "description": "The issue is open and ready for the assignee to start work on it.", "name": "Open", "id": "1", "statusCategory": { "id": 2, "key": "new", "colorName": "blue-gray", "name": "To Do" } }, "priority": { "name": "Low", "id": "4" }, "issuetype": { "id": "2", "description": "A new feature of the product, which has yet to be developed.", "name": "New Feature", "subtask": false } } } } ], "assignee": { "name": "ragrawal", "key": "ragrawal", "displayName": "Ritu Agrawal", "active": true, "timeZone": "America/Los_Angeles" }, "updated": "2016-03-08T07:37:18.000+0000", "status": { "description": "The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.", "name": "Closed", "id": "6", "statusCategory": { "id": 3, "key": "done", "colorName": "green", "name": "Done" } }, "components": [ { "id": "14548", "name": "Titanium SDK & CLI", "description": "Please enter tickets related to the MobileSDK here." } ], "description": "The Android SearchView will not expand in the ActionBar if it is not attached to a TableView.\r\nEven if we call expandActionView on the menu item, it will still not open.\r\nThe root cause is apparently that onOptionsItemSelected in TiMenuSupport.java returns true.\r\nAs we see here this is bad behavior: http://developer.android.com/guide/topics/ui/actionbar.html#ActionViewCollapsing\r\n\"Because the system expands the action view when the user selects the action, you do not need to respond to the item in the onOptionsItemSelected() callback. The system still calls onOptionsItemSelected(), but if you return true (indicating you've handled the event instead), then the action view will not expand.\"\r\nExample below:\r\n{code}\r\nvar win1 = Titanium.UI.createWindow({ \r\n backgroundColor:'#fff'\r\n});\r\n\r\nvar searchView; \r\nwin1.addEventListener('open', function() {\r\n\tvar activity = win1.getActivity();\r\n\tvar actionBar = activity.actionBar || null;\r\n\tif (actionBar){\r\n\t\tsearchView = Ti.UI.Android.createSearchView({\r\n \thintText: 'Search me'\r\n \t});\r\n\t\tactivity.onCreateOptionsMenu = function(e) {\r\n\t\t\tvar menu = e.menu;\r\n\t\t\tvar searchMenuItem = menu.add({\r\n\t\t\t\ttitle: 'Search',\r\n\t\t\t\tactionView : searchView,\r\n\t\t\t\ticon: Ti.Android.R.drawable.ic_menu_search,\r\n\t\t\t\tshowAsAction: Ti.Android.SHOW_AS_ACTION_ALWAYS | Ti.Android.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW,\r\n\t\t\t\titemId: 1\r\n\t\t\t});\r\n/* this will also not work if no TableView attached, and you don't need it if there is a TableView\t\t\r\n\t\t\tsearchMenuItem.addEventListener('click', function() {\r\n\t\t\t\tsearchMenuItem.expandActionView();\r\n\t\t\t});\r\n*/\r\n\t\t};\r\n\t\tactivity.invalidateOptionsMenu();\r\n\t}\r\n \t \t\r\n/* SearchView will expand only if this is uncommented\r\n\tvar data = [];\r\n\tdata.push(Ti.UI.createTableViewRow({title:'Apple'}));\r\n\tdata.push(Ti.UI.createTableViewRow({title:'Banana'}));\r\n\tdata.push(Ti.UI.createTableViewRow({title:'Orange'}));\r\n\tdata.push(Ti.UI.createTableViewRow({title:'Raspberry'}));\r\n\r\n\tvar tableview = Titanium.UI.createTableView({\r\n \tdata:data,\r\n \tsearch:searchView,\r\n \tsearchAsChild:false\r\n\t});\r\n\r\n\twin1.add(tableview);\t\r\n*/\t \t\r\n});\r\n\r\nwin1.open();\r\n{code} ", "attachment": [], "flagged": false, "summary": "Android: SearchView in ActionBar expands only if attached to TableView", "creator": { "name": "mokesmokes", "key": "mokesmokes", "displayName": "Mark Mokryn", "active": true, "timeZone": "Asia/Jerusalem" }, "subtasks": [], "reporter": { "name": "mokesmokes", "key": "mokesmokes", "displayName": "Mark Mokryn", "active": true, "timeZone": "Asia/Jerusalem" }, "environment": "Android SDK 3.2.2, 3.3.0", "comment": { "comments": [ { "id": "300273", "author": { "name": "ragrawal", "key": "ragrawal", "displayName": "Ritu Agrawal", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Thanks for reporting this issue. This issue seems to be the duplicate of TIMOB-13936. Please let us know if you are experiencing some other issue.", "updateAuthor": { "name": "ragrawal", "key": "ragrawal", "displayName": "Ritu Agrawal", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2014-04-08T20:08:39.000+0000", "updated": "2014-04-08T20:08:39.000+0000" }, { "id": "300313", "author": { "name": "mokesmokes", "key": "mokesmokes", "displayName": "Mark Mokryn", "active": true, "timeZone": "Asia/Jerusalem" }, "body": "Yup, this is a duplicate. However, note that my example also shows an additional bug - that expandActionView() doesn't work as expected in this case.", "updateAuthor": { "name": "mokesmokes", "key": "mokesmokes", "displayName": "Mark Mokryn", "active": true, "timeZone": "Asia/Jerusalem" }, "created": "2014-04-08T23:00:36.000+0000", "updated": "2014-04-08T23:00:36.000+0000" }, { "id": "300333", "author": { "name": "ragrawal", "key": "ragrawal", "displayName": "Ritu Agrawal", "active": true, "timeZone": "America/Los_Angeles" }, "body": "[~mokesmokes] We plan to take care of expandActionView() as part TIMOB-13936 as well.", "updateAuthor": { "name": "ragrawal", "key": "ragrawal", "displayName": "Ritu Agrawal", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2014-04-09T05:12:40.000+0000", "updated": "2014-04-09T05:12:40.000+0000" } ], "maxResults": 3, "total": 3, "startAt": 0 } } }