0

I determine the user's location and display it in a TextInputEditText field. The hint, however, remains in the background. What am I doing wrong?

 <com.google.android.material.textfield.TextInputLayout
            android:id="@+id/textLayoutAutocomplete"
            style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:hint="@string/standort"
            android:layout_weight="1">

 <com.google.android.material.textfield.TextInputEditText
                android:id="@+id/autocomplete"
                android:focusableInTouchMode="false"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"                  
                android:inputType="text"
                />

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

To set the value::

  binding.autocomplete.setText(place.toString())
  //Also not working:
  //binding.textLayoutAutocomplete.hint = ""

2 Answers 2

0

After setting the text, you can set the isHintEnabled of TextInputLayout to false.

binding.textLayoutAutocomplete.isHintEnabled = false
Sign up to request clarification or add additional context in comments.

Comments

-1

Try This

binding.autocomplete.setText(place.toString());
binding.textLayoutAutocomplete.setHint(""); // Set hint to an empty string

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.