如何将数据绑定到钛合金标签中? [英] How to bind the data in to label in Titanium alloy?

查看:35
本文介绍了如何将数据绑定到钛合金标签中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何将控制器的数据绑定到xml,我的代码如下,

How can I bind data from controller to xml, My code is as follows,

查看:

  <Collection src="respondentAge"/>
    <Label id="question"></Label>

样式

".question":{
    font:{
        fontSize:18,
        fontWeight:'normal'
    },
    color:"#000",
    left:10,
    height:Ti.UI.SIZE
}

控制器

     var agenames = Alloy.Collections.respondentAge;
     agenames.on("reset", function() {
       var agenamesLength = agenames.length;
       var question; 
       for (var i = 0; i < agenamesLength; i++) {
            question = agenames.at(i).get("quesion");
         // I need to bind the 'agenames.at(i).get("quesion")' value in to label in 
       }
      });
   agenames.fetch({
       query:"SELECT * FROM respondentAge WHERE languageID ='1';"
  });

问题文本来自数据库,所以对于问题,我添加了标签,我正在从数据库中检索值,我需要将标签值设置为检索值.

The question text is coming from the database, So for for question I have added the label and I'm retrieving the value from database and I need to set the label value as retrieving value.

我该怎么做

推荐答案

我建议您使用 Label 的 setText(text) 属性.您可以在此处阅读更多相关信息:标签文档

I propose you use the setText(text) property of Label. You can read more about it here: Label docs

agenames.on("reset", function() {
    var agenamesLength = agenames.length;
    var question; 
    for (var i = 0; i < agenamesLength; i++) {
        question = agenames.at(i).get("quesion");
        $.question.setText(question);
    }
});

这篇关于如何将数据绑定到钛合金标签中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆