易采站长站为您分析Android开发之简单文件管理器实现方法,简单实现了Android的文件目录查看,文件重命名,打开,删除等功能,需要的朋友可以参考下
本文实例讲述了Android开发之简单文件管理器实现方法。,具体如下:
这里运用Java I/O、ListActivity、Dialog、Bitmap等实现简单文件管理器,可以查看目录文件,修改文件名,删除文件,打开文件。比较简单,直接看代码:
先看布局文件:
layout/main.xml
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
android:id="@android:id/list"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
文件列表布局:
layout/file.xml
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
android:id="@+id/imageView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="14sp">
修改文件名对话框布局文件:
layout/rename_dialog.xml
xmlns:android="http://www.easck.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
android:id="@+id/editText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
/>