私のアプリの断片の1つにedittextがあり、それをクリックするたびにキーボードが現れ、断片の中のすべてのコンテンツがedittextを含めて消えます。私はまだキーボードに入力することができます、そして、私が戻るボタンを押した後、すべてが戻って、私が入力したものが編集テキストに表示されますが、すべてを消してしまうのを止めるには?Android EditTextキーボードの断片化が消える
以下は、フラグメントとそのレイアウトのコードです。
フラグメント:
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);
}
}
レイアウト:
<?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>