导航:首页 > 操作系统 > android数字选择器

android数字选择器

发布时间:2023-08-26 13:48:06

1. 求助一个android 文件选择器的源码(用于上传文件时选择并...

打开文件选择器:
private void showFileChooser() {
Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
intent.setType("*/*");
intent.addCategory(Intent.CATEGORY_OPENABLE);

try {
startActivityForResult( Intent.createChooser(intent, "Select a File to Upload"), FILE_SELECT_CODE);
} catch (android.content.ActivityNotFoundException ex) {
Toast.makeText(this, "Please install a File Manager.", Toast.LENGTH_SHORT).show();
}
}
选择结果:

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
switch (requestCode) {
case FILE_SELECT_CODE:
if (resultCode == RESULT_OK) {
// Get the Uri of the selected file
Uri uri = data.getData();
String path = FileUtils.getPath(this, uri);
}
break;
}
super.onActivityResult(requestCode, resultCode, data);
}
FileUtils文件

public class FileUtils {
public static String getPath(Context context, Uri uri) {

if ("content".equalsIgnoreCase(uri.getScheme())) {
String[] projection = { "_data" };
Cursor cursor = null;

try {
cursor = context.getContentResolver().query(uri, projection,null, null, null);
int column_index = cursor.getColumnIndexOrThrow("_data");
if (cursor.moveToFirst()) {
return cursor.getString(column_index);
}
} catch (Exception e) {
// Eat it
}
}

else if ("file".equalsIgnoreCase(uri.getScheme())) {
return uri.getPath();
}

return null;
}
}

2. android怎么给控件添加选择器

1 在/res/drawable/目录下面新建一个xml文件,drawable就在res下面新建这个目录

5 上面的步骤完成时枣拦,找到你的控件所在的layout,设置其background属性,如果上面selector叫button_press.xml,那么其属性就是android:background="@drawable/button_press"

阅读全文

与android数字选择器相关的资料

热点内容
为什么服务器流量那么贵 浏览:256
读取pdf文件内容 浏览:488
如何给脚本链接加密 浏览:80
多服务器云部署方案 浏览:441
如何把一个安卓应用改为中文版 浏览:450
带求补器的源码 浏览:722
程序员掉入能力陷阱 浏览:671
中百超市多点app如何充值 浏览:331
仙剑奇侠传4codex未加密 浏览:194
如何搭建服务器ss端口 浏览:62
国外代理服务器地址服务器端口密码 浏览:754
phpthrownew 浏览:681
java从入门到精通pdf百度云 浏览:55
linuxhdf5安装 浏览:469
java继承编程练习题 浏览:652
云记app怎么写字视频 浏览:598
如何进入我的世界脏小豆的服务器 浏览:42
哪里找到转转app 浏览:580
苹果二次app怎么注册 浏览:587
国际服体验服服务器为什么爆满 浏览:114