title: ListView.addHeaderView(View) Crash on Api 11 and API12
body: <p>i have a List view that i need to add a header view to it and a footer view,</p>
  
  <p>it runs perfectly on any api else 11 &amp; 12.</p>
  
  <p>this is the Log cat  </p>
  
  <pre><code>java.lang.IllegalStateException: Cannot add header view to list -- setAdapter has already been called.
  11-13 11:21:13.717: E/AndroidRuntime(583): at     android.widget.ListView.addHeaderView(ListView.java:255)
  11-13 11:21:13.717: E/AndroidRuntime(583): at MediaFragment.setAdapter_(MediaFragment.java:1041)
  11-13 11:21:13.717: E/AndroidRuntime(583): at    MediaFragment.JsonObjectOnSuccess(MediaFragment.java:991)
  11-13 11:21:13.717: E/AndroidRuntime(583): at MediaFragment.GetCache_db(MediaFragment.java:2074)
  11-13 11:21:13.717: E/AndroidRuntime(583): at DataBaseAdapter$GetAsyncTask.onPostExecute(DataBaseAdapter.java:253)
  11-13 11:21:13.717: E/AndroidRuntime(583): at DataBaseAdapter$GetAsyncTask.onPostExecute(DataBaseAdapter.java:1)
  13 11:21:13.717: E/AndroidRuntime(583): at android.os.AsyncTask.finish(AsyncTask.java:590)
   11-13 11:21:13.717: E/AndroidRuntime(583): at android.os.AsyncTask.access$600(AsyncTask.java:149)
    11-13 11:21:13.717: E/AndroidRuntime(583): at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:603)
   11-13 11:21:13.717: E/AndroidRuntime(583): at android.os.Handler.dispatchMessage(Handler.java:99)
   11-13 11:21:13.717: E/AndroidRuntime(583): at android.os.Looper.loop(Looper.java:132)
   11-13 11:21:13.717: E/AndroidRuntime(583): at android.app.ActivityThread.main(ActivityThread.java:4025)
         11-13 11:21:13.717: E/AndroidRuntime(583): at java.lang.reflect.Method.invokeNative(Native Method)
     11-13 11:21:13.717: E/AndroidRuntime(583): at java.lang.reflect.Method.invoke(Method.java:491)
   11-13 11:21:13.717: E/AndroidRuntime(583): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:841)
   11-13 11:21:13.717: E/AndroidRuntime(583): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:599)
    11-13 11:21:13.717: E/AndroidRuntime(583): at dalvik.system.NativeStart.main(Native Method)
  </code></pre>
  
  <p>and this is my Code :</p>
  
  <pre><code>    listview = (ListView) view.findViewById(R.id.fragmentListView);
  
      headListView = (View) mActivity.getLayoutInflater().inflate(
              R.layout.headlistview,listview,false);
      footerListview = (View) mActivity.getLayoutInflater().inflate(
              R.layout.media_footer,listview,false);
  
  
      listview.addHeaderView(headListView, null, false);
      listview.addFooterView(footerListview, null, false);
  
      listview.setAdapter(MediaAdapter);
      MediaAdapter.notifyDataSetChanged();
      listview.onRestoreInstanceState(state);
  </code></pre>