get Ids Array from resource via Context - Android android.content

Android examples for android.content:Context

Description

get Ids Array from resource via Context

Demo Code


//package com.java2s;
import android.content.Context;
import android.content.res.TypedArray;

public class Main {
    public static int[] getIdsArray(Context context, int idArray) {
        TypedArray ar = context.getResources().obtainTypedArray(idArray);
        int len = ar.length();
        int[] arrayIds = new int[len];
        for (int i = 0; i < len; i++)
            arrayIds[i] = ar.getResourceId(i, 0);
        ar.recycle();/*  w ww .  ja va  2s  .co  m*/
        return arrayIds;
    }
}

Related Tutorials