Android 该片段不会更新EditText的内容

Android 该片段不会更新EditText的内容,android,android-edittext,fragment,Android,Android Edittext,Fragment,我有一个碎片 public class LoginFragment extends Fragment EditText matricula; public LoginFragment() { } public static LoginFragment newInstace(String param1, String param2){ LoginFragment fragment = new LoginFragment();

我有一个碎片

public class LoginFragment extends Fragment 

    EditText matricula;

    public LoginFragment() {

    }

    public static LoginFragment newInstace(String param1, String param2){
        LoginFragment fragment = new LoginFragment();
        return fragment;
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
       final View v = inflater.inflate(R.layout.fragment_login, container, false);
        matricula = v.findViewById(R.id.matricula);
        final Button ingresar = (Button)v.findViewById(R.id.ingresar);

       ingresar.setOnClickListener(new View.OnClickListener(){

           @Override
           public void onClick(View view) {
               Toast.makeText(getActivity(), matricula.getText().toString(), Toast.LENGTH_SHORT).show();
           }
       });
        return v;
            }
我的主要活动是什么

public class MainActivity {
LoginFragment loginFragment;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        loginFragment = new LoginFragment();
      getSupportFragmentManager().beginTransaction().add(R.id.interfaceSesion,loginFragment).commit();
    }
}
但当我点击“Ingrear”按钮时,Toast会抛出EditText的起始值 我改变了文本

这里是XLM片段

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/interfaceSesion"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".LoginFragment">

    <EditText
        android:id="@+id/matricula"
        android:layout_width="200dp"
        android:layout_height="wrap_content"
        android:ems="10"
        android:hint="@string/matricula"
        android:importantForAutofill="no"
        android:inputType="number"
        android:maxLength="5"
        android:text="@string/asd"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="0.497"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintVertical_bias="0.144" />

    <Button
        android:id="@+id/ingresar"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/ingresar"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/password"
        app:layout_constraintVertical_bias="0.095" />

</androidx.constraintlayout.widget.ConstraintLayout>


如果有人需要更多信息,请毫不犹豫地与我联系,让我在几天内无法解决。我将非常感激

请向我们展示您的xml代码fragmentReady,已更新!当你关闭应用程序并重新启动时,会发生这种情况吗?或者如果你从Android Studio应用更改,会发生这种情况吗?因为从我的角度来看,它工作正常。可能是你刚刚从Android Studio应用更改,只是因为它只显示预填充字符。是的,我完全重新编辑了项目,我走得很好,我真的很感谢你的时间,我可以继续工作。