1

How to open and pick file by click load button? I want to show a sd card location when I click on load button and pick any file from there and display on main screen selected files.

Can anyone help me on how to show selected files from SD card display on screen?

Button loadButton = (Button) findViewById(R.id.loadButton);
loadButton.setOnClickListener(new OnClickListener() {
    public void onClick(View v) {

    }
});
4

1 回答 1

0

您需要开始活动在 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-12T12:39:11.553 回答