Titanium Tableview Android没有显示行

时间:2015-03-14 02:42:59

标签: android uitableview titanium cross-platform

我已经开发了一个主要在iOS上的移动应用程序,现在想要在Android中使一切正常运行。在我的移动应用程序中,我在主屏幕中有一个可滚动且由多个面板组成的面板列表。为此我在iOS中使用了一个TableView,其中填充了行,每行都有自己的布局。例如,这样的行可以包含带有图像和文本的标题。 这是我用来在iOS中创建和填充数据库的代码:

var activityWall = Ti.UI.createTableView({
    backgroundColor: 'transparent',
    width: '80%',
    top: '10px'
});

function populateActivityWall(append, receivedData) {
    var posts = [];


    if (!append)
        activityWall.setData([]);

    for(var id in receivedData) {
        var post = receivedData[id];
        var row = createPost(post);

        posts.push(row);
    }

    posts = posts.reverse();
    for(var i=0;i<posts.length; i++) {
        activityWall.appendRow(posts[i]);
    }
}


function createPost(post) {
    var row = {
        height: '88px',
        //selectedBackgroundColor: 'transparent',
    };

    var postView = Titanium.UI.createView({
        top: '18px',
        layout:'vertical',
        width: '100%',
        backgroundColor: Constants.Colors.white,
        borderRadius: 5
    });

    var header = Titanium.UI.createView({
        width: '100%',
        height: '70px',
        borderRadius: 5,
        borderWidth: '4px',
        borderColor: Constants.Colors.mediumGreen
    });

    var profilePic = Titanium.UI.createImageView({
        image: post.User.avatar,
        width: 'auto',
        height: '60px',
        left: '5%'
    });

    var nameDateLabel = Titanium.UI.createLabel({
        text: post.User.name + " " + post.River.status.toLowerCase() + post.Object.name + "\n" + post.River.time_ago,
        left: calculateWidth('10%', 80),
        width: 'auto',
        height: '70px',
        font:{fontFamily:'Arial',fontSize:11} 
    });

    header.add(profilePic);
    header.add(nameDateLabel);

    postView.add(header);   
    row.add(postView);

    return row;
}

虽然这在iOS上完美运行,但上面的代码并没有在android中正确显示表格。我已经多次检查过,数据被正确接收,没有引发任何特定的警告或错误。我甚至看到桌子被填满了,因为我看到滚动条收缩并且rowseperators是可见的。然而,行本身是透明的,不显示任何内容。 有人知道可能是什么问题吗?谢谢!

0 个答案:

没有答案
相关问题