使用ListView来显示文件列表,初始文件目录是"/"。 点击ListView中一个条目时的动作: File file=new File(paths.get(position)); if(file.isDirectory()) { getFileDir(paths.get(position)); } getFileDir方法: private void getFileDir(String filePath) { /* 设置目前所在路径 */ mPath.setText(filePath); items=new ArrayList<String>(); paths=new ArrayList<String>(); File f=new File(filePath); File[] files=f.listFiles(); if(!filePath.equals(rootPath)) { /* 第一笔设置为[回到根目录] */ items.add("Back to "+rootPath); paths.add(rootPath); /* 第二笔设置为[回上层] */ items.add("Back to ../"); paths.add(f.getParent()); } /* 将所有文件添加ArrayList中 */ for(int i=0;i<files.length;i++) { File file=files[i]; items.add(file.getName()); paths.add(file.getPath()); } /* 声明一ArrayAdapter,使用file_row这个Layout, 并将Adapter设置给此ListActivity */ ArrayAdapter<String> fileList = new ArrayAdapter<String>(this,R.layout.file_row, items); setListAdapter(fileList); } 使用decodeFile()方法加载手机磁盘里的图片文件: mImageView = (ImageView)findViewById(R.id.mImageView); File f=new File(fileName); if(f.exists()) { /* 产生Bitmap对象,并放入mImageView中 */ Bitmap bm = BitmapFactory.decodeFile(fileName); mImageView.setImageBitmap(bm); }