angads25:文件选择器

private void importTxtFile() {
    DialogProperties properties = new DialogProperties();
    properties.selection_mode = DialogConfigs.SINGLE_MODE;// 多选 、 单选
    properties.selection_type = DialogConfigs.FILE_SELECT;// 选择文件还是文件夹
    properties.root = new File(Environment.getExternalStorageDirectory().getPath());// 文件选择器的根目录
    properties.error_dir = new File(DialogConfigs.DEFAULT_DIR);// 当根目录无法读取时生效
    properties.offset = new File(Environment.getExternalStorageDirectory().getPath());// 文件路径偏移
    // 文件后缀过滤
    //properties.extensions = new String[]{"mp4", "3gp", "avi", "wma", "rmvb", "m4a", "amr", "mp3", "png", "jpg", "jpeg", "gif", "bmp", "psd", "svg", "swf"};
    properties.extensions = new String[]{"txt"};
    FilePickerDialog dialog = new FilePickerDialog(MainActivity.this, properties);
    dialog.setTitle("选择导入文件");
    dialog.setPositiveBtnName("导入");
    dialog.setNegativeBtnName("取消");
    dialog.setDialogSelectionListener(new DialogSelectionListener() {
        @Override
        public void onSelectedFilePaths(String[] files) {
           String path = files[0];
            AppContext.inputFilePath = path;
            Toast.makeText(MainActivity.this,"导入成功",Toast.LENGTH_SHORT).show();
        }
    });
    dialog.show();
}
compile 'com.github.angads25:filepicker:1.1.1'

 

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值