<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" > < android:id="@+id/Txt_Path" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/hello" /> < android:id="@+id/But_Up" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="向上" /> < android:id="@+id/List_View" android:layout_width="match_parent" android:layout_height="wrap_content" > </ListView> </LinearLayout>main.xml
<?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/RelativeLayout1" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" > < android:id="@+id/Txt_Size" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentRight="true" android:layout_alignParentTop="true" android:text="TextView" /> < android:id="@+id/image_ico" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentLeft="true" android:layout_below="@+id/Txt_Size" android:layout_marginLeft="18dp" android:src="@drawable/folder" /> < android:id="@+id/Txt_Name" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignBottom="@+id/image_ico" android:layout_alignParentRight="true" android:text="TextView" /> </RelativeLayout>item.xml
File_Adter Activity activity; List<File> list= LinkedList<File>(); String currPath; Object getItem( getItemId( View getView( View v=View.inflate(activity,R.layout.item, TextView Txt_Name= TextView Txt_Size= ImageView img= File f= File dir= File[] subFiles= (subFiles!= currPath= .activity= bmp_folder=BitmapFactory.decodeResource(activity.getResources(),R.drawable.folder); bmp_file=BitmapFactory.decodeResource(activity.getResources(),R.drawable.file); sub_index=0 String show="" length= (length>=1073741824 sub_index=String.valueOf(()length/1073741824).indexOf("." show=(()length/1073741824+"000").substring(0,sub_index+3)+"GB" (length>=1048576 sub_index=(String.valueOf(()length/1048576)).indexOf("." show=(()length/1048576+"000").substring(0,sub_index+3)+"GB" (length>=1024 sub_index=(String.valueOf(()length/1024)).indexOf("." show=(()length/1024+"000").substring(0,sub_index+3)+"GB" (length<1024 show=String.valueOf(length)+"B" }File_Adter.java
File_listActivity Activity List_View= But_Up= Txt_Path= File_Adter Adter= File_Adter( List_View.setOnItemClickListener( Adter.scanFiles("/" But_Up.setOnClickListener( File_Adter ad= (ad.currPath.equals("/")) File f= onItemClick(AdapterView<?> parent, View v, positiong, File_Adter da= File f= }File_listActivity.java