Android Open Source - sfcdialog Main Activity






From Project

Back to project page sfcdialog.

License

The source code is released under:

Boost Software License - Version 1.0 - August 17th, 2003 Permission is hereby granted, free of charge, to any person or organization obtaining a copy of the software and accompanying documentation co...

If you think the Android project sfcdialog listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

/*          Copyright  2015 Stanislav Petriakov
// Distributed under the Boost Software License, Version 1.0.
//    (See accompanying file LICENSE_1_0.txt or copy at
//          http://www.boost.org/LICENSE_1_0.txt)
*//*ww  w  .  j  av a2s. com*/
package com.keenfin.sfcdialog;

import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;

import java.io.File;

public class MainActivity extends ActionBarActivity {
    TextView tv;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        tv = (TextView) findViewById(R.id.textview);

        findViewById(R.id.button).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                SimpleFileChooser sfcDialog = new SimpleFileChooser();

                sfcDialog.setOnChosenListener(new SimpleFileChooser.SimpleFileChooserListener() {
                    @Override
                    public void onFileChosen(File file) {
                        setText("File is chosen:\r\n" + file.getAbsolutePath());
                    }

                    @Override
                    public void onDirectoryChosen(File directory) {
                        setText("Directory is chosen:\r\n" + directory.getAbsolutePath());
                    }

                    @Override
                    public void onCancel() {
                        setText("onCancel");
                    }
                });

                sfcDialog.setShowHidden(false);
                sfcDialog.setRootPath("/");
                sfcDialog.show(getFragmentManager(), "SimpleFileChooserDialog");
            }
        });
    }

    private void setText(String text) {
        tv.setText(text);
    }
}




Java Source Code List

com.keenfin.sfcdialog.MainActivity.java
com.keenfin.sfcdialog.SimpleFileChooser.java