Android OPEN spinner with single button click

筅森魡賤 提交于 2020-01-01 04:05:09

问题


I have implemented button which clicks and opens dialog with spinner inside as described here

However this is two clicks. One to open dialog and one to open spinner. I want the spinner to open with a single click of the button? How can this be done?

Is there anyway to just open spinner from button click w/o going to dialog. If not how can I open dialog view and have the spinner open at same time.


回答1:


Just put this in your button.onClick

spinner.performClick();



回答2:


Define a spinner in your activity with 0 height and 0 width in your xml, then the onItemSelected will work



来源:https://stackoverflow.com/questions/5126141/android-open-spinner-with-single-button-click

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!