Android通過LIstView顯示檔案清單

來源:互聯網
上載者:User

<?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

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.