[英]Adding a button to toolBar and Open a Spinner onCLick
I am new to android and I would like to know how to add a button to a toolBar and on Click of the button, I would like to open a Spinner.我是 android 新手,我想知道如何将按钮添加到工具栏,然后单击按钮,我想打开一个微调器。
Thanks谢谢
Since the spinner dropdown is not like the new LollyPop Design like Spinner:由于 Spinner 下拉菜单不像 Spinner 那样的新 LollyPop 设计:
So you need to add small code for the spinner control所以你需要为微调控件添加小代码
android:dropDownVerticalOffset="-52dp" for Kitkat and below android:dropDownVerticalOffset="-52dp" 适用于 Kitkat 及以下
android:dropDownVerticalOffset="0dp" for LollyPop android:dropDownVerticalOffset="0dp" 用于 LollyPop
<Spinner
android:id="@+id/spinner_nav"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:dropDownVerticalOffset="@dimen/dropDownVerticalOffset" />
-> For more detail with example, visit the link :- -> 有关示例的更多详细信息,请访问链接:-
http://android-pratap.blogspot.in/2015/01/spinner-in-toolbar-example-in-android.html http://android-pratap.blogspot.in/2015/01/spinner-in-toolbar-example-in-android.html
its very easy Spinner before = (Spinner) findViewById(R.id.beforeSpinner);它非常简单的 Spinner before = (Spinner) findViewById(R.id.beforeSpinner); before.performClick();
before.performClick();
it will open your spinner它会打开你的微调器
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.