How to add a spinner next to a menu in the toolbar

前端 未结 2 950
清歌不尽
清歌不尽 2021-02-05 23:34

I want my spinner to be next to my menu in the toolbar (to the left of the menu), but currently the spinner appear below the menu. Do i have to add it somehow inside the o

2条回答
  •  甜味超标
    2021-02-06 00:01

    Adding to the above answer, your activity needs to implement onItemSelectedListener, and in the onItemSelected method you do your work.

    You will also need to tell the spinner who is listening, in onCreateOptionsMenu, add this line:

    spinner.setOnItemSelectedListener(this);
    

    which will cause your spinner to call the onItemSelected method of the activity.

提交回复
热议问题