片段教程导致java nullpointer异常

时间:2014-07-16 16:54:49

标签: android facebook nullpointerexception

所以当事务完成任何事情时,我总是得到一个空指针错误。我在这里使用Android Studio https://developers.facebook.com/docs/android/scrumptious/authenticate了解教程。

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    uiHelper = new UiLifecycleHelper(this, callback);
    uiHelper.onCreate(savedInstanceState);

    setContentView(R.layout.activity_manage_profile);
    // Find the user's profile picture custom view FACEBOOK
    FragmentManager fm = getSupportFragmentManager();
    fragments[SPLASH] = fm.findFragmentById(R.id.splashFragment);
    fragments[SELECTION] = fm.findFragmentById(R.id.selectionFragment);
    FragmentTransaction transaction = fm.beginTransaction();
    for(int i = 0; i < fragments.length; i++) {
        transaction.hide(fragments[i]);
    }
    transaction.commit();

}

到目前为止,我唯一不得不偏离教程的地方是在课程定义中。它设置为public class ManageProfileActivity extends FragmentActivity implements SelectionFragment.OnFragmentInteractionListener, SplashFragment.OnFragmentInteractionListener {而不是public class ManageProfileActivity extends FragmentActivity

应用程序将使用transaction.hide(fragments [i])构建并运行良好;注释掉了,但它只是将碎片叠加在一起。

0 个答案:

没有答案