[英]Can't to retrieve all IDs of the drawables – Android
I have silly problem and I can't find out where is problem. 我有愚蠢的问题,我找不到问题所在。 I want to retrieve all ID of drawable elements, but I get only first id of element. 我想检索所有可绘制元素的ID,但仅获得元素的第一个ID。 my code: 我的代码:
images = new ArrayList<Integer>();
String img = mCursor.getString(mCursor.getColumnIndex("img_eq"));
String[] parts = img.split(",");
for (String part : parts) {
int resID = getResources().getIdentifier(part , "drawable", getPackageName());
images.add(resID);
}
I've checked the array "parts" has all elements, but ArrayList has only one id. 我已经检查了数组“部分”具有所有元素,但是ArrayList只有一个id。 Where is my mistake? 我的错误在哪里?
Okay... Cause of my problem was " " in string array. 好吧...我的问题的原因是字符串数组中的“”。 That is why I got null instead of element id. 这就是为什么我得到null而不是元素id的原因。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.