public final int[] getResourceDeclareStyleableIntArray( Context context, String name )
{try
{
//use reflection to access the resource class
Field[] fields2 = Class.forName( mGetPkgName() + ".R$styleable" ).getFields();
//browse all fields
for ( Field f : fields2 )
{
//pick matching field
if ( f.getName().equals( name ) )
{
//return as int array
int[] ret = (int[])f.get( null );
return ret;
}
}
}catch ( Throwable t )
{
}
return null;
}
本文详细解析了如何使用Java通过反射获取资源定义样式数组的方法,并提供了实例代码和关键步骤说明。
1909

被折叠的 条评论
为什么被折叠?



