我有一个问题,我找不到任何帮助:访问<申报,设置样式>资源编程
是否有可能,接收被保留资源的IDS由一个int []无需编程引用资源类R?
<declare-styleable name="com_facebook_login_view">
<attr name="confirm_logout" format="boolean"/>
<attr name="fetch_user_info" format="boolean"/>
<attr name="login_text" format="string"/>
<attr name="logout_text" format="string"/>
</declare-styleable>
的问题是,我无法解析定义的“申报,设置样式”属性的ID - 0×00总是返回:
int id = context.getResources().getIdentifier("com_facebook_login_view", "declare-styleable", context.getPackageName());
int[] resourceIDs = context.getResources().getIntArray(id);
任何想法将不胜感激! :)
在此先感谢!
克里斯托弗
这是因为它是一个声明,设置样式,而不是一个标识符。你有没有尝试对R.styleable课程进行思考? – njzk2
不,我没有提到这一点 - 感谢提示 - 我会尝试使用反射:) 所以没有办法动态访问声明样式? 我会用它的方法 getContext()。obtainStyledAttributes(AttributeSet set,int [] attrs); 感谢您的帮助! –
解决了它。但我的声望太低,回答我自己的问题:( 如果它不会被遗忘,我会在八小时内发布它;) –