java - Android app button not getting disabled/unclickable -
this question has answer here:
- how compare strings in java? 23 answers
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
Post a Comment