瀏覽代碼

[공통][New] ResourceUtil.getStringArray()

hyodong.min 7 年之前
父節點
當前提交
b0321a5611
共有 1 個文件被更改,包括 13 次插入2 次删除
  1. 13 2
      app/src/main/java/kr/co/zumo/app/lifeplus/util/ResourceUtil.java

+ 13 - 2
app/src/main/java/kr/co/zumo/app/lifeplus/util/ResourceUtil.java

@@ -3,6 +3,7 @@
  */
 package kr.co.zumo.app.lifeplus.util;
 
+import android.support.annotation.ArrayRes;
 import android.support.annotation.IdRes;
 import android.support.annotation.StringRes;
 
@@ -44,14 +45,24 @@ public class ResourceUtil {
   /**
    * string resId 로 text 가져오기
    *
-   * @param resId R.string.name
+   * @param resId      R.string.name
    * @param formatArgs The format arguments that will be used for
    *                   substitution.
    * @return The string data associated with the resource, formatted and
-   *         stripped of styled text information.
+   * stripped of styled text information.
    */
   public static String getString(@StringRes int resId, Object... formatArgs) {
     return App.getInstance().getContext().getString(resId, formatArgs);
   }
 
+  /**
+   * array 가져오기
+   *
+   * @param idName "mobile_company"
+   * @return ["1", "2", ...]
+   */
+  public static String[] getStringArray(String idName) {
+    @ArrayRes int resId = App.getInstance().getContext().getResources().getIdentifier(idName, "array", App.getInstance().getPackageName());
+    return App.getInstance().getResources().getStringArray(resId);
+  }
 }