導航:首頁 > 操作系統 > 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數字選擇器相關的資料

熱點內容
劍網三伺服器是怎麼運營 瀏覽:689
快手app快遞在哪裡查 瀏覽:473
開發聊天機器人python 瀏覽:854
程序員入職後無法工作 瀏覽:951
買海鮮用什麼app好 瀏覽:922
看劇用什麼app好 瀏覽:905
sql命令update 瀏覽:25
生意不忙怎麼解壓 瀏覽:500
歡太健康app在哪裡下載 瀏覽:488
androidtools使用教程 瀏覽:971
十天突破雅思口語pdf劍9 瀏覽:295
李誕笑場pdf 瀏覽:265
自用紙巾做解壓筆 瀏覽:129
銀行流水解壓碼是多少 瀏覽:895
百度哪個app好用 瀏覽:316
115廣告聯盟源碼 瀏覽:494
聯通app簽到源碼 瀏覽:680
怎麼連接另一個伺服器的資料庫 瀏覽:742
貓盤洗白命令 瀏覽:844
168api源碼 瀏覽:967