0

在这里,我的 tableView 有问题我想在表格的每一行中插入文本

你能帮我吗

这是代码

// this sets the background color of the master UIView (when there are no windows/tab groups on it)
Titanium.UI.setBackgroundColor('white');

// create tab group
var tabGroup = Titanium.UI.createTabGroup({ 

});

// create base UI tab and root window

var win1= Titanium.UI.createWindow({ 

    title:'',
    tabBarHidden: true,
    barColor:'black',
    backgroundColor:'white'
});


var tab= Ti.UI.createTab({
    title:'Connexion ',
    window:win1

});

//
//  This is a test that is meant to verify that a row object can have a header
//  and the table view has no table view header - the header should be displayed

var win = Titanium.UI.currentWindow;

var inputData = [
    {title:'Pseudo/email :', header:'Connexion ......'},
    {title:'Password :'},

    {title:'Créer votre compte',hasChild:true, header:'not yet registered ?'},

];
var tableView = Titanium.UI.createTableView({
    data:inputData,
    style:Titanium.UI.iPhone.TableViewStyle.GROUPED
});
win1.add(tableView);

tabGroup.addTab(tab);

// open tab group-----------------------------------------
tabGroup.open();
win1.open();

这就是我现在所做的,但是我的表格标题有问题,然后我添加了另一个表格。

还有一些光标在中线标题中移动的ouci

这是代码

var win1= Titanium.UI.createWindow({ 

    title:'',
    tabBarHidden: true,
    barColor:'black',
    backgroundColor:'white'
});


    var view = Titanium.UI.createView({
        backgroundColor: "#FFFEEE"
    });


    var row1 = Ti.UI.createTableViewRow({
        height:'auto',
        selectionStyle:Ti.UI.iPhone.TableViewCellSelectionStyle.NONE
    });


    var label1 = Titanium.UI.createLabel({
        text:'Pseudo/e-mail :',
        left: 10
    });


    var usernametf = Ti.UI.createTextField({
        left: 100,
        right:10,
        //hintText: 'Pseudo/email :',
    //textAlign:"right",
        borderStyle: Ti.UI.INPUT_BORDERSTYLE_NONE
    });


    var row2 = Ti.UI.createTableViewRow({
        height:'auto',
        selectionStyle:Ti.UI.iPhone.TableViewCellSelectionStyle.NONE
    });


    var label2 = Titanium.UI.createLabel({
    text:'Mot de passe :',
        left: 10       
    });

    var passwordtf = Ti.UI.createTextField({
        left: 100,
        //textAlign:"right",
        //hintText: 'password',
        right:30,
        passwordMask:true,
        borderStyle: Ti.UI.INPUT_BORDERSTYLE_NONE
    });

    row1.add(label1);

    row1.add(usernametf);

    row2.add(label2);

    row2.add(passwordtf);

    var data = [row1,row2];

    var table = Ti.UI.createTableView
    ({

    data:data,
    style: Ti.UI.iPhone.TableViewStyle.GROUPED

    });


    view.add(table);

    win1.add(view);

win1.open();

我让你知道我真的是从 Appcelerator 开始的

4

1 回答 1

0

你有什么理由不只使用文本字段吗?然后,您可以在按钮按下并插入时获取值。

厨房水槽示例链接 https://github.com/appcelerator/titanium_mobile/blob/master/demos/KitchenSink/Resources/examples/textfield_events.js

像这样的屏幕的另一个示例是 Tweetanium 应用程序https://github.com/appcelerator/tweetanium

无论您使用文本字段还是表格视图,都可以通过多种方式使用 Ti 数据库对象。

两种常见的方法是:

1)您可以遍历您的 inputData 对象并插入。下面是几个例子。

https://github.com/appcelerator/titanium_mobile/blob/master/demos/KitchenSink/Resources/examples/database_2.js

https://github.com/appcelerator/titanium_mobile/blob/master/demos/KitchenSink/Resources/examples/database_3.js

2)您可以使用 tableview 对象本身或类似于此示例的包装器https://github.com/kwhinnery/Persistence

如果可能,我建议使用文本字段。

于 2011-04-27T13:01:46.143 回答