在array.xml中
<string-array name="app_center_img">
<item>@drawable/app_business_form</item>
<item>@drawable/app_summary</item>
<item>@drawable/app_development</item>
<item>@drawable/app_aboutfield</item>
<item>@drawable/app_field</item>
<item>@drawable/app_teach</item>
<item>@drawable/app_course</item>
<item>@drawable/app_ice_borke</item>
<item>@drawable/app_sell</item>
<item>@drawable/app_chase_off</item>
</string-array>
代码获取
private TypedArray mThumbIds = getResources().obtainTypedArray(R.array.app_center_img);
image.setImageResource(mThumbIds.getResourceId(position,0));
当然也是可以获取字符串的 代码如下:
<string-array name="app_center_text">
<item>@string/app_deve_progress</item>
<item>@string/app_business_form</item>
<item>@string/app_summary</item>
<item>@string/app_development</item>
<item>@string/app_aboutfield</item>
<item>@string/app_field</item>
<item>@string/app_arrange</item>
<item>@string/app_teach</item>
<item>@string/app_teach_field</item>
<item>@string/app_ice_borke</item>
<item>@string/app_promotion_lesson_reg</item>
<item>@string/app_promotion_lesson_follow</item>
<item>@string/app_learning_cards</item>
<item>@string/app_learn_card</item>
<item>@string/app_referrals</item>
<item>@string/app_service_record</item>
<item>@string/app_sell</item>
<item>@string/app_chase_off</item>
<item>@string/app_course_table</item>
<item>@string/business_add_new_org</item>
</string-array>
代码获取
private TypedArray mTextValues = getResources().obtainTypedArray(R.array.app_center_text);
用法
text.setText(mTextValues.getResourceId(position, 0));