titanium开发教程-02-05创建单行的选择器
2012-03-17 00:30
260 查看
![](http://images.cnblogs.com/cnblogs_com/xiaozhanga4/201203/201203170029421532.jpg)
var win = Titanium.UI.createWindow({ title:"Creating a Single-Column Picker", backgroundColor:"#FFF", exitOnClose:true }); //A single column picker var picker = Titanium.UI.createPicker({ bottom:0, selectionIndicator:true //This is the blue translucent window (on iOS) that indicates the current selection }); //A picker requires an array of pickerRow objects var data = []; //Create an array; next, fill with pickerRow objects data[0] = Titanium.UI.createPickerRow({title:"Backpack Cal", val:"Hiking"}); //Create a new picker row with the minimum of a title property (text that is displayed to the user; the other properties are custom and drawn up in the event listener) data[1] = Titanium.UI.createPickerRow({title:"California Calm", val:"Resting"}); data[2] = Titanium.UI.createPickerRow({title:"California Hotsprings", val:"Bathing"}); data[3] = Titanium.UI.createPickerRow({title:"Cycle California", val:"Biking"}); //Now, we need add the pickerRow objects in the data array to the picker picker.add(data); //This label contains text that will change with each picker change var results = Titanium.UI.createLabel({ text:"Select from the picker below", height:40, width:"auto", top:20 }); //When using a picker, listen for the "change" event picker.addEventListener("change", function(e){ results.text = e.row.title + ": " + e.row.val; //Pull the title and val properties from the selected pickerRow object (accessed via e.row) }); win.add(picker); win.add(results); win.open();
相关文章推荐
- titanium开发教程-02-06创建多行的选择器
- titanium开发教程-02-07创建时间选择器
- titanium开发教程-02-10创建的文本字段与嵌入的按钮
- titanium开发教程-02-02创建按钮
- titanium开发教程-02-04创建开关
- titanium开发教程-02-03创建滑竿
- titanium开发教程-02-08创建文本域和多行文本输入区
- titanium开发教程-05-01创建一个地图并且设置坐标
- titanium开发教程-04-05从rows打开window
- titanium开发教程-02-11增加交互性,在任何view
- titanium开发教程-02-12回顾周期的创作
- titanium开发教程-01-01创建你第一个程序
- titanium开发教程-01-02检测平台
- titanium开发教程-04-02增加一个搜索栏
- titanium开发教程-01-05使用image view
- titanium开发教程-04-03创建一个简单的table
- titanium开发教程-02-01监听事件
- titanium开发教程-03-02自定义tab group
- titanium开发教程-02-09配置文本域和文本区键盘类型
- titanium开发教程-04-04创建自定义的table rows