开发者

How do i add a spinner to the title bar of an activity?

开发者 https://www.devze.com 2023-03-30 23:57 出处:网络
I tried to set a custom title bar includes spinner object but everytime it gave me that exception called \"You cannot combine custom titles with other title features\". I searched to find a solution s

I tried to set a custom title bar includes spinner object but everytime it gave me that exception called "You cannot combine custom titles with other title features". I searched to find a solution site by site and also i did everything correctly as described on the net but the exception never disappeared. There is a very si开发者_如何学Golly question left on my mind that it can be related to android 3.0? I am developing with version 3.0 (honeycomb). I don't know what should i do.

Thank you adamp, i made it with your guidance. here is a simple action bar with spinner example. May help to someone who is facing the similar issue.

    super.onCreate(savedInstanceState);
    setContentView(R.layout.screens);
    ActionBar bar = getActionBar();
    bar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);
    bar.setListNavigationCallbacks(new SpinnerAdapter(this, android.R.layout.simple_dropdown_item_1line, EczaneMgr.getInstance(this).getEczaneListAsSpinner()),
            new OnNavigationListener() {
          @Override
          public boolean onNavigationItemSelected(int position, long itemId) {
            Log.e("item position",String.valueOf(position));
            return true;
            //do whatever want to do...
          }
        }
    );


The Action Bar used on Android 3.0+ is considered a title feature, and your Activity will get one by default if you are using one of the Holo themes. (Theme.Holo, Theme.Holo.Light, etc.) Theme.Holo is the default for apps with targetSdkVersion="11" or above. The older "custom title bar" feature cannot be combined with the action bar, but you can use the action bar to do this instead.

Use the action bar's list navigation mode, set using ActionBar#setNavigationMode and ActionBar#setListNavigationCallbacks to specify an adapter that will supply spinner views.

0

精彩评论

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