您的位置:首页 > 其它

titanium开发教程-02-09配置文本域和文本区键盘类型

2012-03-17 00:55 417 查看




 

var win = Titanium.UI.createWindow({
title:"Configuring text field and text area keyboard types",
backgroundColor:"#FFF",
exitOnClose:true
});

var textField = Titanium.UI.createTextField({
top:75,
height:60,
width:300,
borderStyle:Titanium.UI.INPUT_BORDERSTYLE_ROUNDED,
hintText:"This field only allows numbers",
keyboardType:Titanium.UI.KEYBOARD_DECIMAL_PAD //This property sets the keyboard type to appear
//Experiment by changing the above line with the values below
/* Keyboard types are:
* Titanium.UI.KEYBOARD_DEFAULT - Default keyboard
* Titanium.UI.KEYBOARD_ASCII 	- ASCII keyboard
* Titanium.UI.KEYBOARD_NUMBERS_PUNCTUATION; - Numbers and punctuation
* Titanium.UI.KEYBOARD_URL - Web keyboard
* Titanium.UI.KEYBOARD_NUMBER_PAD - Number pad
* Titanium.UI.KEYBOARD_PHONE_PAD - Phone keypad
* Titanium.UI.KEYBOARD_NAMEPHONE_PAD - Alpha + phone pad
* Titanium.UI.KEYBOARD_EMAIL - Email phone pad
* Titanium.UI.KEYBOARD_DECIMAL_PAD - Number and decimal pad
*/
});

//Add an event listener to the window that allows for the keyboard or input keys to be hidden if the user taps outside a text field
//Note: each text field to be blurred would be added below
win.addEventListener("click", function(e){
textField.blur(); // Cause the text field to lose focus, thereby hiding the keyboard (if visible)
});

win.add(textField);

win.open();
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: