开发者

Android if value not working

I am having problem,

final Button button = (Button) findViewById(R.id.okBtn);
button.setOnClickListener(new View.OnClickListener() {
    public void onClick(View v) {
        String res = getServerData("http://10.0.2.2/auth.php?username="+username.getText()+"&password="+password.getText());
        //txt.开发者_如何转开发setText(res);
        if("true".equals(res))
            txt.setText("SUCESS");
        else
            txt.setText("FAILED");
    }
});

Why this conditions keep on FAILED even though if i uncomment txt.setText(res) it display as true. any idea why?

Thank you..


i think that is problem related to the extra spaces in the the string so try it.

final Button button = (Button) findViewById(R.id.okBtn);
button.setOnClickListener(new View.OnClickListener() {
    public void onClick(View v) {
        String res = getServerData("http://10.0.2.2/auth.php?username="+username.getText()+"&password="+password.getText());
        //txt.setText(res);
        Log.d("MyActivity",res);
        if("true".equals(res.trim()))
            txt.setText("SUCESS");
        else
            txt.setText("FAILED");
    }
});

if this work or not.

please inform me i want to know exactly going on.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜