title: Android Nullpointer Exception onQueryTextChange when switch fragment
body: <p>I have the following problem:</p>
  
  <p>When I switch from fragment1 to fragment2 I get a nullpointer exception.<br>
  fragment2 has a searchview with a filter. Error occurs of some mobile pones and I dont know why.</p>
  
  <p>The app crashed in mListAdapter.getFilter().filter there:</p>
  
  <pre><code>        @Override
  public boolean onQueryTextChange(String newText) {
      mListAdapter.getFilter().filter(newText);
      lv.setAdapter(mListAdapter);
  
      return false;
  }
  </code></pre>
  
  <p>Here is the Logcat:</p>
  
  <pre><code>08-25 09:18:25.840: E/AndroidRuntime(1430): FATAL EXCEPTION: main
  08-25 09:18:25.840: E/AndroidRuntime(1430): java.lang.NullPointerException
  08-25 09:18:25.840: E/AndroidRuntime(1430):     at com.kansosystem.fragments.FragmentList.onQueryTextChange(FragmentList.java:291)
  08-25 09:18:25.840: E/AndroidRuntime(1430):     at android.widget.SearchView.onTextChanged(SearchView.java:1154)
  08-25 09:18:25.840: E/AndroidRuntime(1430):     at android.widget.SearchView.access$2000(SearchView.java:92)
  08-25 09:18:25.840: E/AndroidRuntime(1430):     at android.widget.SearchView$11.onTextChanged(SearchView.java:1623)
  08-25 09:18:25.840: E/AndroidRuntime(1430):     at android.widget.TextView.sendOnTextChanged(TextView.java:7079)
  08-25 09:18:25.840: E/AndroidRuntime(1430):     at android.widget.TextView.setText(TextView.java:3550)
  08-25 09:18:25.840: E/AndroidRuntime(1430):     at android.widget.TextView.setText(TextView.java:3405)
  08-25 09:18:25.840: E/AndroidRuntime(1430):     at android.widget.EditText.setText(EditText.java:80)
  08-25 09:18:25.840: E/AndroidRuntime(1430):     at android.widget.TextView.setText(TextView.java:3380)
  08-25 09:18:25.840: E/AndroidRuntime(1430):     at android.widget.TextView.onRestoreInstanceState(TextView.java:3280)
  08-25 09:18:25.840: E/AndroidRuntime(1430):     at android.view.View.dispatchRestoreInstanceState(View.java:11910)
  08-25 09:18:25.840: E/AndroidRuntime(1430):     at android.view.ViewGroup.dispatchRestoreInstanceState(ViewGroup.java:2590)
  08-25 09:18:25.840: E/AndroidRuntime(1430):     at android.view.ViewGroup.dispatchRestoreInstanceState(ViewGroup.java:2590)
  08-25 09:18:25.840: E/AndroidRuntime(1430):     at android.view.ViewGroup.dispatchRestoreInstanceState(ViewGroup.java:2590)
  08-25 09:18:25.840: E/AndroidRuntime(1430):     at android.view.ViewGroup.dispatchRestoreInstanceState(ViewGroup.java:2590)
  08-25 09:18:25.840: E/AndroidRuntime(1430):     at android.view.View.restoreHierarchyState(View.java:11888)
  08-25 09:18:25.840: E/AndroidRuntime(1430):     at com.android.internal.view.menu.MenuBuilder.restoreActionViewStates(MenuBuilder.java:358)
  08-25 09:18:25.840: E/AndroidRuntime(1430):     at com.android.internal.policy.impl.PhoneWindow.preparePanel(PhoneWindow.java:417)
  08-25 09:18:25.840: E/AndroidRuntime(1430):     at com.android.internal.policy.impl.PhoneWindow.invalidatePanelMenu(PhoneWindow.java:747)
  08-25 09:18:25.840: E/AndroidRuntime(1430):     at android.app.Activity.invalidateOptionsMenu(Activity.java:2595)
  08-25 09:18:25.840: E/AndroidRuntime(1430):     at android.app.FragmentManagerImpl.invalidateOptionsMenu(FragmentManager.java:1950)
  08-25 09:18:25.840: E/AndroidRuntime(1430):     at android.app.Fragment.setHasOptionsMenu(Fragment.java:901)
  08-25 09:18:25.840: E/AndroidRuntime(1430):     at com.kansosystem.fragments.FragmentList.onCreate(FragmentList.java:53)
  08-25 09:18:25.840: E/AndroidRuntime(1430):     at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:796)
  08-25 09:18:25.840: E/AndroidRuntime(1430):     at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1035)
  08-25 09:18:25.840: E/AndroidRuntime(1430):     at android.app.BackStackRecord.run(BackStackRecord.java:635)
  08-25 09:18:25.840: E/AndroidRuntime(1430):     at android.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1397)
  08-25 09:18:25.840: E/AndroidRuntime(1430):     at android.app.FragmentManagerImpl$1.run(FragmentManager.java:426)
  08-25 09:18:25.840: E/AndroidRuntime(1430):     at android.os.Handler.handleCallback(Handler.java:615)
  08-25 09:18:25.840: E/AndroidRuntime(1430):     at android.os.Handler.dispatchMessage(Handler.java:92)
  08-25 09:18:25.840: E/AndroidRuntime(1430):     at android.os.Looper.loop(Looper.java:137)
  08-25 09:18:25.840: E/AndroidRuntime(1430):     at android.app.ActivityThread.main(ActivityThread.java:4745)
  08-25 09:18:25.840: E/AndroidRuntime(1430):     at java.lang.reflect.Method.invokeNative(Native Method)
  08-25 09:18:25.840: E/AndroidRuntime(1430):     at java.lang.reflect.Method.invoke(Method.java:511)
  08-25 09:18:25.840: E/AndroidRuntime(1430):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
  08-25 09:18:25.840: E/AndroidRuntime(1430):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
  08-25 09:18:25.840: E/AndroidRuntime(1430):     at dalvik.system.NativeStart.main(Native Method)
  </code></pre>