![](/img/trans.png)
[英]How to remove the underline under TextInputLayout in Android Material Design?
[英]How to add value (setText) to a material design TextInputLayout?
如何在 android 工作室中将文本设置为材料设计 TextInputLayout(材料设计)?
//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()
上面的代码对我不起作用。
我的 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>
这是语法..在您的代码中酌情使用它:
mTextInputLayout.getEditText().setText("ur text");
和
mTextInputLayout.getEditText().getText()
例子:
TextInputEditText inpedit_txt;
inpedit_txt = (TextInputEditText)findViewById(R.id.id_of_input_edit_text);
inpedit_txt.setText(String.valueOf("you Text"))
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.