开发者

Change a Spinner programmatically in Android

开发者 https://www.devze.com 2023-03-24 16:37 出处:网络
Im trying to add a Spinner in my app configuration Activity. The spinner offers an option and save 开发者_JS百科it persistently with SharedPreferences.

Im trying to add a Spinner in my app configuration Activity. The spinner offers an option and save 开发者_JS百科it persistently with 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.

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

0

精彩评论

暂无评论...
验证码 换一张
取 消