滚动对于tableview不起作用。
我在移动设备上尝试过相同的功能,并且它在平板电脑中的工作和滚动没有发生在平板电脑中..
帮助。
CODE
var win = Titanium.UI.createWindow({
title : 'Medall app',
backgroundColor : '#fff',
fullscreen : false,
navBarHidden : true,
layout : 'vertical',
});
var scrollView = Titanium.UI.createScrollView({
contentWidth : 'auto',
contentHeight : 'auto',
width : Titanium.UI.FILL,
height : Titanium.UI.FILL,
top : '0dp',
bottom : '0dp',
layout : 'vertical',
showVerticalScrollIndicator : true
});
win.add(scrollView);
var mainview = Titanium.UI.createView({
width : Ti.UI.FILL,
height : Ti.UI.FILL,
//layout : 'horizontal',
horizontalWrap : false,
//right : '10dp',
//left : '10dp',
layout : 'vertical',
//backgroundImage : '/images/backblue.png'
//backgroundColor : medblue,
backgroundColor : 'white',
bottom : '20dp'
//top : '20dp',
//backgroundColor:''
});
scrollView.add(mainview);
var tableview = Titanium.UI.createTableView({
//data : data,
backgroundColor : 'white',
width : '90%',
height : 0,
layout : 'horizontal',
padding : '10dp',
separatorColor : bordercolor_views_textfields,
top : '0dp',
borderColor : medblue,
scrollable : true
});
mainview.add(tableview);
var a=['1','2','3','4','5'];
for (var i = 0; i < a.length; i++) {
var row = Ti.UI.createTableViewRow({
height : '30dp',
layout : 'vertical',
className : 'row',
objName : 'row',
onClick : "delete",
onPress : "rowvalue",
backgroundColor : 'white',
//rightImage : '/images/Right_Arrow',
top : '0dp',
padding : '10dp',
width : '100%',
horizontalWrap : false,
layout : 'horizontal',
backgroundColor : 'white',
top : '10dp',
padding : '10dp',
});
var heading_report = Titanium.UI.createView({
width : '48%',
height : Ti.UI.SIZE,
//layout : 'horizontal',
horizontalWrap : false,
//right : '10dp',
//left : '10dp',
layout : 'vertical',
//backgroundImage : '/images/backblue.png'
backgroundColor : 'white',
left : '0dp',
left : '1%',
right : '1%',
padding : '10dp',
});
row.add(heading_report);
var heading_report_label = Ti.UI.createLabel({
text : a[i],
font : {
fontSize : '20dp',
fontWeight : 'bold'
},
color : bordercolor_views_textfields,
left : '0dp',
//left : '10dp',
//right : '10dp'
//bottom : '10dp'
});
heading_report.add(heading_report_label);
var heading_status = Titanium.UI.createView({
width : '48%',
height : Ti.UI.SIZE,
//layout : 'horizontal',
horizontalWrap : false,
//right : '10dp',
//left : '10dp',
layout : 'absolute',
//backgroundImage : '/images/backblue.png'
backgroundColor : 'white',
left : '1%',
right : '1%',
padding : '10dp',
});
row.add(heading_status);
var heading_status_label = Ti.UI.createLabel({
text : "" + a[i],
color : 'black',
font : {
fontSize : '20dp',
fontWeight : 'bold'
},
left : '0dp',
});
heading_status.add(heading_status_label);
data.push(row);
stableview.setData(data);
}
甚至尝试在清单中添加此内容但没有帮助
<android xmlns:android="http://schemas.android.com/apk/res/android">
<manifest>
<application android:theme="@style/Theme.MyTheme">
<supports-screens android:largeScreens="true"
android:normalScreens="true"
android:smallScreens="true" android:xlargeScreens="true"/>
<uses-sdk android:minSdkVersion="10" android:targetSdkVersion="19"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
</application>
</manifest>
</android>
答案 0 :(得分:0)
我更新了一些代码:
var win = Titanium.UI.createWindow({
title : 'Medall app',
backgroundColor : '#fff',
fullscreen : false,
navBarHidden : true,
layout : 'vertical',
});
var scrollView = Titanium.UI.createScrollView({
// contentWidth : 'auto',
// contentHeight : 'auto',
width : Titanium.UI.FILL,
// height : Titanium.UI.FILL,
top : '0dp',
bottom : '0dp',
layout : 'vertical',
showVerticalScrollIndicator : true
});
win.add(scrollView);
var mainview = Titanium.UI.createView({
width : Ti.UI.FILL,
height : Ti.UI.FILL,
//layout : 'horizontal',
horizontalWrap : false,
//right : '10dp',
//left : '10dp',
layout : 'vertical',
//backgroundImage : '/images/backblue.png'
//backgroundColor : medblue,
backgroundColor : 'white',
bottom : '20dp'
//top : '20dp',
//backgroundColor:''
});
scrollView.add(mainview);
var data = [];
var tableview = Titanium.UI.createTableView({
//data : data,
backgroundColor : 'white',
width : '90%',
// height : 0,
layout : 'horizontal',
padding : '10dp',
separatorColor : 'black',//bordercolor_views_textfields,
top : '0dp',
borderColor : 'blue',//medblue,
scrollable : true
});
mainview.add(tableview);
var a=['1','2','3','4','5'];
for (var i = 0; i < a.length; i++) {
var row = Ti.UI.createTableViewRow({
height : '30dp',
layout : 'vertical',
className : 'row',
objName : 'row',
onClick : "delete",
onPress : "rowvalue",
backgroundColor : 'white',
//rightImage : '/images/Right_Arrow',
top : '0dp',
padding : '10dp',
width : '100%',
horizontalWrap : false,
layout : 'horizontal',
backgroundColor : 'white',
top : '10dp',
padding : '10dp',
});
var heading_report = Titanium.UI.createView({
width : '150dp',//'48%',
height : Ti.UI.SIZE,
//layout : 'horizontal',
horizontalWrap : false,
//right : '10dp',
//left : '10dp',
layout : 'vertical',
//backgroundImage : '/images/backblue.png'
backgroundColor : 'white',
left : '0dp',
left : '1%',
right : '1%',
padding : '10dp',
});
row.add(heading_report);
var heading_report_label = Ti.UI.createLabel({
text : a[i],
font : {
fontSize : '20dp',
fontWeight : 'bold'
},
color : 'black',//bordercolor_views_textfields,
left : '0dp',
//left : '10dp',
//right : '10dp'
//bottom : '10dp'
});
heading_report.add(heading_report_label);
var heading_status = Titanium.UI.createView({
width : '48%',
height : Ti.UI.SIZE,
//layout : 'horizontal',
horizontalWrap : false,
//right : '10dp',
//left : '10dp',
layout : 'absolute',
//backgroundImage : '/images/backblue.png'
backgroundColor : 'white',
left : '1%',
right : '1%',
padding : '10dp',
});
row.add(heading_status);
var heading_status_label = Ti.UI.createLabel({
text : "" + a[i],
color : 'black',
font : {
fontSize : '20dp',
fontWeight : 'bold'
},
left : '0dp',
});
heading_status.add(heading_status_label);
data.push(row);
tableview.setData(data);
}
win.open();
现在它的工作正常,没有必要在清单标签中写任何东西。