[英]Change a Spinner programmatically in Android
Im trying to add a Spinner in my app configuration Activity. 我试图在我的应用程序配置活动中添加微调框。 The spinner offers an option and save it persistently with SharedPreferences.
微调器提供一个选项,并使用SharedPreferences永久保存它。
How can I set the spinner in a position programmatically (for init in the activity creation) Thanks in advance 我如何以编程方式将微调器设置在某个位置(用于在活动创建中进行初始化),谢谢
To programatically set the spinner position you should use the method: 要以编程方式设置微调器位置,应使用以下方法:
setSelection(position_to_select)
From the Spinner class (Actually the method's implementation is from the android.widget.AbsSpinner but it is inherited by Spinner class. 从Spinner类(实际上,该方法的实现来自android.widget.AbsSpinner,但它是Spinner类继承的。
You can check the API documentation for it here: http://developer.android.com/reference/android/widget/Spinner.html 您可以在此处查看API文档: http : //developer.android.com/reference/android/widget/Spinner.html
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.