Android Appcelerator更改按钮文本
您好 我正在尝试更改appcelerator中按钮上的文本 现在我可以更改它一次,但一旦发生某个事件,我就不能将文本更改回原来的位置 代码如下:Android Appcelerator更改按钮文本,android,text,button,titanium,appcelerator,Android,Text,Button,Titanium,Appcelerator,您好 我正在尝试更改appcelerator中按钮上的文本 现在我可以更改它一次,但一旦发生某个事件,我就不能将文本更改回原来的位置 代码如下: var login=Titanium.UI.createButton({ title:'Login', width:250, top:330 }); win.add(login); var xhr=Titanium.Network.createHTTPClient(); login.addEventListener('clic
var login=Titanium.UI.createButton({
title:'Login',
width:250,
top:330
});
win.add(login);
var xhr=Titanium.Network.createHTTPClient();
login.addEventListener('click', function(e){
login.title="Please wait..."; //this line works fine
xhr.onload=function(){
login.title="Login"; //this line doesn't work
if(uname.hasText){
uname.value=this.responseText;
}
};
xhr.onerror=function(){
login.title="Login"; //this line doesn't work
alertDialog.show();
};
xhr.open("POST","http://www.asdf.com/ajax/login.php");
if(uname.hasText && pword.hasText){
xhr.send({"uname":uname.value,"pword":pword.value});
}else{
alertDialog.show();
}
});
现在我真的不知道该怎么办
非常感谢您的任何见解
非常感谢,您应该在eventListener中创建HTTPClient
login.addEventListener('click', function(e){
var xhr=Titanium.Network.createHTTPClient();
xhr.onload=function(){};
xhr.onerror =function(){};
xhr.onreadysetstate =function(){};
}
嘿,我试过了,但仍然无法更改xhr.onload=function(){}中的文本