如何解决Titanium TableView显示问题?
我有钛制的表格视图。我在 3 个不同的行中显示了 12 个标签。当我第一次使用它时,它正确显示了所有 3 行的内容。
每当我从表视图返回到其他视图并再次访问同一个表视图时,我看不到表视图内容,只能看到空白行。
任何人都可以帮我解决问题到底是什么以及为什么我在加载表格视图时无法再次看到内容(第二次)。
我在下面添加了整个代码片段:
var win = Titanium.UI.currentWindow;
var atmData =[];
var tableView;
var titledata =[
'Member No:',
'A/C Type:',
'A/C Desc:',
'A/C: ',
'State:',
'Zip:',
'Surcharge\nAmount:',
];
var Value =[
'28956',
'Savings',
'85416',
'025489',
'California',
'38847',
'Free',
];
var FirstLabel =[];
var FirstText = [];
var SecondLabel =[];
var SecondText = [];
var ThirdLabel =[];
var ThirdText = [];
var FourthLabel =[];
var FourthText = [];
var FifthLabel =[];
var FifthText = [];
var SixthLabel =[];
var SixthText = [];
for (var i=0; i < 3; i++){
var row = Ti.UI.createTableViewRow();
//row.backgroundColor = '#576996';
row.selectedBackgroundColor = '#385292';
//row.height = 170;
FirstLabel = Titanium.UI.createLabel({
text:'Member No:',
color:'black',
//textAlign:'left',
//font:{fontSize:13,fontWeight:'bold'},
font:{fontSize:13,
fontFamily:'Helvetica Neue'
},
width: 110,
left:10,
height:20,
top :0
});
FirstText = Titanium.UI.createLabel({
text:'35687',
color:'black',
//textAlign:'left',
//font:{fontSize:13,fontWeight:'bold'},
font:{
fontSize:13,
fontFamily:'Helvetica Neue'
},
width:'auto',
height:20,
left:120,
top :0
});
SecondLabel = Titanium.UI.createLabel({
text:'A/C Type:',
color:'black',
//textAlign:'left',
//font:{fontSize:13,fontWeight:'bold'},
font:{fontSize:13,
fontFamily:'Helvetica Neue'
},
width: 100,
height:20,
left:10,
top :25
});
SecondText = Titanium.UI.createLabel({
text:'Savings',
color:'black',
//textAlign:'left',
//font:{fontSize:13,fontWeight:'bold'},
font:{
fontSize:13,
fontFamily:'Helvetica Neue'
},
width:'auto',
height:20,
left:120,
top :25
});
ThirdLabel = Titanium.UI.createLabel({
text:'A/C Desc:',
color:'black',
//textAlign:'left',
//font:{fontSize:13,fontWeight:'bold'},
font:{fontSize:13,
fontFamily:'Helvetica Neue'
},
width: 100,
height:20,
left:10,
top :50
});
ThirdText= Titanium.UI.createLabel({
text:'65565616',
color:'black',
//textAlign:'left',
//font:{fontSize:13,fontWeight:'bold'},
font:{
fontSize:13,
fontFamily:'Helvetica Neue'
},
width:'auto',
height:20,
left:120,
top :50
});
FourthLabel = Titanium.UI.createLabel({
text:'A/C:',
color:'black',
//textAlign:'left',
//font:{fontSize:13,fontWeight:'bold'},
font:{fontSize:13,
fontFamily:'Helvetica Neue'
},
width: 100,
height:20,
left:10,
top :75
});
FourthText= Titanium.UI.createLabel({
text:'861556.00',
color:'black',
//textAlign:'left',
//font:{fontSize:13,fontWeight:'bold'},
font:{
fontSize:13,
fontFamily:'Helvetica Neue'
},
width:'auto',
height:20,
left:120,
top :75
});
FifthLabel = Titanium.UI.createLabel({
text:'ZIP :',
color:'black',
//textAlign:'left',
//font:{fontSize:13,fontWeight:'bold'},
font:{fontSize:13,
fontFamily:'Helvetica Neue'
},
width: 100,
height:20,
left:10,
top :100
});
FifthText= Titanium.UI.createLabel({
text:'388546',
color:'black',
//textAlign:'left',
//font:{fontSize:13,fontWeight:'bold'},
font:{
fontSize:13,
fontFamily:'Helvetica Neue'
},
width:'auto',
height:20,
left:120,
top :100
});
SixthLabel = Titanium.UI.createLabel({
text:'Surcharge\nAmount:',
color:'black',
//textAlign:'left',
//font:{fontSize:13,fontWeight:'bold'},
font:{fontSize:13,
fontFamily:'Helvetica Neue'
},
width: 100,
height:50,
left:10,
top :125
});
SixthText= Titanium.UI.createLabel({
text:'Free',
color:'black',
//textAlign:'left',
//font:{fontSize:13,fontWeight:'bold'},
font:{
fontSize:12,
fontFamily:'Helvetica Neue'
},
width:'auto',
height:50,
left:120,
top :125
});
row.className = 'header';
row.add(FirstLabel);
row.add(FirstText);
row.add(SecondLabel);
row.add(SecondText);
row.add(ThirdLabel);
row.add(ThirdText);
row.add(FourthLabel);
row.add(FourthText);
row.add(FifthLabel);
row.add(FifthText);
row.add(SixthLabel);
row.add(SixthText);
atmData.push(row);
backgroundColor:'transparent'
};
var tableview = Titanium.UI.createTableView({
data:atmData,
rowHeight:170,
});
win.add(tableview);
I have tableview in titanium.I have displayed 12 labels in 3 different rows.When i am using it first time it is showing all of the 3 rows properly with content.
Whenever i am coming back from the tableview to other view and again i am going to access the same tableview, i can not see tableview content, i can only see blank rows.
can anybody help me out , what exactly the problem is and why am i not able to see content again(2nd time) when tableview loads.
I have added whole code snippet below :
var win = Titanium.UI.currentWindow;
var atmData =[];
var tableView;
var titledata =[
'Member No:',
'A/C Type:',
'A/C Desc:',
'A/C: ',
'State:',
'Zip:',
'Surcharge\nAmount:',
];
var Value =[
'28956',
'Savings',
'85416',
'025489',
'California',
'38847',
'Free',
];
var FirstLabel =[];
var FirstText = [];
var SecondLabel =[];
var SecondText = [];
var ThirdLabel =[];
var ThirdText = [];
var FourthLabel =[];
var FourthText = [];
var FifthLabel =[];
var FifthText = [];
var SixthLabel =[];
var SixthText = [];
for (var i=0; i < 3; i++){
var row = Ti.UI.createTableViewRow();
//row.backgroundColor = '#576996';
row.selectedBackgroundColor = '#385292';
//row.height = 170;
FirstLabel = Titanium.UI.createLabel({
text:'Member No:',
color:'black',
//textAlign:'left',
//font:{fontSize:13,fontWeight:'bold'},
font:{fontSize:13,
fontFamily:'Helvetica Neue'
},
width: 110,
left:10,
height:20,
top :0
});
FirstText = Titanium.UI.createLabel({
text:'35687',
color:'black',
//textAlign:'left',
//font:{fontSize:13,fontWeight:'bold'},
font:{
fontSize:13,
fontFamily:'Helvetica Neue'
},
width:'auto',
height:20,
left:120,
top :0
});
SecondLabel = Titanium.UI.createLabel({
text:'A/C Type:',
color:'black',
//textAlign:'left',
//font:{fontSize:13,fontWeight:'bold'},
font:{fontSize:13,
fontFamily:'Helvetica Neue'
},
width: 100,
height:20,
left:10,
top :25
});
SecondText = Titanium.UI.createLabel({
text:'Savings',
color:'black',
//textAlign:'left',
//font:{fontSize:13,fontWeight:'bold'},
font:{
fontSize:13,
fontFamily:'Helvetica Neue'
},
width:'auto',
height:20,
left:120,
top :25
});
ThirdLabel = Titanium.UI.createLabel({
text:'A/C Desc:',
color:'black',
//textAlign:'left',
//font:{fontSize:13,fontWeight:'bold'},
font:{fontSize:13,
fontFamily:'Helvetica Neue'
},
width: 100,
height:20,
left:10,
top :50
});
ThirdText= Titanium.UI.createLabel({
text:'65565616',
color:'black',
//textAlign:'left',
//font:{fontSize:13,fontWeight:'bold'},
font:{
fontSize:13,
fontFamily:'Helvetica Neue'
},
width:'auto',
height:20,
left:120,
top :50
});
FourthLabel = Titanium.UI.createLabel({
text:'A/C:',
color:'black',
//textAlign:'left',
//font:{fontSize:13,fontWeight:'bold'},
font:{fontSize:13,
fontFamily:'Helvetica Neue'
},
width: 100,
height:20,
left:10,
top :75
});
FourthText= Titanium.UI.createLabel({
text:'861556.00',
color:'black',
//textAlign:'left',
//font:{fontSize:13,fontWeight:'bold'},
font:{
fontSize:13,
fontFamily:'Helvetica Neue'
},
width:'auto',
height:20,
left:120,
top :75
});
FifthLabel = Titanium.UI.createLabel({
text:'ZIP :',
color:'black',
//textAlign:'left',
//font:{fontSize:13,fontWeight:'bold'},
font:{fontSize:13,
fontFamily:'Helvetica Neue'
},
width: 100,
height:20,
left:10,
top :100
});
FifthText= Titanium.UI.createLabel({
text:'388546',
color:'black',
//textAlign:'left',
//font:{fontSize:13,fontWeight:'bold'},
font:{
fontSize:13,
fontFamily:'Helvetica Neue'
},
width:'auto',
height:20,
left:120,
top :100
});
SixthLabel = Titanium.UI.createLabel({
text:'Surcharge\nAmount:',
color:'black',
//textAlign:'left',
//font:{fontSize:13,fontWeight:'bold'},
font:{fontSize:13,
fontFamily:'Helvetica Neue'
},
width: 100,
height:50,
left:10,
top :125
});
SixthText= Titanium.UI.createLabel({
text:'Free',
color:'black',
//textAlign:'left',
//font:{fontSize:13,fontWeight:'bold'},
font:{
fontSize:12,
fontFamily:'Helvetica Neue'
},
width:'auto',
height:50,
left:120,
top :125
});
row.className = 'header';
row.add(FirstLabel);
row.add(FirstText);
row.add(SecondLabel);
row.add(SecondText);
row.add(ThirdLabel);
row.add(ThirdText);
row.add(FourthLabel);
row.add(FourthText);
row.add(FifthLabel);
row.add(FifthText);
row.add(SixthLabel);
row.add(SixthText);
atmData.push(row);
backgroundColor:'transparent'
};
var tableview = Titanium.UI.createTableView({
data:atmData,
rowHeight:170,
});
win.add(tableview);
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我遇到了一个非常类似的问题,我可以通过将
tableview.setData(tableview.data);
放入导致表格看起来奇怪的任何事件中来解决。I had a very similar problem that I was able to fix by putting
tableview.setData(tableview.data);
into any events that caused the table to look strange.