Как добавить значение (setText) в дизайн материала TextInputLayout? - PullRequest
0 голосов
/ 04 мая 2020

Как мне установитьТекст для дизайна материала TextInputLayout (Material Design) в 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()

Приведенный выше код не работал для меня.

My xml код:

<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>

1 Ответ

1 голос
/ 04 мая 2020

это синтаксис. Используйте его в вашем коде в зависимости от ситуации:

mTextInputLayout.getEditText().setText("ur text");

и

mTextInputLayout.getEditText().getText()
...