How do I setText to a Material Design TextInputLayout (Material Design) in Android Studio?
//setValue
BarCode.setText(MainPage.ResultCode.getText());
TextInputLayout BarCode;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_discharge_product);
BarCode = findViewById(R.id.barcodeAdd);
BarCode.setText(MainPage.ResultCode.getText()
The above code did not work for me.
My XML code:
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/barcodeAdd"
android:layout_width="match_parent"
android:layout_height="wrap_content"
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox">
<com.google.android.material.textfield.TextInputEditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Bar Code"/>
</com.google.android.material.textfield.TextInputLayout>
TextInputEditText
orEditText
– BoonyBarCode
? I guess it is theTextInputLayout
, so instead of it use theTextInputEditText
. Post the relevant part of the code. – BoonybarcodeAdd
? You can see it in the xml file – BoonybarcodeAdd
is the id of the TextInputLayout input. i have uploaded the xml file – Alameda