private static final String FRAGMENT_LEFT_MENU = "fragment_left_menu";
private static final String FRAGMENT_CONTENT = "fragment_content";
/**
* 出社會fragment,將fragment數據填充給布局文件
*/
private void initFragment() {
FragmentManager fm=getSupportFragmentManager();
FragmentTransaction transaction=fm.beginTransaction();
transaction.replace(R.id.fl_left_menu,new LeftMenuFragment(),FRAGMENT_LEFT_MENU);
transaction.replace(R.id.fl_main_menu,new ContentFragment(),FRAGMENT_CONTENT);
transaction.commit();
LeftMenuFragment lefFragment=(LeftMenuFragment) fm.findFragmentByTag(FRAGMENT_LEFT_MENU);
}
lefFragment輸出結果為null 怎麼辦
我自己解決了 fm必須fm.executePendingTransactions();才能讀取得到數據