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 your code:
mTextInputLayout.getEditText().setText("your text");
and
mTextInputLayout.getEditText().getText()