您需要啓動活動添加在Manifasto.xml以下代碼文件
<activity
android:name=".fileDialog"
android:configChanges="orientation"
android:screenOrientation="reverseLandscape" />
在Java
您需要添加方法
public void onButtonClick(View v) {
pathSelect = "/sdcard/";
Intent myIntent = new Intent(getBaseContext(),
fileDialog.class);
myIntent.putExtra(fileDialog.START_PATH,
pathSelect);
startActivityForResult(pathSelect, REQUEST_SAVE);
}
public synchronized void onActivityResult(final int requestCode,
int resultCode, final Intent data) {
String filename = "null";
if (resultCode == Activity.RESULT_OK) {
filename = data.getStringExtra(FileDialog.RESULT_PATH);
} else if (resultCode == Activity.RESULT_CANCELED) {
// do on cancle button click
}
}
要顯示所選文件的路徑? – 2013-02-12 12:30:01
你見過嗎? –
Stan
2013-02-12 12:40:37