开发者

Can the ActionBar drop-down navigation list control be disabled?

I'm using a navigation control in the ActionBar to provide a drop-down list. I would like to disable selection of the drop down list under certain circumstances.

My layout for the closed view of the spinner adapter has a TextView wrapped in a LinearLayout. The best I've come up with is overriding getView in my spinner's adapter and making both the LinearLayout and TextView non-clickable and disabled. This has the effect of greying out the text but it can still be selected.

Edit I appreciate that I can hide开发者_开发问答 the list but this is not what I want to do. Furthermore I have returned false in the methods which check if one or all items are enabled but this does not work.

Trying to get this working with Honeycomb on a Xoom. Thanks in advance. Peter.


If you want to prevent selection of anything in the list navigation mode, call setNavigationMode(NAVIGATION_MODE_STANDARD) and get rid of it entirely until you are ready for it to be used again.

If you want to prevent selection of specific items in the list navigation mode, have your SpinnerAdapter implement areAllItemsEnabled() to return false and implement isItemEnabled() to return true or false as needed -- I haven't tried this, but in theory it should work.


You can create a custom view in your ActionBar like so:

    ViewGroup customFilterBrowse = (ViewGroup) getLayoutInflater().inflate(R.layout.component_cancellable_progressbar, null);       
    ActionBar actionBar = getActionBar();
    actionBar.setCustomView(customFilterBrowse);
    actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_HOME | ActionBar.DISPLAY_SHOW_CUSTOM);   

You can make the custom view do whatever you want (You can create a Spinner component which you disable in certain circumstances for instance).

HTH

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜