我工作的一个机器人项目,我使用的是旋转器,它使用它从数据库中填充的数组适配器。
I am working on an android project and I am using a spinner which uses an array adapter which is populated from the database.
我无法找出如何我可以从列表中以编程方式设置选定的项目。例如,如果在飞旋我有以下项目:
I can't find out how I can set the selected item programmatically from the list. For example if, in the spinner I have the following items:
类别1 第二类 类别3我将如何编程制作类2所选择的项目创建画面时。我想这可能是类似于C#IE Spinner.SelectedText =2类,但似乎并没有与此类似Android的任何方法。
How would I programmatically make Category 2 the selected item when the screen is created. I was thinking it might be similar to c# I.E Spinner.SelectedText = "Category 2" but there doesn't seem to be any method similar to this for Android.
使用下列内容:
spinnerObject.setSelection(INDEX_OF_CATEGORY2)
。