In einem der Fragmente in meiner app ich eine EditText haben, und wenn ich darauf klicke die Tastatur kommt und der gesamte Inhalt in dem Fragment verschwindet nur, einschließlich der EditText. Ich kann auf der Tastatur noch ein, und nachdem ich die Zurück-Taste drücken, alles kommt zurück und alles, was ich tippe auf EditText zeigt, aber wie kann ich aufhören alles verschwinden?Android EditText Keyboard Fragment macht verschwinden
Unten ist der Code für das Fragment und das Layout.
Fragment:
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
public class PaymentsFragment extends Fragment {
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
return inflater.inflate(R.layout.fragment_payments, container, false);
}
}
Layout:
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<EditText
android:id="@+id/editText2"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:hint="Enter Something"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintRight_toLeftOf="@+id/button2"
android:layout_marginLeft="16dp"
android:layout_marginTop="16dp"
android:layout_marginRight="16dp" />
<Button
android:id="@+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button"
app:layout_constraintBaseline_toBaselineOf="@+id/editText2"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintLeft_toRightOf="@+id/editText2"
android:layout_marginLeft="0dp"
android:layout_marginRight="16dp" />
</android.support.constraint.ConstraintLayout>