我想在選擇listFragment A項目後用片段B2替換片段B1。替換片段
@Override
public void onListItemClick(ListView l, View v, int position, long id) {
Integer Position = position;
WebViewerFragment fragment = (WebViewerFragment) getFragmentManager()
.findFragmentById(R.id.detailFragment);
if (Position.equals(0)) {
FragmentManager fm = getFragmentManager();
WebViewerFragment newFragment = new WebViewerFragment();
FragmentTransaction ft = fm.beginTransaction();
ft.replace(R.id.detailFragment, newFragment);
ft.addToBackStack("android");
ft.commit();
} else if (Position.equals(1)) {
FragmentManager fms = getFragmentManager();
WebViewerFragment_II newFragments = new WebViewerFragment_II();
FragmentTransaction fts = fms.beginTransaction();
fts.replace(R.id.detailFragment, newFragments);
fts.addToBackStack("google");
fts.commit();
}
}
它只是替換一次,選擇項目1(位置0)後,應用程序崩潰。
請發送異常的堆棧跟蹤。 – yDelouis