How can I add my spinner to the ActionBar?

前端 未结 1 453
余生分开走
余生分开走 2021-01-11 16:27

I\'m trying to get my spinner working as the Action Bar Drop Down List item, but I cant seem to implement it at all, there aren\'t many tutorials for this after searching th

相关标签:
1条回答
  • 2021-01-11 17:04

    Step #1: Get rid of your Spinner.

    Step #2: Get rid of your OnItemSelectedListener.

    Step #3: Provide your ArrayAdapter as the first parameter to setListNavigationCallbacks().

    Step #4: Provide an implementation of ActionBar.OnNavigationListener as the second parameter to setListNavigationCallbacks().

    Step #5: In the onNavigationItemSelected() callback method in your ActionBar.OnNavigationListener, do whatever it is you want to do based upon the change in the state of the navigation (e.g., execute a FragmentTransaction).

    Step #6: Redesign your application to not start an activity based on this navigation selection, as you are attempting above. Either start the activity from a toolbar button or options menu item, or use fragments to replace (part of) the UI on the existing activity. List and tabs navigation in the action bar is not for launching activities.

    0 讨论(0)
提交回复
热议问题