Details

      Description

      Add support for [Action Items](http://developer.android.com/guide/topics/ui/actionbar.html#ActionItems).
      Action items are an extension of the option menu that appear in the action bar displaying a title or a custom view.

      • Implement the new MenuItem methods for setting the action view, how the action item is displayed (ex: always, if room), and new events (ex: expanded).
      • May require some build changes to target SDK version 11 or higher. This should still remain compatible (we
        are not bumping the min. API level) and fallback to using the old style option menus.
      • Update the documentation to explain how to take advantage of this feature in Honeycomb or later devices.

      Action bar menu example

      var win = Ti.UI.createWindow({fullscreen: false, backgroundColor: 'red'});
       
      win.activity.onCreateOptionsMenu = function(e) {
        var item = e.menu.add({title: 'Expand'});
        item.showAsAction = Ti.Android.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW;
       
        var collapseActionButton = Ti.UI.createButton({
          title: 'Collapse'
        });
        collapseActionButton.addEventListener('click', function() {
          item.collapseActionView();
        });
        item.actionView = collapseActionButton;
       
        item.on('expand', function() {
          alert('Expanded menu item!');
        });
        item.on('collapse', function() {
          alert('Collapsed menu item!');
        });
        item.on('click', function() {
          alert('clicked!');
        });
      }
       
      win.open();
      

        Issue Links

          Activity

          Hide
          joshroesslein Josh Roesslein added a comment -

          To test run the example above. Be sure to test on both a pre-Honeycomb, Honeycomb, and ICS devices.

          1. Click the 'Expand' menu item. On pre-Honeycomb devices
          this will show up in the menu list which is shown via the menu button.
          On Honeycomb or later you will find this item in the overflow options menu
          on the action bar (the three vertical dots).
          2. After clicking you should see an alert saying "click". On ICS or later
          you will also see an "expanded" alert dialog. You will also notice on ICS
          the menu item has expanded into a button view saying "Collapse".
          3. On ICS click the "Collapse" action button that was expanded in step 2.
          It should collapse back into an item in the overflow menu and show an alert
          saying "collapsed'.

          Show
          joshroesslein Josh Roesslein added a comment - To test run the example above. Be sure to test on both a pre-Honeycomb, Honeycomb, and ICS devices. 1. Click the 'Expand' menu item. On pre-Honeycomb devices this will show up in the menu list which is shown via the menu button. On Honeycomb or later you will find this item in the overflow options menu on the action bar (the three vertical dots). 2. After clicking you should see an alert saying "click". On ICS or later you will also see an "expanded" alert dialog. You will also notice on ICS the menu item has expanded into a button view saying "Collapse". 3. On ICS click the "Collapse" action button that was expanded in step 2. It should collapse back into an item in the overflow menu and show an alert saying "collapsed'.
          Hide
          joshroesslein Josh Roesslein added a comment -

          Make sure you adjust the "targetSdkVersion" in your Android manifest for the application.
          This needs to be API level 11 or higher to support the action bar. Also bump it to API level 14
          to verify the expand/collapse works for menu items.

          Show
          joshroesslein Josh Roesslein added a comment - Make sure you adjust the "targetSdkVersion" in your Android manifest for the application. This needs to be API level 11 or higher to support the action bar. Also bump it to API level 14 to verify the expand/collapse works for menu items.
          Hide
          joshroesslein Josh Roesslein added a comment -

          @Neeraj

          My PR includes some documentation updates. I will be creating a ticket with Arthur
          to review the menu documentation and add some additional information.

          Show
          joshroesslein Josh Roesslein added a comment - @Neeraj My PR includes some documentation updates. I will be creating a ticket with Arthur to review the menu documentation and add some additional information.
          Hide
          andreykonn Andrey Kon added a comment -

          I'm new to titanium so maybe my question will look silly but...
          1. I wanted to ask if it's possible to remove and add new action items to action bar or to show contextual action bars.
          2. Is it possible to add custom views to the left side of action bar zone?
          3. What do I have to do to be able to test action items now?

          Show
          andreykonn Andrey Kon added a comment - I'm new to titanium so maybe my question will look silly but... 1. I wanted to ask if it's possible to remove and add new action items to action bar or to show contextual action bars. 2. Is it possible to add custom views to the left side of action bar zone? 3. What do I have to do to be able to test action items now?
          Hide
          sbhadauria Shyam Bhadauria added a comment -

          To test,run the sample app given and observed the below details.(Tested on both a pre-Honeycomb, Honeycomb, and ICS device).

          1. Click the 'Expand' menu item. On pre-Honeycomb devices
          this will show up in the menu list which is shown via the menu button.
          On Honeycomb or later you will find this item in the overflow options menu
          on the action bar (the three vertical dots).
          2. After clicking you should see an alert saying "click". On ICS or later
          you will also see an "expanded" alert dialog. You will also notice on ICS
          the menu item has expanded into a button view saying "Collapse".
          3. On ICS click the "Collapse" action button that was expanded in step 2.
          It should collapse back into an item in the overflow menu and show an alert
          saying "collapsed'.

          Devices tested
          Samsung Galaxy Nexus - Android 4.0.2
          Samung GALAXY Tab 620 - Android 3.2
          LG-P970 - Android 2.2.2

          Titanium SDK:3.0.0.v20121113170203
          Titanium  Studio:3.0.0.201211131839

          Show
          sbhadauria Shyam Bhadauria added a comment - To test,run the sample app given and observed the below details.(Tested on both a pre-Honeycomb, Honeycomb, and ICS device). 1. Click the 'Expand' menu item. On pre-Honeycomb devices this will show up in the menu list which is shown via the menu button. On Honeycomb or later you will find this item in the overflow options menu on the action bar (the three vertical dots). 2. After clicking you should see an alert saying "click". On ICS or later you will also see an "expanded" alert dialog. You will also notice on ICS the menu item has expanded into a button view saying "Collapse". 3. On ICS click the "Collapse" action button that was expanded in step 2. It should collapse back into an item in the overflow menu and show an alert saying "collapsed'. Devices tested Samsung Galaxy Nexus - Android 4.0.2 Samung GALAXY Tab 620 - Android 3.2 LG-P970 - Android 2.2.2 Titanium SDK:3.0.0.v20121113170203 Titanium  Studio:3.0.0.201211131839

            People

            • Assignee:
              joshroesslein Josh Roesslein
              Reporter:
              joshroesslein Josh Roesslein
            • Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development

                  Poker Sessions

                  This issue is currently not assigned to any Poker Session.

                    Git Source Code