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>
this is the syntax.. use it as appropriate in you code:
mTextInputLayout.getEditText().setText("ur text");
and
mTextInputLayout.getEditText().getText()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With