android 應用通過自定義資源名獲取資源

2021-08-22 10:13:01 字數 567 閱讀 5712

//對應資源陣列

private static final string res_icon_name = ;

//對應字串資源陣列

"statusbar",

"launcher",

"wall*****",

"lookscreen",

};//關鍵點通過下面方式獲取id,drawable資源

public static int getresiconid(context context, string iconname)

//字串資源

public static int getresnameid(context context, string iconname)

//實際使用地方

string name =

drawable drawable =

context.getdrawable(getresiconid(context,res_icon_name[i])));

}可以根據不同的需要替換掉string,drawable,dimen....

springboot自定義靜態資

pringboot 靜態資源位置,classpath meta inf resources classpath resources classpath static classpath public 預設資源放在這幾個目錄下,是可以訪問的,但是專案中往往需要自己定義靜態資源載入的位置,這個時候就需要...

Android筆記 通過Shape自定義圓角按鈕

首先,在res資料夾下建乙個drawable資料夾,然後,在drawable資料夾下建乙個xml檔案,比如說 button bg.xml檔案,button bg.xml檔案內容可以是 android width 10dp android color 00ff00 android dashwidth ...

Android自定義控制項 自定義屬性

自定義屬性的過程 1.在res values資料夾中建立attrs的xml檔案。2.寫入標籤,定義子標籤attr,放入自定義屬性的名稱。format 可以用 來同時使用 1 reference 參考某一資源id 2 color 顏色值 3 boolean 布林值 4 dimension 尺寸值 帶有...