入门
开发指南
- 模块
- 控件基础知识
- 控件树
- 选择器 API
- 布局
- 手势和触摸事件
- W3C APIs 兼容
- Cordova 插件支持
- EcmaScript 6,TypeScript 和 JSX
- Windows 10 支持说明
- 构建 Tabris.js App
- Tabris.js App 补丁
API 参考文档
- app
- device
- fs
- localStorage
- ui
- ActionSheet(操作列表)
- AlertDialog(对话框)
- CanvasContext
- InactivityTimer(闲置定时器)
- NativeObject
- Popup(弹出窗)
- Timer(计时器)
- WidgetCollection
控件
- Action
- ActivityIndicator
- Button
- Canvas
- CheckBox
- CollectionView
- Composite
- Drawer
- ImageView
- NavigationBar
- NavigationView
- Page
- Picker
- ProgressBar
- RadioButton
- ScrollView
- SearchAction
- Slider
- StatusBar
- Switch
- Tab
- TabFolder
- TextInput
- TextView
- ToggleButton
- Video
- WebView
- Widget
自定义控件
Picker
Extends Widget
A widget with a drop-down list of items to choose from.
Import this type with “const {Picker} = require('tabris');
”
Android | iOS |
---|---|
Properties
borderColor
Type: Color
The color of the border of the Picker. On iOS this is a rectangular border around the Picker, on Android it is a single line below the Picker.
fillColor
iOS
Type: Color
The color of the background of the Picker - applies only to iOS.
itemCount
Type: number
The number of items to display.
itemText
Type: (index: number) => string
A function that returns the string to display for a given index.
selectionIndex
Type: number
The index of the currently selected item.
textColor
Type: Color
The color of the text.
Events
borderColorChanged
Fired when the borderColor property has changed.
Event Parameters
target: this The widget the event was fired on.
value: Color The new value of borderColor.
fillColorChanged
Fired when the fillColor property has changed.
Event Parameters
target: this The widget the event was fired on.
value: Color The new value of fillColor.
itemCountChanged
Fired when the itemCount property has changed.
Event Parameters
target: this The widget the event was fired on.
value: number The new value of itemCount.
itemTextChanged
Fired when the itemText property has changed.
Event Parameters
target: this The widget the event was fired on.
value: (index: number) => string The new value of itemText.
select
Fired when an item was selected by the user.
Event Parameters
target: this The widget the event was fired on.
index: number Contains the index of the selected item.
selectionIndexChanged
Fired when the selectionIndex property has changed.
Event Parameters
target: this The widget the event was fired on.
value: number The new value of selectionIndex.
textColorChanged
Fired when the textColor property has changed.
Event Parameters
target: this The widget the event was fired on.
value: Color The new value of textColor.
Example
const {Picker, ui} = require('tabris');
// Create a picker widget to select a string from a list
const AIRPORTS = [
{
id: 'SFO',
name: 'San Francisco'
},
{
id: 'TXL',
name: 'Berlin Tegel'
},
{
id: 'FRA',
name: 'Frankfurt'
}
];
let picker = new Picker({
left: 20, top: 20, right: 20,
itemCount: AIRPORTS.length,
itemText: (index) => AIRPORTS[index].name,
selectionIndex: 1
}).appendTo(ui.contentView);
picker.on('select', ({index}) => console.log('Selected ' + AIRPORTS[index].id));
See also
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论