Titanium에서 TableView 표시
2550 단어 Titanium
1. 필요한 설명
1.tableViewRowを記述
2.画像の配置
3.ラベルの配置
4.画像、ラベルをtableViewに格納
이것을 표시하게 합니다.
2. 구현
· 실장 한 내용은 여기
var win = Ti.UI.createWindow({
backgroundColor:'#fff'
});
var tableView;
var rowData = [];
var headerRow = Ti.UI.createTableViewRow();
headerRow.backgroundColor = '#576996';
headerRow.selectedBackgroundColor = '#385292';
headerRow.height =40;
var clickLabel = Titanium.UI.createLabel({
text:'Hello Facebook',
color:'#fff',
textAlign:'center',
font:{fontSize:24},
width:'auto',
height:'auto'
});
headerRow.className = 'header';
headerRow.add(clickLabel);
rowData.push(headerRow);
for (var c = 1; c < 50; c++){
var row = Ti.UI.createTableViewRow();
row.selectedBackgroundColor = '#fff';
row.height = 100;
row.className = 'datarow';
var photo = Ti.UI.createView({
backgroundImage: 'images/user.png',
top: 20,
left: 10,
width: 50,
height: 50
});
photo.rowNum = c;
photo.addEventListener('click', function() {
alert('Hello World');
});
row.add(photo);
var user = Ti.UI.createLabel({
color:'#576996',
font:{fontSize:16, fontWeight:'bold', fontFamily:'Arial'},
left:70,
top:2,
height:30,
width:200,
text:'Kanno Yuma' + c
});
user.rowNum = c;
user.addEventListener('click', function(){
alert('OK!');
});
row.add(user);
var comment = Ti.UI.createLabel({
color:'#222',
font:{fontSize:16,fontWeight:'normal', fontFamily:'Arial'},
left:70,
top:21,
height:50,
width:200,
text:'ckckckckckcckkckckckckckckckckckckck'
});
row.add(comment);
var calendar = Ti.UI.createView({
backgroundImage:'images/image.png',
bottom:2,
left:70,
width:32,
height:32
});
calendar.rowNum = c;
calendar.addEventListener('click', function(){
alert('image');
});
row.add(calendar);
var button = Ti.UI.createView({
backgroundImage:'images/droplet.png',
top:35,
right:5,
width:36,
height:34
});
button.rowNum = c;
button.addEventListener('click', function(){
alert('NO!');
});
row.add(button);
rowData.push(row);
}
tableView = Ti.UI.createTableView({
data: rowData
});
win.add(tableView);
포인트는 for 문을 사용하여 var rowData = []; for 문에서 tableViewRow를 늘리고 []에 저장하여 tableView에 추가 할 수 있습니다.
Reference
이 문제에 관하여(Titanium에서 TableView 표시), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://qiita.com/canno/items/e7ac5d63350a730dde59텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념 (Collection and Share based on the CC Protocol.)