在java/android中使用arraylist
对于-1在下面的arraylist中代表什么,我有点困惑。有人能帮我一下吗,谢谢在java/android中使用arraylist,java,android,arraylist,Java,Android,Arraylist,对于-1在下面的arraylist中代表什么,我有点困惑。有人能帮我一下吗,谢谢 toyList.add(new toyStore(toyName[0], toyIcon.getResourceId(0, -1))); toyList.add(new toyStore(toyName[1], toyIcon.getResourceId(1, -1))); 如果属性未定义或不是资源,则defValue表示要返回的值 更多说明: public int getResourceId(int索引,int
toyList.add(new toyStore(toyName[0], toyIcon.getResourceId(0, -1)));
toyList.add(new toyStore(toyName[1], toyIcon.getResourceId(1, -1)));
如果属性未定义或不是资源,则defValue表示要返回的值
更多说明:
public int getResourceId(int索引,int定义值)
在API级别1中添加检索
属性在索引处。请注意,当
将检索整个TypedArray对象。因此,该函数
将返回所指定的最终资源值的资源标识符
已找到,但不一定是由指定的原始资源
属性
要检索的属性的参数索引。将值定义为
如果属性未定义或不是资源,则返回。退换商品
属性资源标识符,如果未定义,则为defValue
getResourceId(0,-1)
在toyIcon
的索引0处提供资源Id,或者如果属性未定义或不是资源,则返回-1。在文档中
public int getResourceId (int index, int defValue)
Parameters
index Index of attribute to retrieve.
defValue Value to return if the attribute is not defined or not a resource.
Returns
Attribute resource identifier, or defValue if not defined.
见此:,int)
类似地,
toyIcon.getResourceId(1,-1)
将在toyIcon
的索引1处返回资源Id,如果属性未定义或不是资源,则返回-1。来自以下链接,int)
“如果属性未定义或不是资源,则返回的值。”
因此,如果找不到您要查找的内容,则基本上它是一个默认值
public int getResourceId (int index, int defValue)
Parameters
index Index of attribute to retrieve.
defValue Value to return if the attribute is not defined or not a resource.
Returns
Attribute resource identifier, or defValue if not defined.