导航:首页 > 操作系统 > 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数字选择器相关的资料

热点内容
cc2540编程 浏览:794
越南离北京源码 浏览:639
服装展示网站源码 浏览:325
编译器过度优化线 浏览:689
安卓怎么边浏览边录视频 浏览:653
分支限界java 浏览:389
phpdiscuz登录 浏览:182
epr服务器50人要什么配置 浏览:780
云服务器ecs如何转移 浏览:558
android仿应用宝 浏览:379
php连接mysql数据库的方法 浏览:109
螺杆制冷压缩机油镜怎样判断 浏览:126
本地电脑如何做服务器配置 浏览:860
如何对app的版权进行保护 浏览:822
小孩子用什么app软件 浏览:733
androidksoap上传 浏览:464
服务器掉线是什么原因 浏览:33
迷你世界怎么看服务器被炸 浏览:324
和平精英上线服务器是什么 浏览:941
云服务器显存分配 浏览:453