java - Android app button not getting disabled/unclickable -


this question has answer here:

the button defined in mainui thread here part of code causing trouble-

        button.setonclicklistener(new onclicklistener() {         public void onclick(view v){             new thread(new runnable() {                  public void run() {                     try {                         outputstream outtoserver = client.getoutputstream();                         dataoutputstream out = new dataoutputstream(outtoserver);                         out.writeutf("hello " + client.getlocalsocketaddress());                         final string msg = edi.gettext().tostring();                         out.writeutf("client: " + msg);                          runonuithread(new runnable() {                             @override                             public void run() {                                 tex.append(msg);                                 if (msg == "quit") {                                     button.setclickable(false);                                     tex.append("quitbutton");                                 }                                 tex.append("client: " + msg + "\n");                                 edi.settext("");                             }                         });                      } catch (exception e) {                         e.printstacktrace();                     }                 }}).start();         }     }); 

rest of code here working fine. when send in "quit" string, msg variable has correctly. problem seems not entering if block @ all, because if did, should have shown "quibutton" text in textview, ain't.

i'd appreciate kind of help, :)

edit- didn't realize wasn't comparing strings in right way, not don't know how to. got mixed c++ operator overloaded function in head wanted compare strings using == directly.

change this

if (msg == "quit") {                     button.setclickable(false);                     tex.append("quitbutton");                    } 

to this

if (msg.equals("quit")) {                     button.setenabled(false);                     tex.append("quitbutton");                    } 

Comments

Popular posts from this blog

yii2 - Yii 2 Running a Cron in the basic template -

asp.net - 'System.Web.HttpContext' does not contain a definition for 'GetOwinContext' Mystery -

mercurial graft feature, can it copy? -