title: android browse files code
body: <p>In the following code i am trying to implement the follwwing browser code <a href="http://www.remwebdevelopment.com/dev/a34/Directory-Browser-Application.html" rel="nofollow">http://www.remwebdevelopment.com/dev/a34/Directory-Browser-Application.html</a></p>
  
  <p>I am just getting a blank text view here as the ouptut and i do not see the browser.What am i doing wrong here</p>
  
  <pre><code> public class File_browse extends Activity {
  private List&lt;String&gt; items = null;
  
  @Override
  public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_file_browse);
      getFiles(new File("/").listFiles());
  }
  
  @Override
  public boolean onCreateOptionsMenu(Menu menu) {
      getMenuInflater().inflate(R.menu.activity_file_browse, menu);
      return true;
  }
  
  protected void onListItemClick(ListView l, View v, int position, long id){
      int selectedRow = (int)id;
      if(selectedRow == 0){
          getFiles(new File("/").listFiles());
      }else{
          File file = new File(items.get(selectedRow));
          if(file.isDirectory()){
              getFiles(file.listFiles());
          }else{
               new AlertDialog.Builder(this)
               .setTitle("This file is not a directory")
               .setNeutralButton("OK", new DialogInterface.OnClickListener(){
                   public void onClick(DialogInterface dialog, int button){
                       //do nothing
                   }
               }).show();
              //Toast.makeText(this, "This file is not a directory" + position, Toast.LENGTH_SHORT).show();
          }
      }
  }
  private void getFiles(File[] files){
      Toast.makeText(this, "In get files" , Toast.LENGTH_SHORT).show();
      items = new ArrayList&lt;String&gt;();
      items.add(getString(R.string.app_name));
      for(File file : files){
          items.add(file.getPath());
      }
      ArrayAdapter&lt;String&gt; fileList = new ArrayAdapter&lt;String&gt;(this,R.layout.file_list_row, items);
      ArrayAdapter adp = new ArrayAdapter(File_browse.this, android.R.layout.simple_list_item_1);
      ListView mainlist = null;
      mainlist.setAdapter(adp);
      mainlist.setTextFilterEnabled(true);
  
  }
  
  
  
  
   }
  </code></pre>
  
  <p>Main.xml</p>
  
  <pre><code> &lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
  xmlns:tools="http://schemas.android.com/tools"
  android:layout_width="match_parent"
  android:layout_height="match_parent" &gt;
  
   &lt;ListView android:id="@android:id/list"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"/&gt;
  
  &lt;!-- &lt;TextView
      android:id="@android:id/empty"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_centerHorizontal="true"
      android:layout_centerVertical="true"
      android:padding="@dimen/padding_medium"
      android:text="@string/hello_world"
      tools:context=".File_browse" /&gt;--&gt;
  
  
   &lt;/RelativeLayout&gt;
  </code></pre>
  
  <p>file_list_row.xml is next to activity_file_browse.xml</p>
  
  <pre><code> &lt;?xml version="1.0" encoding="utf-8"?&gt;
   &lt;TextView android:id="@+id/text1"
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="wrap_content"
  android:layout_height="wrap_content"/&gt;
  </code></pre>