如果两个编辑文本字段不为空,如何更改图像的可绘制性

我已经研究了推荐的类似问题,并尝试了许多不同的方法,但到目前为止它们还没有奏效,我不确定为什么。也许我错误地实施了它们,但不确定。

我想做的是,如果两个Edittext字段都从空变为在其中包含文本,则将按钮的可绘制区域更改为较亮的颜色。

<?xml version="1.0" encoding="utf-8"?>

<LinearLayout

    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    tools:context=".RegistrationActivity"
    android:orientation="vertical">


    <TextView
        android:layout_width="204dp"
        android:layout_height="wrap_content"
        android:layout_marginLeft="33dp"
        android:layout_marginTop="33dp"
        android:text="My email and password are"
        android:textSize="32dp"
        android:fontFamily="@font/roboto_black"
        android:textColor="@android:color/holo_green_light" />

    <EditText
        android:id="@+id/emailReg"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:ems="10"
        android:fontFamily="@font/roboto_lightitalic"
        android:hint="email"
        android:inputType="textEmailAddress"
        android:layout_marginLeft="33dp"
        android:layout_marginTop="27dp"/>

    <EditText
        android:id="@+id/passwordReg"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:hint="password"
        android:ems="10"
        android:fontFamily="@font/roboto_lightitalic"
        android:inputType="textWebPassword"
        android:layout_marginLeft="33dp"
        android:layout_marginTop="17dp"/>

    <TextView
        android:id="@+id/textView"
        android:layout_width="323dp"
        android:layout_height="wrap_content"
        android:layout_marginLeft="33dp"
        android:layout_marginTop="23dp"
        android:ems="10"
        android:justificationMode="inter_word"
        android:text="Clicking 'Continue' will send a verification email to the address above. This will be used to log you in at future dates." />


    <ImageButton
        android:id="@+id/registerReg"
        android:layout_width="wrap_content"
        android:layout_height="52dp"
        android:layout_marginLeft="32dp"
        android:layout_marginTop="17dp"
        android:layout_marginRight="32dp"
        android:background="@null"
        android:scaleType="fitCenter"
        />


</LinearLayout>

和活动:

public class RegistrationActivity extends AppCompatActivity {

    //VARIABLES

    private ImageButton mRegister;

    private EditText mEmail;
    private EditText mPassword;

    private FirebaseAuth mAuth;
    private FirebaseAuth.AuthStateListener fireBaseAuthStateListener;

    private DatabaseReference userRef;

    String emailStr;
    String passwordStr;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_registration);

        //VARIABLE IDS

        mEmail = (EditText) findViewById(R.id.emailReg);
        mPassword = (EditText) findViewById(R.id.passwordReg);
        mRegister = (ImageButton) findViewById(R.id.registerReg);
        mAuth = FirebaseAuth.getInstance();

        mEmail.setOnFocusChangeListener(new View.OnFocusChangeListener() {
            @Override
            public void onFocusChange(View v, boolean hasFocus) {
                if (hasFocus) {
                    emailStr = mEmail.getText().toString().trim();
                }
            }
        });

        mPassword.setOnFocusChangeListener(new View.OnFocusChangeListener() {
            @Override
            public void onFocusChange(View v, boolean hasFocus) {
                if(hasFocus) {
                    passwordStr = mPassword.getText().toString().trim();
                }
            }
        });


        changeButtonDrawable(emailStr, passwordStr);


        //REGISTER BUTTON

            mRegister.setOnClickListener(new View.OnClickListener() {

                final String email = mEmail.getText().toString().trim();
                final String password = mPassword.getText().toString().trim();

                @Override
                public void onClick(View v) {

                    mAuth.createUserWithEmailAndPassword(email, password).addOnCompleteListener(RegistrationActivity.this, new OnCompleteListener<AuthResult>() {
                        @Override
                        public void onComplete(@NonNull Task<AuthResult> task) {

                            firebaseUtility fU = new firebaseUtility();

                            String currentUserId = fU.getUserIdString();
                            DatabaseReference userRef = fU.getUserDatabaseRef(currentUserId);

                            Map userInfo = new HashMap();

                            userInfo.put("email", email);
                            userInfo.put("profileImageUrl", "default");

                            userRef.updateChildren(userInfo);

                            if (task.isSuccessful()) {

                                Intent intent = new Intent(RegistrationActivity.this, MainActivity.class);
                                startActivity(intent);
                                finish();

                            }
                        }

                    });

                }
            });

    }
    @Override
    public void onStart() {
        super.onStart();
        mAuth = FirebaseAuth.getInstance();
        FirebaseUser user = FirebaseAuth.getInstance().getCurrentUser();
        if(user != null) {
            Intent intent = new Intent(RegistrationActivity.this, NameAgeZipActivity.class);
            startActivity(intent);
            finish();
        }
    }

    private void changeButtonDrawable (String email, String password){
        if (TextUtils.isEmpty(email) && TextUtils.isEmpty(password)){
            mRegister.setImageResource(R.drawable.continue_btn_grey_on_grey);
        } else if (!TextUtils.isEmpty(email) && !TextUtils.isEmpty(password)) {
            mRegister.setImageResource(R.drawable.continue_btn_white_on_purple);
        }
    }

}

基本上,如果两个字段中都有文本,则ImageButton应该更改为可绘制的continue_btn_white_on_purple,但是现在它只是保持灰色。一直试图弄清楚这一点。任何帮助,不胜感激。