我在尝试启动FragmentActivity时不断获得NullPointer。
这是nullpointer im getting。
09-05 14:44:21.550: ERROR/AndroidRuntime(19409): FATAL EXCEPTION: main
09-05 14:44:21.550: ERROR/AndroidRuntime(19409): java.lang.NullPointerException
09-05 14:44:21.550: ERROR/AndroidRuntime(19409): at com.fttech.youtubeReaults.searchYoutube(youtubeReaults.java:182)
09-05 14:44:21.550: ERROR/AndroidRuntime(19409): at com.fttech.youtubeReaults.onActivityCreated(youtubeReaults.java:59)
09-05 14:44:21.550: ERROR/AndroidRuntime(19409): at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:760)
09-05 14:44:21.550: ERROR/AndroidRuntime(19409): at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:933)
09-05 14:44:21.550: ERROR/AndroidRuntime(19409): at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:578)
09-05 14:44:21.550: ERROR/AndroidRuntime(19409): at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1219)
09-05 14:44:21.550:ERROR / AndroidRuntime(19409):在android.support.v4.app.FragmentManagerImpl $ 1.run(FragmentManager.java:380) 09-05 14:44:21.550:ERROR / AndroidRuntime(19409):在android.os.Handler.handleCallback(Handler.java:587)
NullPointer指着我......
@Override
public void onActivityCreated(Bundle state){
super.onActivityCreated(state);
search = AccessibleYouTube_Fragment.search;
((TextView) getView().findViewById(R.id.textViewSearchResultTitle))
.setText("Captioned search results for " + search);
//NullPointer is pointing me to this line
ArrayList<YouTubeResult> ytResults = searchYoutube(search);
我在这里做错了吗?
答案 0 :(得分:1)
你的代码中有人为空,你试图访问它......
在Nullpointer上我建议你.......................
System.out.println(“搜索”+搜索); ..
。并打印AccessibleYouTube_Fragment.search,还有textview有些东西是空的.................