javascript - TITANIUM 如何获取 ListView 的值?

标签 javascript android listview titanium

希望获取listview子文本,找不到获取方式。 我的 ListView 构建代码:

var myTemplate = {
    childTemplates: [
            {                            // Title 
            type: 'Ti.UI.Label',     // Use a label for the title 
            bindId: 'info',          // Maps to a custom info property of the item data
            properties: {            // Sets the label properties
                color: 'black',
                font: { fontFamily:'Arial', fontSize: '20dp', fontWeight:'bold' },
                left: 0, top: 0,
            }
        },
        {                            // Subtitle
            type: 'Ti.UI.Label',     // Use a label for the subtitle
            bindId: 'es_info',       // Maps to a custom es_info property of the item data
            properties: {            // Sets the label properties
                color: 'black',
                font: { fontFamily:'Arial', fontSize: '20dp' },
                right: 0, top: '0dp',
                accessoryType: Ti.UI.LIST_ACCESSORY_TYPE_NONE
            }
        }
    ]
};

var table = Ti.UI.createListView({
// Maps myTemplate dictionary to 'template' string
    templates: { 'template': myTemplate },
    bottom:'50dp',
    editing : true,
    defaultItemTemplate: 'template'
});
var sections = [];


ProcuctRS = db.execute('select uniqnumber,barcode,scantimes,quantity from product where batchno=?',Titanium.App.Properties.getString("batchnumber"));
while (ProcuctRS.isValidRow())  
    {  
        var BNO = ProcuctRS.fieldByName('barcode');  
        var SCTIME = ProcuctRS.fieldByName('scantimes');  
        var QUANTITY = ProcuctRS.fieldByName('quantity'); 

        var PDSection = Ti.UI.createListSection({ headerTitle: BNO});
        var PDDataSet = [
                            { es_info: {text: 'Scan times :' + SCTIME}, info: {text: 'Quantity :'+ QUANTITY}},
                        ];
        PDSection.setItems(PDDataSet);
        sections.push(PDSection);
        ProcuctRS.next(); 
    }  
ProcuctRS.close();
table.sections = sections;
self.add(table);

现在我想更改信息和 es_info 文本,我尝试了不同的方法, 例如:

    table.addEventListener('itemclick', function(e){
            var item = e.section.getItemAt(e.itemIndex);
            e.section.es_info.color = 'orange';
            e.section.updateItemAt(e.itemIndex, item); 
};

但它不起作用。 我能做什么?帮助!谢谢你

最佳答案

我不知道它是否相关(或者只是复制粘贴错误)但是你在事件监听器的末尾错过了')'

 table.addEventListener('itemclick', function(e){
        var item = e.section.getItemAt(e.itemIndex);
        e.section.es_info.color = 'orange';
        e.section.updateItemAt(e.itemIndex, item); 
 });

关于javascript - TITANIUM 如何获取 ListView 的值?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20361507/

相关文章:

javascript - 在图像上创建网格覆盖

android - 如何在 root 设备上将我的应用程序设置为默认值

android - 如何将 ListView 放入 fragment 中

javascript - Angular 翻译 HTML 标签

javascript - 使用 ng-repeat 将数组中的数据获取到数据列表中

javascript - 等于 ko.observable() 的变量的默认值是多少?

android - 我的 Android 应用程序能否检测到它是否是从 Eclipse 启动的?

android - 使用唤醒锁(最小化电池使用)处理传入短信的正确方法

python - Django: ListView 。我在哪里可以声明我想要在模板上使用的变量?

java - 从 ListView 获取字符串时类转换异常