Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/212.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
Android Appcelerator更改按钮文本_Android_Text_Button_Titanium_Appcelerator - Fatal编程技术网

Android 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

您好

我正在尝试更改appcelerator中按钮上的文本

现在我可以更改它一次,但一旦发生某个事件,我就不能将文本更改回原来的位置

代码如下:

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(){}中的文本