Search in sources :

Example 51 with MenuItem

use of com.actionbarsherlock.view.MenuItem in project Ushahidi_Android by ushahidi.

the class MenuBuilder method saveActionViewStates.

public void saveActionViewStates(Bundle outStates) {
    SparseArray<Parcelable> viewStates = null;
    final int itemCount = size();
    for (int i = 0; i < itemCount; i++) {
        final MenuItem item = getItem(i);
        final View v = item.getActionView();
        if (v != null && v.getId() != View.NO_ID) {
            if (viewStates == null) {
                viewStates = new SparseArray<Parcelable>();
            }
            v.saveHierarchyState(viewStates);
            if (item.isActionViewExpanded()) {
                outStates.putInt(EXPANDED_ACTION_VIEW_ID, item.getItemId());
            }
        }
        if (item.hasSubMenu()) {
            final SubMenuBuilder subMenu = (SubMenuBuilder) item.getSubMenu();
            subMenu.saveActionViewStates(outStates);
        }
    }
    if (viewStates != null) {
        outStates.putSparseParcelableArray(getActionViewStatesKey(), viewStates);
    }
}
Also used : Parcelable(android.os.Parcelable) MenuItem(com.actionbarsherlock.view.MenuItem) View(android.view.View)

Example 52 with MenuItem

use of com.actionbarsherlock.view.MenuItem in project httpclient by pixmob.

the class SubMenus method onCreateOptionsMenu.

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    SubMenu subMenu1 = menu.addSubMenu("Action Item");
    subMenu1.add("Sample");
    subMenu1.add("Menu");
    subMenu1.add("Items");
    MenuItem subMenu1Item = subMenu1.getItem();
    subMenu1Item.setIcon(R.drawable.ic_title_share_default);
    subMenu1Item.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS | MenuItem.SHOW_AS_ACTION_WITH_TEXT);
    SubMenu subMenu2 = menu.addSubMenu("Overflow Item");
    subMenu2.add("These");
    subMenu2.add("Are");
    subMenu2.add("Sample");
    subMenu2.add("Items");
    MenuItem subMenu2Item = subMenu2.getItem();
    subMenu2Item.setIcon(R.drawable.ic_compose);
    return super.onCreateOptionsMenu(menu);
}
Also used : SubMenu(com.actionbarsherlock.view.SubMenu) MenuItem(com.actionbarsherlock.view.MenuItem)

Example 53 with MenuItem

use of com.actionbarsherlock.view.MenuItem in project httpclient by pixmob.

the class MainActivity method onCreateOptionsMenu.

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    getSupportMenuInflater().inflate(R.menu.main_menu, menu);
    // set up a listener for the refresh item
    final MenuItem refresh = (MenuItem) menu.findItem(R.id.menu_refresh);
    refresh.setOnMenuItemClickListener(new OnMenuItemClickListener() {

        // on selecting show progress spinner for 1s
        public boolean onMenuItemClick(MenuItem item) {
            // item.setActionView(R.layout.progress_action);
            handler.postDelayed(new Runnable() {

                public void run() {
                    refresh.setActionView(null);
                }
            }, 1000);
            return false;
        }
    });
    return super.onCreateOptionsMenu(menu);
}
Also used : OnMenuItemClickListener(com.actionbarsherlock.view.MenuItem.OnMenuItemClickListener) MenuItem(com.actionbarsherlock.view.MenuItem)

Example 54 with MenuItem

use of com.actionbarsherlock.view.MenuItem in project httpclient by pixmob.

the class MenuWrapper method addInternal.

private SubMenu addInternal(android.view.SubMenu nativeSubMenu) {
    SubMenu subMenu = new SubMenuWrapper(nativeSubMenu);
    android.view.MenuItem nativeItem = nativeSubMenu.getItem();
    MenuItem item = subMenu.getItem();
    mNativeMap.put(nativeItem, item);
    return subMenu;
}
Also used : SubMenu(com.actionbarsherlock.view.SubMenu) MenuItem(com.actionbarsherlock.view.MenuItem)

Example 55 with MenuItem

use of com.actionbarsherlock.view.MenuItem in project httpclient by pixmob.

the class ActionBarView method onRestoreInstanceState.

@Override
public void onRestoreInstanceState(Parcelable p) {
    SavedState state = (SavedState) p;
    super.onRestoreInstanceState(state.getSuperState());
    if (state.expandedMenuItemId != 0 && mExpandedMenuPresenter != null && mOptionsMenu != null) {
        final MenuItem item = mOptionsMenu.findItem(state.expandedMenuItemId);
        if (item != null) {
            item.expandActionView();
        }
    }
    if (state.isOverflowOpen) {
        postShowOverflowMenu();
    }
}
Also used : MenuItem(com.actionbarsherlock.view.MenuItem) ActionMenuItem(com.actionbarsherlock.internal.view.menu.ActionMenuItem)

Aggregations

MenuItem (com.actionbarsherlock.view.MenuItem)93 View (android.view.View)18 ComponentName (android.content.ComponentName)16 Intent (android.content.Intent)16 PackageManager (android.content.pm.PackageManager)16 ResolveInfo (android.content.pm.ResolveInfo)16 Parcelable (android.os.Parcelable)16 SubMenu (com.actionbarsherlock.view.SubMenu)10 ActionMenuItem (com.actionbarsherlock.internal.view.menu.ActionMenuItem)8 MenuItemWrapper (com.actionbarsherlock.internal.view.menu.MenuItemWrapper)5 OnClickListener (android.view.View.OnClickListener)2 OnFocusChangeListener (android.view.View.OnFocusChangeListener)2 AutoCompleteTextView (android.widget.AutoCompleteTextView)2 ImageView (android.widget.ImageView)2 OnActionExpandListener (com.actionbarsherlock.view.MenuItem.OnActionExpandListener)2 OnMenuItemClickListener (com.actionbarsherlock.view.MenuItem.OnMenuItemClickListener)2 ShareActionProvider (com.actionbarsherlock.widget.ShareActionProvider)2 Drawable (android.graphics.drawable.Drawable)1 Editable (android.text.Editable)1 TextWatcher (android.text.TextWatcher)1