DroidScript意外结束令牌

时间:2018-05-12 05:26:33

标签: droidscript

它正好说明了这一点。我不认为我弄错了。这是我的代码:

function OnStart()
{
 list=app.LoadText("List");
lvw= app.CreateListView(list,"Lego");

 lvw.SetOnTouch( lvw_OnTouch );
 lvw.Show();
 }
 app.EnableBackKey( "false" );

 function lvw_OnTouch( item )
 {
if(item=="Add Item"){
to=app.LoadText( "List" );
//Create dialog window.
dlgTxt = app.CreateDialog( "Add Item" );  
//Create a layout for dialog.
layDlg = app.CreateLayout( "linear", "vertical,fillxy,left" );
layDlg.SetPadding( 0.02, 0, 0.02, 
 0.02 );
dlgTxt.AddLayout( layDlg );
lstDlg = app.CreateTextEdit("");
lstDlg.SetHint( "*******Item ID  here*******" );
lstDlg.SetPadding( 0.0, 0, 0.02, 
0.02);
lstDlg.SetTextColor( "#dddddd" );
layDlg.AddChild( lstDlg );
lstDlg.SetOnEnter( enter );
 amount= app.CreateTextEdit("");
amount.SetHint( "*******Item Amount*******" );
amount.SetPadding( 0.0, 0, 0.02, 
0.02);
amount.SetTextColor( "#dddddd" );

layDlg.AddChild( amount);
amount.SetOnEnter( enter );
//Show dialog.
dlgTxt.Show();
}else if(item=="Reset"){
var yesno=app.CreateYesNoDialog("Do you really want to reset?");
yesno.SetOnTouch(yesnores);
yesno.Show();

}else if(item=="Exit App"){
app.Exit(  );
}else{
lvw.Show();
}
function enter()
{
dlgTxt.Hide();
lvw.Show();
app.SaveText("List",to+","+lstDlg.GetText()+"        "+amount.GetText());
}
function OnBack()
{
app.Exit(  );
}
function yesnores(result)
{
if(result=="Yes") 
{app.SaveText("List","Add 
Item,Reset,Exit App");
}else  lvw.Show();
}
}

我一次又一次检查了代码,但没有结果,我无法找到导致错误的原因。不要忘记不是javascript,即DroidScript,这与javascript不同。当用户点击添加项目时,应用程序需要保存来自用户的值,当用户按下重置时应该重置列表,用户只需单击退出应用程序即可退出应用程序。

1 个答案:

答案 0 :(得分:0)

您在字符串中间有一个换行符

这应该是全部一行

app.SaveText("List","Add Item,Reset,Exit App");