Ich versuche, Floating EditText von viewgroup (LinearLayout) zu erhalten. Einfach EditText Funktioniert gut, aber unfähig, damit zu kommen.Versuchen, Floating-EditText Children einer ViewGroup zu erhalten
hier ist mein Code:
XML-Code:
<LinearLayout
android:id="@+id/signup_form"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="64dp"
android:orientation="vertical">
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<EditText
android:id="@+id/et_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/hint_name"
android:inputType="textPersonName"
android:maxLines="1"
android:singleLine="true" />
</android.support.design.widget.TextInputLayout>
Java-Code:
for (int i = 0; i < layout.getChildCount(); i++) {
View v = layout.getChildAt(i);
if (v instanceof EditText) {
EditText editText = (EditText) v;
if (editText.getInputType() == InputType.TYPE_TEXT_VARIATION_PERSON_NAME + 1) {
isValid = validateName(et_name);
if (!isValid) {
break;
}
}
Diese (android.support.design.widget.TextInputLayout) kommt zwischen LinearLayout und EditText und ich ha Ich habe keine Ahnung, wie ich es lösen kann.
Vielen Dank im Voraus
Es ist nicht ganz klar, was dein Problem ist. Wenn Sie einen Verweis auf den 'EditText' wollen, verwenden Sie' findViewById() '. –
Danke @MikeM für Ihren Rat! Jetzt habe ich mein Problem von der unten erwähnten Antwort gelöst. – Manish