Search in sources :

Example 21 with IcsListPopupWindow

use of com.actionbarsherlock.internal.widget.IcsListPopupWindow in project AndroidTraining by mixi-inc.

the class MenuPopupHelper method tryShow.

public boolean tryShow() {
    mPopup = new IcsListPopupWindow(mContext, null, R.attr.popupMenuStyle);
    mPopup.setOnDismissListener(this);
    mPopup.setOnItemClickListener(this);
    mAdapter = new MenuAdapter(mMenu);
    mPopup.setAdapter(mAdapter);
    mPopup.setModal(true);
    View anchor = mAnchorView;
    if (anchor != null) {
        final boolean addGlobalListener = mTreeObserver == null;
        // Refresh to latest
        mTreeObserver = anchor.getViewTreeObserver();
        if (addGlobalListener)
            mTreeObserver.addOnGlobalLayoutListener(this);
        ((View_HasStateListenerSupport) anchor).addOnAttachStateChangeListener(this);
        mPopup.setAnchorView(anchor);
    } else {
        return false;
    }
    mPopup.setContentWidth(Math.min(measureContentWidth(mAdapter), mPopupMaxWidth));
    mPopup.setInputMethodMode(PopupWindow.INPUT_METHOD_NOT_NEEDED);
    mPopup.show();
    mPopup.getListView().setOnKeyListener(this);
    return true;
}
Also used : View_HasStateListenerSupport(com.actionbarsherlock.internal.view.View_HasStateListenerSupport) View(android.view.View) AdapterView(android.widget.AdapterView) IcsListPopupWindow(com.actionbarsherlock.internal.widget.IcsListPopupWindow)

Aggregations

IcsListPopupWindow (com.actionbarsherlock.internal.widget.IcsListPopupWindow)21 View (android.view.View)7 AdapterView (android.widget.AdapterView)7 View_HasStateListenerSupport (com.actionbarsherlock.internal.view.View_HasStateListenerSupport)7 ViewTreeObserver (android.view.ViewTreeObserver)3