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

热点内容
广东分布式服务器云主机 浏览:578
服务器忙打不开怎么办 浏览:10
tif压缩软件 浏览:408
程序员那么可爱陆漓上班第1天 浏览:950
macbookair自带什么app 浏览:696
如何关了加密的软件 浏览:577
程序员p2p待遇 浏览:920
ipd编译要求 浏览:931
压缩解压王怎么用 浏览:29
服务器共享文件如何备份 浏览:752
买安卓手机怎么在官网买 浏览:122
诗词入门PDF 浏览:361
毒app是什么单位 浏览:64
如何自己编译android系统 浏览:792
phpmysqlpdomysqli 浏览:808
php修改sql语句 浏览:720
android有道api 浏览:387
挠耳营水表用的什么app 浏览:54
战锤40kpdf 浏览:381
java判断字符串是汉字 浏览:468