title: java.lang.NullPointerException: Attempt to invoke virtual method 'int android.view.View.getImportantForAccessibility()' using BaseAdapter
body: <p>How to get mp3 files from a folder in SDcard and show in custom listview using BaseAdapter and also want to play the song on Item Click.</p>
  
  <p>I am getting the mp3 files from a SDCard particular folder using base adapter.Getting the mp3 files but unable to add to custom base Adapter.
  I am getting this exception : </p>
  
  <blockquote>
    <p>java.lang.NullPointerException: Attempt to invoke virtual method 'int
    android.view.View.getImportantForAccessibility()' on a null object
    reference using BaseAdapter.</p>
  </blockquote>
  
  <p>Below is my Fragment:</p>
  
  <pre><code> ListView lv_recordersList;
   private ListViewAdapter adapter;
   ProgressDialog mProgressDialog;
   private List&lt;String&gt; myList;
   File file;
  
  
          public View onCreateView(LayoutInflater inflater, ViewGroup container,
                  Bundle savedInstanceState) {
              // TODO Auto-generated method stub
  
              View v = inflater.inflate(R.layout.frag_recorders_list, null);
              lv_recordersList = (ListView) v.findViewById(R.id.lv_recordersList);
  
              myList = new ArrayList&lt;String&gt;();
  
  
              new DownloadJSON().execute();
  
  
              return v;
          }
  
  
  
      public class DownloadJSON extends AsyncTask&lt;Void, Void, Void&gt;{
  
          @Override
          protected void onPreExecute() {
              // TODO Auto-generated method stub
              super.onPreExecute();
  
              mProgressDialog = new ProgressDialog(getActivity());
              //mProgressDialog.setTitle("PlugLeads");
              mProgressDialog.setMessage("Loading...");
              mProgressDialog.setIndeterminate(false);
              mProgressDialog.show();
  
          }
  
  
          @Override
          protected Void doInBackground(Void... params) {
              // TODO Auto-generated method stub
  
              File directory = Environment.getExternalStorageDirectory();
              file = new File(directory + "/Plugleads");
              File list[] = file.listFiles();
  
              for (int i = 0; i &lt; list.length; i++) {
                  // if(checkExtension( list[i].getName())
                  if (checkExtension(list[i].getName())) {
                      myList.add(list[i].getName());
                  }
              }
  
  
              return null;
          }
  
  
  
  
          @Override
          protected void onPostExecute(Void result) {
              // TODO Auto-generated method stub
              super.onPostExecute(result);
              //listview = (ListView) findViewById(R.id.listview);
              // Pass the results into ListViewAdapter.java
              adapter = new ListViewAdapter(getActivity(), myList);
              // Set the adapter to the ListView
              lv_recordersList.setAdapter(adapter);
              // Close the progressdialog
              mProgressDialog.dismiss();
          }
  
  
  
          private boolean checkExtension(String fileName) {
              String ext = getFileExtension(fileName);
              if (ext == null)
                  return false;
              try {
                  if (SupportedFileFormat.valueOf(ext.toUpperCase()) != null) {
                      return true;
                  }
              } catch (IllegalArgumentException e) {
                  return false;
              }
              return false;
          }
  
          public String getFileExtension(String fileName) {
              int i = fileName.lastIndexOf('.');
              if (i &gt; 0) {
                  return fileName.substring(i + 1);
              } else
                  return null;
          }
  
  
      }
  </code></pre>
  
  <p>This is my CustomBaseAdapter</p>
  
  <pre><code>public class ListViewAdapter extends BaseAdapter{
  
  Context context;
  LayoutInflater inflater;
  private List&lt;String&gt; myListp;
  
  public ListViewAdapter(Context context,
          List&lt;String&gt; myList) {
      this.context = context;
      myListp= myList;
  
  }
  
  @Override
  public int getCount() {
      // TODO Auto-generated method stub
      return myListp.size();
  }
  
  @Override
  public Object getItem(int position) {
      // TODO Auto-generated method stub
      return myListp.get(position);
  }
  
  @Override
  public long getItemId(int position) {
      // TODO Auto-generated method stub
      return position;
  }
  
  @Override
  public View getView(int position, View convertView, ViewGroup parent) {
      // TODO Auto-generated method stub
  
      ImageView img_recorders_listitem;
      TextView tv_recorders_listitem;
  
      inflater = (LayoutInflater) context
              .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
  
  
      View itemView = inflater.inflate(R.layout.frag_recorders_listitem, parent, false);
  
      img_recorders_listitem = (ImageView) itemView.findViewById(R.id.img_recorders_listitem);
      tv_recorders_listitem = (TextView) itemView.findViewById(R.id.tv_recorders_listitem);
  
  
      return convertView;
  }
  </code></pre>
  
  <p>My Logcat</p>
  
  <pre><code> 06-09 10:30:43.378: E/AndroidRuntime(21491): FATAL EXCEPTION: main
          06-09 10:30:43.378: E/AndroidRuntime(21491): Process: com.plugleads.feedbackform, PID: 21491
          06-09 10:30:43.378: E/AndroidRuntime(21491): java.lang.NullPointerException: Attempt to invoke virtual method 'int android.view.View.getImportantForAccessibility()' on a null object reference
          06-09 10:30:43.378: E/AndroidRuntime(21491):    at android.widget.AbsListView.obtainView(AbsListView.java:2363)
          06-09 10:30:43.378: E/AndroidRuntime(21491):    at android.widget.ListView.makeAndAddView(ListView.java:1864)
          06-09 10:30:43.378: E/AndroidRuntime(21491):    at android.widget.ListView.fillDown(ListView.java:698)
          06-09 10:30:43.378: E/AndroidRuntime(21491):    at android.widget.ListView.fillFromTop(ListView.java:759)
          06-09 10:30:43.378: E/AndroidRuntime(21491):    at android.widget.ListView.layoutChildren(ListView.java:1673)
          06-09 10:30:43.378: E/AndroidRuntime(21491):    at android.widget.AbsListView.onLayout(AbsListView.java:2151)
          06-09 10:30:43.378: E/AndroidRuntime(21491):    at android.view.View.layout(View.java:15689)
          06-09 10:30:43.378: E/AndroidRuntime(21491):    at android.view.ViewGroup.layout(ViewGroup.java:5040)
          06-09 10:30:43.378: E/AndroidRuntime(21491):    at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1703)
          06-09 10:30:43.378: E/AndroidRuntime(21491):    at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1557)
          06-09 10:30:43.378: E/AndroidRuntime(21491):    at android.widget.LinearLayout.onLayout(LinearLayout.java:1466)
          06-09 10:30:43.378: E/AndroidRuntime(21491):    at android.view.View.layout(View.java:15689)
          06-09 10:30:43.378: E/AndroidRuntime(21491):    at android.view.ViewGroup.layout(ViewGroup.java:5040)
          06-09 10:30:43.378: E/AndroidRuntime(21491):    at android.widget.FrameLayout.layoutChildren(FrameLayout.java:579)
          06-09 10:30:43.378: E/AndroidRuntime(21491):    at android.widget.FrameLayout.onLayout(FrameLayout.java:514)
          06-09 10:30:43.378: E/AndroidRuntime(21491):    at android.view.View.layout(View.java:15689)
          06-09 10:30:43.378: E/AndroidRuntime(21491):    at android.view.ViewGroup.layout(ViewGroup.java:5040)
          06-09 10:30:43.378: E/AndroidRuntime(21491):    at android.support.v4.widget.DrawerLayout.onLayout(DrawerLayout.java:1043)
          06-09 10:30:43.378: E/AndroidRuntime(21491):    at android.view.View.layout(View.java:15689)
          06-09 10:30:43.378: E/AndroidRuntime(21491):    at android.view.ViewGroup.layout(ViewGroup.java:5040)
          06-09 10:30:43.378: E/AndroidRuntime(21491):    at android.widget.FrameLayout.layoutChildren(FrameLayout.java:579)
          06-09 10:30:43.378: E/AndroidRuntime(21491):    at android.widget.FrameLayout.onLayout(FrameLayout.java:514)
          06-09 10:30:43.378: E/AndroidRuntime(21491):    at android.view.View.layout(View.java:15689)
          06-09 10:30:43.378: E/AndroidRuntime(21491):    at android.view.ViewGroup.layout(ViewGroup.java:5040)
          06-09 10:30:43.378: E/AndroidRuntime(21491):    at android.support.v7.internal.widget.ActionBarOverlayLayout.onLayout(ActionBarOverlayLayout.java:437)
          06-09 10:30:43.378: E/AndroidRuntime(21491):    at android.view.View.layout(View.java:15689)
          06-09 10:30:43.378: E/AndroidRuntime(21491):    at android.view.ViewGroup.layout(ViewGroup.java:5040)
          06-09 10:30:43.378: E/AndroidRuntime(21491):    at android.widget.FrameLayout.layoutChildren(FrameLayout.java:579)
          06-09 10:30:43.378: E/AndroidRuntime(21491):    at android.widget.FrameLayout.onLayout(FrameLayout.java:514)
          06-09 10:30:43.378: E/AndroidRuntime(21491):    at android.view.View.layout(View.java:15689)
          06-09 10:30:43.378: E/AndroidRuntime(21491):    at android.view.ViewGroup.layout(ViewGroup.java:5040)
          06-09 10:30:43.378: E/AndroidRuntime(21491):    at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1703)
          06-09 10:30:43.378: E/AndroidRuntime(21491):    at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1557)
          06-09 10:30:43.378: E/AndroidRuntime(21491):    at android.widget.LinearLayout.onLayout(LinearLayout.java:1466)
          06-09 10:30:43.378: E/AndroidRuntime(21491):    at android.view.View.layout(View.java:15689)
          06-09 10:30:43.378: E/AndroidRuntime(21491):    at android.view.ViewGroup.layout(ViewGroup.java:5040)
          06-09 10:30:43.378: E/AndroidRuntime(21491):    at android.widget.FrameLayout.layoutChildren(FrameLayout.java:579)
          06-09 10:30:43.378: E/AndroidRuntime(21491):    at android.widget.FrameLayout.onLayout(FrameLayout.java:514)
          06-09 10:30:43.378: E/AndroidRuntime(21491):    at android.view.View.layout(View.java:15689)
          06-09 10:30:43.378: E/AndroidRuntime(21491):    at android.view.ViewGroup.layout(ViewGroup.java:5040)
          06-09 10:30:43.378: E/AndroidRuntime(21491):    at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:2116)
          06-09 10:30:43.378: E/AndroidRuntime(21491):    at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1873)
          06-09 10:30:43.378: E/AndroidRuntime(21491):    at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1084)
          06-09 10:30:43.378: E/AndroidRuntime(21491):    at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:5990)
          06-09 10:30:43.378: E/AndroidRuntime(21491):    at android.view.Choreographer$CallbackRecord.run(Choreographer.java:767)
          06-09 10:30:43.378: E/AndroidRuntime(21491):    at android.view.Choreographer.doCallbacks(Choreographer.java:580)
          06-09 10:30:43.378: E/AndroidRuntime(21491):    at android.view.Choreographer.doFrame(Choreographer.java:550)
          06-09 10:30:43.378: E/AndroidRuntime(21491):    at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:753)
          06-09 10:30:43.378: E/AndroidRuntime(21491):    at android.os.Handler.handleCallback(Handler.java:739)
          06-09 10:30:43.378: E/AndroidRuntime(21491):    at android.os.Handler.dispatchMessage(Handler.java:95)
          06-09 10:30:43.378: E/AndroidRuntime(21491):    at android.os.Looper.loop(Looper.java:135)
          06-09 10:30:43.378: E/AndroidRuntime(21491):    at android.app.ActivityThread.main(ActivityThread.java:5343)
          06-09 10:30:43.378: E/AndroidRuntime(21491):    at java.lang.reflect.Method.invoke(Native Method)
          06-09 10:30:43.378: E/AndroidRuntime(21491):    at java.lang.reflect.Method.invoke(Method.java:372)
          06-09 10:30:43.378: E/AndroidRuntime(21491):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:905)
          06-09 10:30:43.378: E/AndroidRuntime(21491):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:700)
  </code></pre>
  
  <p>Please Help me.Thaks in advance...</p>