有没有一种方法或内置方法可以从android material TextInputLayout(om.google.android.material.textfield.TextInputLayout)获取文本?
我尝试过使用getText(),但在使用该文本字段时,此选项不可用,下面是文本字段:有没有一种方法或内置方法可以从android material TextInputLayout(om.google.android.material.textfield.TextInputLayout)获取文本?,android,material-design,Android,Material Design,我尝试过使用getText(),但在使用该文本字段时,此选项不可用,下面是文本字段: <com.google.android.material.textfield.TextInputLayout android:id="@+id/firstnametxt" android:layout_width="match_parent" android:layout_height="wr
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/firstnametxt"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="25dp"
android:layout_marginTop="120dp"
android:layout_marginRight="25dp"
android:hint="First Name">
<com.google.android.material.textfield.TextInputEditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="text" />
</com.google.android.material.textfield.TextInputLayout>
TextInputLayout
有一个editText
字段,您可以将它强制转换到textInputText
中,并使用它的text
字段获取其中的文本。例如,在科特林,它看起来像
val editText = textInputLayout.editText as TextInputEditText
editText.text
嗨,Pixyboy,看来你把这个发到了错误的堆栈交换站点。您可能正在寻找或。我已经把你的问题迁移到了这里,因为它已经脱离了主题。我添加了标签(之前由于迁移而未标记)。希望标签有意义,否则就可以重新标记。