我開發一個應用程序中,我動態添加視圖並使用分配一個唯一的ID,但它返回負值負值:System.currentTimeMillis的()爲int的回報
long time = System.currentTimeMillis();
view.setId((int)time);
所以我搜索的谷歌並找到了另一個解決方案,但是它也不起作用。它還返回負值:
Long time = System.currentTimeMillis();
view.setId(time.intValue());
所以,我怎麼能轉換通過System.currentTimeMills()
回到int
安全長期價值?
System.currentTimeMills()
返回1505645107314
,同時轉換爲int
返回-1888413582
。
該值不適用於int。使用很長。 – algrid
感謝您的快速響應,但view.setId()方法需要int值和唯一 –