如何在appcelerator中的Picker组件上设置selecteItem

时间:2016-07-06 07:21:11

标签: javascript appcelerator-titanium appcelerator-alloy

我正在使用appcelerator studio构建应用程序。

在我的窗口中,我有一个"选择器"有这样的元素:

<Picker id="pickerUm" selectionIndicator="true" class="picker_modal" >
    <PickerColumn id="column1">
    <PickerRow title="/mL"/>
    <PickerRow title="P'"/>
    <PickerRow title="/dL"/>
    <PickerRow title="/g"/>
    </PickerColumn>
</Picker>

现在我希望通过一个事件,我可以从此Picker元素中更改所选项目。

对于例如,我希望所选元素是&#34; / dL&#34;。

我该怎么做?

1 个答案:

答案 0 :(得分:0)

var index = ["/mL","P'","/dL","/g"].indexOf(value);
if (index > -1) {
    $.pickerUm.setSelectedRow(0, index, true);
}

http://docs.appcelerator.com/platform/latest/#!/api/Titanium.UI.Picker-method-setSelectedRow