Comparing two editTexts in android

前端 未结 6 1544
既然无缘
既然无缘 2020-12-22 05:01

I am learning android I tried following codeline but it\'s giving me error please give me suggestions, that how can I compare two edittext\'s text.



        
6条回答
  •  南笙
    南笙 (楼主)
    2020-12-22 05:50

    I have find the best solution..

    if(Password.getText().toString().trim().matches(confirmPassword.getText().toString().trim()))
    {
    // then do your work
    }
    else
    //otherwise show error message.
    

    whereas

    Password = (EditText)findViewById(R.id.pass);
    
    confirmPassword = (EditText)findViewById(R.id.confirmpass);
    

    are two editText.

提交回复
热议问题