我无法从fragmentTransaction中删除片段。我想删除我在oncreate方法中添加的片段。以下是我的代码:
fragmentManager = getSupportFragmentManager();
fragmentTransaction = fragmentManager.beginTransaction();
firstFragment = new FirstFragment();
secondFragment = new SecondFragment();
fragmentTransaction
.add(R.id.container_first, firstFragment)
.add(R.id.container_second, secondFragment)
.commit();
VideoView video = (VideoView) findViewById(R.id.videoView1);
video.setVideoURI(Uri.parse("http://192.168.43.10/video.mp4"));
video.start();
Button btn = (Button) findViewById(R.id.button1);
btn.setOnClickListener(new OnClickListener(){
@Override
public void onClick(View arg0) {
Toast.makeText(MainActivity.this, "im here", 1500).show();
FragmentTransaction ft = fragmentManager.beginTransaction();
ft.remove(secondFragment);
ft.commit();
}});