Android FragmentTransaction commit already called
My ERROR : java.lang.IllegalStateException: commit already called My CODE: final FragmentTransaction fragmentTransaction =getFragmentManager().beginTransaction(); f1_fragment = new F1_Fragments(); f2_fragment = new F2_Fragments(); listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { parent.getItemAtPosition(position); if(position==0){ fragmentTransaction.replace(android.R.id.content, f1_fragment); }else{ fragmentTransaction.replace(android.R.id.content, f2_fragment); }