使用Titanium排列数据

Lining up data with Titanium

本文关键字:数据 排列 Titanium 使用      更新时间:2023-12-23

我需要在列表视图的底部显示5行摘要数据。我创建了一个页脚并尝试:

label1.text+num.toString()
footer.add(label1) // repeat for 5 labels
listview.add(footer)

五个标签是固定长度的绳子,但没有通过,仍然没有正确排列。我读过一些关于表视图的帖子,这是我需要的吗?

编辑:单空间字体工作,但仍然。。。

我认为您的第一条语句中有一个拼写错误:

label1.text+num.toString()

我认为应该是:

label1.text = num.toString();

这可以解释你没有看到任何标签。

如果不是解决方案,并且标签的text属性设置为语句之前的任何内容,请提供更多代码以帮助您。

为了解决项目正确排列的问题,我所做的是创建一个视图。然后用顶部/左侧定位向其中添加单个元素。

var summary_win2 = Titanium.UI.createView({
    height: '50%',
    top: 0
});

 // summary_win2.add(summary_win2_label0);
 // I did the above code for all the elements below
var summary_win2_label0 = Titanium.UI.createLabel({
    text: "Data 1",
    font:{fontSize:24,fontWeight:'normal'},
    color:'#000',
    top: 0,
    left:3 
});
var summary_win2_data0 = Titanium.UI.createLabel({
    text: "0",
    font:{fontSize:24,fontWeight:'normal'},
    color:'#000',
    top: 0,
    left:120 
});
var summary_win2_label1 = Titanium.UI.createLabel({
    text: "Data 2",
    font:{fontSize:24,fontWeight:'normal'},
    color:'#000',
    top: 25,
    left:3 
});
var summary_win2_data1 = Titanium.UI.createLabel({
    text: "0",
    font:{fontSize:24,fontWeight:'normal'},
    color:'#000',
    top: 25,
    left:120 
});

var summary_win2_label2 = Titanium.UI.createLabel({
    text:"Data 3",
    font:{fontSize:24,fontWeight:'normal'},
    color:'#000',
    top: 50,
    left:3
});
var summary_win2_data2 = Titanium.UI.createLabel({
    text: "0",
    font:{fontSize:24,fontWeight:'normal'},
    color:'#000',
    top: 50,
    left:120 
});

var summary_win2_label3 = Titanium.UI.createLabel({
    text: "Data 4",
    font:{fontSize:24,fontWeight:'normal'},
    color:'#000',
    top: 75,
    left:3
});
var summary_win2_data3 = Titanium.UI.createLabel({
    text: "0",
    font:{fontSize:24,fontWeight:'normal'},
    color:'#000',
    top: 75,
    left:120
});
var buttonClear_win2 = Titanium.UI.createButton({
    title: 'Clear',
     top: 110, 
    width: 100,
    height: 50,
    left: 0
});