繁体   English   中英

TItanium:滚动在表格视图中不起作用

[英]TItanium: Scroll not working in tableview

滚动不适用于tableview。

我已经在移动设备中尝试过相同的操作,并且它在平板电脑中无法正常工作并在tableview中滚动。

请帮助。

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>

我已经更新了一些代码:

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();

现在,它的工作正常,无需在manifest标签中编写任何内容。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM