0

I have xml like this

<com.google.android.material.textfield.TextInputLayout
                android:id="@+id/layout_phone"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginStart="34dp"
                android:layout_marginEnd="34dp"
                android:textColorHint="@color/grey_40"
                android:theme="@style/EditText.Black">

                <androidx.appcompat.widget.AppCompatEditText
                    android:id="@+id/edit_phone"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:textSize="17sp"
                    android:inputType="phone"
                    android:textColor="@android:color/black"
                    android:fontFamily="@font/poppinsregular"/>

            </com.google.android.material.textfield.TextInputLayout>

And Then 2 theme style, Black and white, as you can see i'm using black theme to default for my textinputlayout, but now i need to change it to red on this code :

private void checklogin(){
        nomor_handphone = findViewById(R.id.edit_phone);
        if(!nomor_handphone.getText().toString().equals("1234567890")){
            Handler handler = new Handler();
            handler.postDelayed(new Runnable() {
                @Override
                public void run() {
                     //code for change theme from @style/EditText.Black to @style/EditText.Red
                }
            }, 2000);

        }

Can you help me ?

  • do you really need theming here? you can use `setError` method which will display red error message – fraggjkee May 09 '20 at 15:52
  • https://stackoverflow.com/questions/60898946/materialcomponents-textinputlayout-outlinedbox-it-doesnt-work-properly-boxbackg/60910419#60910419 – MMG May 09 '20 at 16:45

0 Answers0