java.lang.IllegalStateException: commit already called
at androidx.fragment.app.BackStackRecord.commitInternal(BackStackRecord.java:669)
at androidx.fragment.app.BackStackRecord.commit(BackStackRecord.java:637)
at com.example.ui.PACK.SUBPACK.subpack$4.onClick(subpack.java:94)
at android.view.View.performClick(View.java:6600)
at android.view.View.performClickInternal(View.java:6577)
at android.view.View.access$3100(View.java:781)
at android.view.View$PerformClick.run(View.java:25912)
at android.os.Handler.handleCallback(Handler.java:873)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6923)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:870)
这是我的JAVA代码:
public class subpack extends Fragment { private FragmentTransaction ft; @Override public View onCreateView(LayoutInflater inflater, ViewGroup container,Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_subpack, container, false); ft = getFragmentManager().beginTransaction(); //TXT LUNES EVENT LISTENER txt_lunes.setOnClickListener(new View.OnClickListener(){ @Override public void onClick(View v){ fragment = new lunes_gestionar(); ft.replace(R.id.fragment,fragment).setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN).commit(); } }); //TXT MARTES EVENT LISTENER txt_martes.setOnClickListener(new View.OnClickListener(){ @Override public void onClick(View v){ fragment = new martes_gestionar(); ft.replace(R.id.fragment,fragment).setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN).commit(); } });
描述:
我有一个带有另一个片段的片段,在其中TEXT VIEWS(星期一,星期二)用于通过Fragment Transaction
更改片段。问题是当我第二次单击此文本视图时。我该如何解决?非常感谢您阅读!