Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/459.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/193.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 移动应用程序表视图中的附加行必须永久保留(钛)_Javascript_Android_Dom Events_Mobile Application_Appcelerator Mobile - Fatal编程技术网

Javascript 移动应用程序表视图中的附加行必须永久保留(钛)

Javascript 移动应用程序表视图中的附加行必须永久保留(钛),javascript,android,dom-events,mobile-application,appcelerator-mobile,Javascript,Android,Dom Events,Mobile Application,Appcelerator Mobile,我正在使用Tianium开发Android应用程序。我正在使用以下代码来显示数据和使用表视图。当我单击“注释”时,会在表视图中追加一个新行。它工作正常。但当我单击“上一步”按钮或转到另一个窗口,然后再次返回到添加新行的同一窗口时,新添加的行不会保留。我也尝试了 insertRowAfter但它给出了相同的结果。我使用了以下代码: for (var i=0;i<5;i++) { var row = Ti.UI.createTableViewRow({height:'auto',cla

我正在使用Tianium开发Android应用程序。我正在使用以下代码来显示数据和使用表视图。当我单击“注释”时,会在表视图中追加一个新行。它工作正常。但当我单击“上一步”按钮或转到另一个窗口,然后再次返回到添加新行的同一窗口时,新添加的行不会保留。我也尝试了 insertRowAfter但它给出了相同的结果。我使用了以下代码:

for (var i=0;i<5;i++)
{
    var row = Ti.UI.createTableViewRow({height:'auto',className:"row"});
    var comments = Ti.UI.createLabel(
    {
        text:'new comment',
        height:'auto',
        font:{fontSize:12, fontFamily:'Helvetica Neue'},
        color:'#000',
        width:'auto',
        textAlign:'left',
        top:10,
        left:40,
    });row.add(comments);
}
comment_table.setData(data);
commnet.add(comment_table);
var comment_btn = Titanium.UI.createButton(
{
    title:'comment',
    height:60,
    width:60,
    bottom:-5,
    left:-2,
});
comment.add(comment_btn);
var comment_box = Titanium.UI.createTextArea({
    borderRadius:5,
    backgroundColor:'#EEE',
    editable: true,
    height:30,
    width:200,
    top:10,
    font:{fontSize:15,fontFamily:'Marker Felt'},
    color:'#000',
    keyboardType:Titanium.UI.KEYBOARD_DEFAULT,
    returnKeyType:Titanium.UI.RETURNKEY_DEFAULT,
    borderRadius:5, 
});
comment.add(comment_box);
comment_btn.addEventListener('click', function()
{
    comment_table.appendRow({title:comment_box.value});
    //comment_table.insertRowAfter(3,{'title':comment_box.value});
}   
(变量i=0;i)的

  • 对象的类型必须为:
    comment\u table.appendRow(Row\u type\u Object)
  • 如果您要返回(假设按下后退按钮),则当前窗口将因此关闭 该窗口的所有子窗口表示视图、按钮和表将被删除
  • 假设当前窗口的Tableview为widnow1,现在打开window2,如果 从window2转换到window1时,您可以在中看到带有新附加行的表 窗口1
  • 解决方案:

  • 创建一个全局数组(
    data[]
    ),该数组保存要删除的行和行 附加
  • 加载当前window1时,检查数据是否为空
  • 如果数据不为null,则从全局数组数据加载tableview
    tableview.setData(data)
    ,否则加载新的行