问题
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);
回答1:
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.
来源:https://stackoverflow.com/questions/6073876/how-to-resolve-titanium-tableview-display-problem