Android 导致java空指针异常的片段教程
所以每当事务执行任何操作时,我都会收到一个空指针错误。我在这里使用Android Studio学习教程Android 导致java空指针异常的片段教程,android,facebook,nullpointerexception,Android,Facebook,Nullpointerexception,所以每当事务执行任何操作时,我都会收到一个空指针错误。我在这里使用Android Studio学习教程 @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); uiHelper = new UiLifecycleHelper(this, callback); uiHelper.onCreate(savedInstanceState
@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();
}
@覆盖
创建时受保护的void(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
uiHelper=新UiLifecycleHelper(此为回调);
uiHelper.onCreate(savedInstanceState);
setContentView(R.layout.activity\u manage\u profile);
//查找用户的个人资料图片自定义查看FACEBOOK
FragmentManager fm=getSupportFragmentManager();
片段[SPLASH]=fm.findFragmentById(R.id.splashFragment);
片段[SELECTION]=fm.findFragmentById(R.id.selectionFragment);
FragmentTransaction=fm.beginTransaction();
for(int i=0;i
到目前为止,我唯一不得不偏离教程的地方是类定义。它被设置为public class ManageProfileActivity extends FragmentActivity实现SelectionFragment.OnFragmentInteractionListener,SplashFragment.OnFragmentInteractionListener{
,而不是public class ManageProfileActivity extends FragmentActivity
该应用程序将生成并运行事务。hide(fragments[i]);注释掉,但它只是将这些片段重叠在一起。你有NullPointerException的堆栈跟踪吗?它在第一次运行for循环时会断开吗?没有堆栈跟踪(我将努力获得一个)它在第一次循环中就中断了。我想我在运行Facebook测试应用程序时遇到了问题。我想我只是尝试创建自己的登录流。对片段进行一些空检查[]。我觉得splashFragment/selectionFragment可能有问题。请确保已导入片段的支持库。