开发者

Content of a inflated EditText

I'm having a hard time figuring out how to getText() as a readable String from a inflated EditText.

I have a boolean method that checks something, so, in the onCreate method i call it like this

if(method) {
    if(booleanVariable) {
         LayoutInflater factory = LayoutInflater.from(MyActivity.this);
         View child = factory.inflate(R.layout.password, null);
         mPassword = (EditText)child.findViewById(R.id.password);
           }
}

Then thats the part where i try to retrieve the text:

private View.OnClickListener btnLoginListener = new View.OnClickListener() {        
@Override
public void onClick(View v) {
     if(mPassword!=null) {开发者_JAVA百科
          if(mPassword.getText().toString()==password) {                    
// LOGIN OK
            } else {
// NOT OK
            }
     }
}

Result:

07-11 15:39:53.098: VERBOSE/Project(1239): mPassword: <b>android.widget.EditText@43d3ba98</b> password: 329349


Im still quite new and I don't know too much about EditTexts but normally in Java we don't use == for Strings since they are objects.

mPassword.getText().toString().equals(password)

would be more correct.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜