【问题标题】:Table view Section Header Title in titanium表视图节标题标题钛
【发布时间】:2014-11-23 10:31:31
【问题描述】:

我在我的 Titanium 项目中为 tableview 创建了一个自定义 Header 视图,

 var headerView = Ti.UI.createView({ height: 40,backgroundColor:'#00928F' });
    var headerLabel = Ti.UI.createLabel({ text: array_interview_dates[i],color:'white' });
    headerView.add(headerLabel);    
    headerViewArray.push(headerView);

现在当我想在选择行时获取节标题标题

table.addEventListener('click', function action_table(e){
 var header_title=e.section.headerTitle;
}

我得到空值,我想得到 section_HeaderTitle

【问题讨论】:

    标签: titanium tableview


    【解决方案1】:

    在您的代码中没有节的定义。

    您应该在节定义中定义属性 headerTitle 以使其可用,如本例所示(改编自 Titanium documentation):

    Ti.UI.backgroundColor = 'white';
    var win = Ti.UI.createWindow();
    
    var sectionFruit = Ti.UI.createTableViewSection({ headerTitle: 'Fruit' });
    sectionFruit.add(Ti.UI.createTableViewRow({ title: 'Apples' }));
    sectionFruit.add(Ti.UI.createTableViewRow({ title: 'Bananas' }));
    
    var sectionVeg = Ti.UI.createTableViewSection({ headerTitle: 'Vegetables' });
    sectionVeg.add(Ti.UI.createTableViewRow({ title: 'Carrots' }));
    sectionVeg.add(Ti.UI.createTableViewRow({ title: 'Potatoes' }));
    
    var table = Ti.UI.createTableView({
        data: [sectionFruit, sectionVeg]
    });
    
    table.addEventListener('click', function(e){
        Ti.API.info(e.rowData.title);
        Ti.API.info(e.section.headerTitle);
    });
    
    win.add(table);
    win.open();
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-05-18
      • 1970-01-01
      • 2023-03-09
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多