Spinner as MenuItem not initialized by findViewById

你。 提交于 2019-12-06 00:26:52

findViewbyId will try to find the id from the contentView of the activity.

Instead of

spinnerNumber= (Spinner)findViewById(R.id.numberSpinner);

Try this

MenuItem item = menu.findItem(R.id.numberSpinner);
spinnerNumber = (Spinner)item.getActionView()
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!