Android TextInput布局未清除错误消息

Android TextInput布局未清除错误消息,android,Android,某些用户输入后未清除文本字段错误 如果我添加了一条错误消息,它会被放置在编辑文本的下面,一切看起来都很好 在这里,我输入了第一个用户名,但错误仍然显示在textinput布局下方 代码: 您需要在获得文本输入的值后清除文本输入-当您确认它们有值时。如果在执行第一个else后它们没有值,则为空 if(!TextUtils.isEmpty(display_name) && !TextUtils.isEmpty(email) && !TextUtils.isEmpt

某些用户输入后未清除文本字段错误

如果我添加了一条错误消息,它会被放置在编辑文本的下面,一切看起来都很好

在这里,我输入了第一个用户名,但错误仍然显示在textinput布局下方

代码:


您需要在获得文本输入的值后清除文本输入-当您确认它们有值时。如果在执行第一个else后它们没有值,则为空

if(!TextUtils.isEmpty(display_name) && !TextUtils.isEmpty(email) && 
!TextUtils.isEmpty(password)){

    mRegProgress.setTitle("Registering User");
    mRegProgress.setMessage("Please wait....");
    mRegProgress.setCanceledOnTouchOutside(false);
    mRegProgress.show();

    register_user(display_name, email, password);
    // This is where you reset your text inputs and other bits and pieces.
    // If this is true nothing beyond here is executed!!

}else{
因此,将您的逻辑置于其他逻辑之上:

if(!TextUtils.isEmpty(display_name) && !TextUtils.isEmpty(email) && 
!TextUtils.isEmpty(password)){

    mRegProgress.setTitle("Registering User");
    mRegProgress.setMessage("Please wait....");
    mRegProgress.setCanceledOnTouchOutside(false);
    mRegProgress.show();

    register_user(display_name, email, password);
    // This is where you reset your text inputs and other bits and pieces.
    // Start your logic to validate the input here
    if (mDisplayName.getEditText().getText().toString().length() == 0){
        .../...

}else{
    // Put your logic here if there is no input. 

您需要在获得文本输入的值后清除文本输入-当您确认它们有值时。如果在执行第一个else后它们没有值,则为空

if(!TextUtils.isEmpty(display_name) && !TextUtils.isEmpty(email) && 
!TextUtils.isEmpty(password)){

    mRegProgress.setTitle("Registering User");
    mRegProgress.setMessage("Please wait....");
    mRegProgress.setCanceledOnTouchOutside(false);
    mRegProgress.show();

    register_user(display_name, email, password);
    // This is where you reset your text inputs and other bits and pieces.
    // If this is true nothing beyond here is executed!!

}else{
因此,将您的逻辑置于其他逻辑之上:

if(!TextUtils.isEmpty(display_name) && !TextUtils.isEmpty(email) && 
!TextUtils.isEmpty(password)){

    mRegProgress.setTitle("Registering User");
    mRegProgress.setMessage("Please wait....");
    mRegProgress.setCanceledOnTouchOutside(false);
    mRegProgress.show();

    register_user(display_name, email, password);
    // This is where you reset your text inputs and other bits and pieces.
    // Start your logic to validate the input here
    if (mDisplayName.getEditText().getText().toString().length() == 0){
        .../...

}else{
    // Put your logic here if there is no input.