如何在android中获取当前加载的片段标记

时间:2016-08-17 13:24:53

标签: android android-fragments

您好我想在我的应用程序中获取当前加载的片段标记我写下面的代码,但我得到空指针异常为什么我得到空指针异常可以有人帮助我

我的代码: -

intializingPhoneFragments(new SettingsListViewFragment(), "SettingsListViewFragment");


 private void intializingPhoneFragments(Fragment fragment,String tag) {

        try {

            FragmentManager fragmentManager = getSupportFragmentManager();
            FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
            fragmentManager.popBackStack();
            fragmentTransaction.replace(R.id.frame_layout_master, fragment, tag);
            fragmentTransaction.commit();

            Fragment currentFragment = fragmentManager.findFragmentById(R.id.frame_layout_master);
            if(currentFragment.getTag().equals("SettingsListViewFragment")) {
            }
            else {

            }
}

0 个答案:

没有答案