在Android的编程方式更改微调 [英] Change a Spinner programmatically in Android

查看:134
本文介绍了在Android的编程方式更改微调的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试着在我的应用程序配置的活动添加一个微调。微调提供了一个选项,并使用共享preferences永久保存。

Im trying to add a Spinner in my app configuration Activity. The spinner offers an option and save it persistently with SharedPreferences.

如何设置在一个位置微调编程(在活动创造INIT)
在此先感谢

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)

从微调类(其实该方法的实现是从android.widget.AbsSpinner但它是由微调类继承。

From the Spinner class (Actually the method's implementation is from the android.widget.AbsSpinner but it is inherited by Spinner class.

您可以在这里检查它的API文档:
http://developer.android.com/reference/android/widget/Spinner.html

You can check the API documentation for it here: http://developer.android.com/reference/android/widget/Spinner.html

这篇关于在Android的编程方式更改微调的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆