JavaScript
TI

TItaniumで、TextFiledに文字を入力し、背景色を変える。

More than 1 year has passed since last update.
var win1 = Ti.UI.createWindow({
    backgroundColor:'#ff8080'
});

var textFiled = Ti.UI.createTextField({
    keyboardType: Titanium.UI.KEYBOARD_DEFAULT,
    borderStyle:Titanium.UI.INPUT_BORDERSTYLE_ROUNDED,
    autocapitalization:false,
    width:'200dp',
    top:'25%'
});
win1.add(textFiled);

textFiled.addEventListener('blur',function(e){
    if(textFiled.value === '赤色') win1.setBackgroundColor('#ff0000');
    else if(textFiled.value === '黄色') win1.setBackgroundColor('#ffff00');
    else if(textFiled.value === '青色') win1.setBackgroundColor('#0000ff');
    else win1.setBackgroundColor('#fff');
});

win1.open();