如有图片kung_fu0_normal.png,kung_fu1_normal.png,kung_fu2_normal.png...
遍历的时候取出每个id:
int resid = getResources().getIdentifier("kung_fu" + position % 10+"_normal", "drawable",
parent.getContext().getPackageName());
本文介绍了一种根据位置参数动态获取图片资源的方法,通过构造特定格式的字符串来匹配资源文件名,适用于如游戏等需要大量图标资源的应用场景。
如有图片kung_fu0_normal.png,kung_fu1_normal.png,kung_fu2_normal.png...
遍历的时候取出每个id:
int resid = getResources().getIdentifier("kung_fu" + position % 10+"_normal", "drawable",
parent.getContext().getPackageName());
416

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