2、資源管理器文件瀏覽器參考_第1頁
2、資源管理器文件瀏覽器參考_第2頁
2、資源管理器文件瀏覽器參考_第3頁
2、資源管理器文件瀏覽器參考_第4頁
免費(fèi)預(yù)覽已結(jié)束,剩余9頁可下載查看

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡介

1、資源管理器(文件瀏覽器【實(shí)驗(yàn)內(nèi)資資源管理器(文件瀏覽器【實(shí)驗(yàn)內(nèi)資源管理器(文件瀏覽器【實(shí)驗(yàn)?zāi)苛私赓Y源管理器_文件瀏覽器的用法】開源平板【關(guān)鍵代1源文件publicclassrowserprivate sic final_ID_COPY =private sic final_ID_ABOUT =+1; private sic final_ID_QUIT =+ 2; private ImageButton back, backToRoot;/ privateFileroot=new/ privateFilecurDir=/ private File files; privateFiledestFi

2、le=/ isCut=/* Called when the activity iscreated.*/ protected void onCreate(Bundle icicle)/ / publicvoid/ curDir=list/ publicvoid/ curDir=list=/ back.setOnClickListener(new publicvoidonClick(View/ backToRoot.setOnClickListener(new View.OnClickListener()publicvoidonClick(View/* 瀏覽目錄dir*/ privatevoidg

3、etFileDir(File/ / 2/ curDir=/ / shMap/ curDir=/ / shMap fileList = new shMapString, / files=/* */ for (File file : files)/ HashMapfileMap=newHashMap fileMap.put(fileSize,(newDouble(file.length()/10000/100.0).toString()+M); else if(file.length() 1024)fileMap.put(fileSize,(newDouble(file.length()/10)/

4、100.0).toString()+K); fileMap.put(fileSize, /elsefileMap.put(fileSize, fileMap.put(fileDate, 3/ SimpleAdapter adapter = new SimpleAdapter(this, R.layout.file_row,newimg,fileName,fileSize,fileDate,/ SimpleAdapter adapter = new SimpleAdapter(this, R.layout.file_row,newimg,fileName,fileSize,fileDate, R

5、.id.imgView, R.id fileName, R.id.fileSize, R.id.fileDate /* 事件,list.setOnItemClickListener(new publicvoidonItemClick(AdapterViewarg0,Viewarg1, long arg3)/ finalFilefile=/ 讀ifif/* */ /* */ else/* newnewpublicvoiderfacelist.setOnItemLongClickListener(new onItemLongClick(AdapterView arg0, View arg2,lon

6、g4returnpublicvoid(finalFileOnClickListener listener = new publicvoid returnpublicvoid(finalFileOnClickListener listener = new publicvoid erface/ AlertDialog dlg = new + + itiveButton(確定, / if(which=if(which=1destFile=file; isCut = false;/ AlertDialog dlg = new + + itiveButton(確定, 5elseifwhich2destF

7、ile=/這0 表示剪切操isCut=/ elseifwhich2destFile=/這0 表示剪切操isCut=/ if(which=/自定義一個(gè)帶輸入框由TextView final LayoutInflater factory = finalViewdialogview=factory.inflate(R.layout.rename,/TextView 的提示dialogview.findViewById(R.id.TextView01).setText(重命名/EditText 輸入框初始(EditText) new AlertDialog.OnClickListener() publ

8、icvoiderface /點(diǎn)擊確定之which) Stringvalue=if(new File(value).exists()builder.setTitle(重命名builder.setMessage(文件名重復(fù),是否需newAlertDialog.OnClickListener()publicvoiderfacedialogview =file6new Dialogerface.OnClickListener() publicvoiderface new Dialogerface.OnClickListener() publicvoiderface new Dialogerface.O

9、nClickListener() publicvoiderface elseif(which=4builder.setMessage(確定刪除newAlertDialog.OnClickListener()publicvoiderfaceif(deleteFile(file)rowser.this,刪除失敗!, 7new Dialogerface.OnClickListener() publicvoiderface /顯示操作菜new Dialogerface.OnClickListener() publicvoiderface /顯示操作菜=打開,剪切,重命名,刪除new .setTitle

10、(請(qǐng)選擇你要進(jìn)行的操作file)if(file!=return true;catch(Exceptionreturn false;returnopenFile(File*ent=8*UriFILE_OPEN_URI=Uri*ent.setData(FILE_OPEN_URI); try *catch(ActivityNotFoundException *Toast.LENGTH_SHORT).show(); *UriFILE_OPEN_URI=Uri*ent.setData(FILE_OPEN_URI); try *catch(ActivityNotFoundException *Toast.

11、LENGTH_SHORT).show(); *ent=* file.getAbsolutePath(); try catch(ActivityNotFoundException *Toast.LENGTH_SHORT).show(); /*MIMETyepent2=/ ent2.addFlags( ent.FLAG_ACTIVITY_NEW_TASK); ent2.addFlags( ent.FLAG_GRANT_READ_URI_PERMIS ent2.setAction( ent.ACTION_VIEW);/ 取得當(dāng)前文件的絕對(duì)路徑名+String type = getMIMEType(f

12、ile); return.add(.add(.add()_ID_COPY, 0, 粘貼_ID_ABOUT, 1, 關(guān)于_ID_QUIT, 2, 退出return publicvoidcopyFile(Filesrc,InputStream in = null; )9,catch(IOExceptionItem ecopyFile(destFile,newFile(curDir.getAbsolutePath()catch(IOExceptionItem ecopyFile(destFile,newFile(curDir.getAbsolutePath()+/+destFile.getName(

13、); return()if(destFile!=return Stringtype=StringfileName=/ String endName = fileName.substring(fileName.lastIndexOf(.) + 1if (endName.equals(mp3) | |type=elseif(endName.equals(3gp)|if (endName.equals(mp3) | |type=elseif(endName.equals(3gp)|type =elseif(endName.equals(jpg)|endName.equals(png)|type = image;type=*; type+=/*; return type;/*publicnativeic ?xml =1.0 encoding=utf-LinearLayout

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。

評(píng)論

0/150

提交評(píng)論