Android 文件选择器,单选,多选
程序员文章站
2024-03-23 14:58:52
...
https://github.com/inksnow/fileselect
使用
allprojects {
repositories {
google()
jcenter()
maven { url 'https://jitpack.io' }
}
}
implementation 'com.github.inksnow:fileselect:1.0.1'
package com.inks.fileselect;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import com.inks.inkslibrary.Utils.ClickUtil;
import com.inks.inkslibrary.Utils.L;
import com.inks.inkslibrary.Utils.T;
import java.util.ArrayList;
public class MainActivity extends AppCompatActivity {
private ChooseFile chooseFile;
private ChooseFileMultiple chooseFileMultiple;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
chooseFile = new ChooseFile();
chooseFile.setOnChooseFileBack(chooseFileBack);
chooseFileMultiple = new ChooseFileMultiple();
chooseFileMultiple.setOnChooseFileBack(chooseFileMultipleBack);
}
public void click(View view) {
if (!ClickUtil.isFastDoubleClick((long) 100)) {
int id = view.getId();
if (id == R.id.check_one) {
//单选
chooseFile.popupChoose(MainActivity.this, view, getWindow(), getLayoutInflater(),true);
} else if (id == R.id.check_multiple) {
//多选
chooseFileMultiple.popupChoose(MainActivity.this, view, getWindow(), getLayoutInflater(),true);
}
}
}
ChooseFile.onChooseFileBack chooseFileBack = new ChooseFile.onChooseFileBack() {
@Override
public void onChooseBack(String path, String type) {
L.e("选择文件:" + path);
T.showShort(MainActivity.this, "选择文件:" + path);
}
};
ChooseFileMultiple.onChooseFileBack chooseFileMultipleBack = new ChooseFileMultiple.onChooseFileBack() {
@Override
public void onChooseBack(ArrayList<String> paths) {
for (String path :paths) {
L.e("选择文件:" + path);
}
T.showShort(MainActivity.this, "共选择"+paths.size()+"个文件" );
}
};
}
上一篇: 时间日期选择器-bootstrap
下一篇: springboot简介
推荐阅读
-
Android 文件选择器,单选,多选
-
Android 文件选择器详解及实例代码
-
Android 文件选择器详解及实例代码
-
Android中创建对话框(确定取消对话框、单选对话框、多选对话框)实例代码
-
Android中创建对话框(确定取消对话框、单选对话框、多选对话框)实例代码
-
Android ListView构建支持单选和多选的投票项目
-
Android实现单选与多选对话框的代码
-
Android ListView构建支持单选和多选的投票项目
-
Android listview ExpandableListView实现多选,单选,全选,edittext实现批量输入的实例代码
-
Android实现单选与多选对话框的代码