我想要使用下面的代碼來打開Fragment
是在另一個片段,但是給我一個空指針異常無故。Android的碎片NullPointerException錯誤
Fragment newFragment = new SecondFragment();
// consider using Java coding conventions (upper char class names!!!)
FragmentTransaction transaction = getFragmentManager().beginTransaction();
// Replace whatever is in the fragment_container view with this fragment,
// and add the transaction to the back stack
transaction.replace(R.id.menuitem_detail_container, newFragment);
transaction.addToBackStack(null);
// Commit the transaction
transaction.commit();
這段代碼是一個基本的onItemClickListener
內onCreateView
方法中的一個片段內(android.support.v4.app.Fragment
)
什麼我可能是做錯了任何想法?
NPE被拋出的線是什麼? – panini