title: Problem in viewing in custom-listview in android
body: <p>I wanted to display some images from a folder form mobile SD card. I written an adapter to display image and file name.</p>
  
  <p>Unfortunately the app is not showing the list view. What's wrong with the code please help me out.</p>
  
  <p>This is listview</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:app="http://schemas.android.com/apk/res-auto"
      xmlns:tools="http://schemas.android.com/tools"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      tools:context=".MainActivity"&gt;
  
      &lt;ListView
          android:id="@+id/listview"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"&gt;
      &lt;/ListView&gt;
  
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>This is my row to display in listview</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:app="http://schemas.android.com/apk/res-auto"
      android:layout_width="match_parent"
      android:layout_height="match_parent"&gt;
  
      &lt;ImageView
          android:id="@+id/imageView"
          android:layout_width="45dp"
          android:layout_height="45dp"
          android:layout_alignParentTop="true"
          android:layout_marginLeft="15dp"
          android:layout_marginTop="15dp"
          app:srcCompat="@mipmap/ic_launcher" /&gt;
  
      &lt;TextView
          android:id="@+id/textView"
          android:layout_width="307dp"
          android:layout_height="wrap_content"
          android:layout_alignParentStart="true"
          android:layout_alignParentTop="true"
          android:layout_marginStart="73dp"
          android:layout_marginTop="25dp"
          android:text="TextView" /&gt;
  
  &lt;/RelativeLayout&gt;
  </code></pre>
  
  <p>My MainActivity Code</p>
  
  <pre><code>public class MainActivity extends AppCompatActivity{
  
      final String str = Environment.getExternalStorageDirectory().getAbsolutePath()+"/WhatsApp/Media/.Statuses";
      File f = new File(str);
      ListView listView;
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
          File[] files = listFiles();
          String[] fileNames = new String[files.length];
          String[] filePaths = new String[files.length];
  
          for(int i=0;i&lt;files.length;i++){
              fileNames[i]=files[i].getName();
              filePaths[i]=files[i].getAbsolutePath();
          }
  
          System.out.println("files::: " + files.length);
          System.out.println("fileNamesfileNames::: " + fileNames.length);
          System.out.println("filePathsfilePaths::: " + filePaths.length);
  
  
          listView = (ListView) findViewById(R.id.listview);
          MyAdapter adapter = new MyAdapter(this,fileNames,filePaths);
          listView.setAdapter(adapter);
      }
  
      public File[] listFiles() {
          try {
              return f.listFiles(new FilenameFilter() {
                  @Override
                  public boolean accept(File dir, String name) {
                      return name.endsWith(".jpg");
                  }
              });
          } catch (Exception e) {
              e.printStackTrace();
          }
          return null;
      }
  }
  
  class MyAdapter extends BaseAdapter{
  
      Context context;
      String[] rFiles;
      String[] rPaths;
  
      private static LayoutInflater inflater = null;
  
      MyAdapter(Context ctx,String[] fileNames,String[] filePaths){
          context = ctx;
          rFiles = fileNames;
          rPaths = filePaths;
          inflater = (LayoutInflater) ctx.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
      }
  
      @Override
      public int getCount() {
          return 0;
      }
  
      @Override
      public Object getItem(int position) {
          return null;
      }
  
  
      @Override
      public long getItemId(int position) {
          return position;
      }
  
      @Override
      public View getView(int position, View view, ViewGroup parent) {
          View vi = view;
          if(view==null){
              vi = inflater.inflate(R.layout.row,null);
          }
          ImageView images  = vi.findViewById(R.id.imageView);
          TextView textView  = vi.findViewById(R.id.textView);
  
  
          Bitmap bmp = BitmapFactory.decodeFile(rPaths[position]);
          images.setImageBitmap(bmp);
          textView.setText(rFiles[position]);
  
          System.out.println(vi);
  
          return vi;
      }
  }
  </code></pre>
  
  <p>Files are reading but.. its not displaying the list... 
  please help me out with this.</p>