I have pos in the same way, for example in the code
if (controlList.get(pos).getImageUploads().size() > 9) { I add no more than 10 items to the list. But there is a snag, I want to always move the first position to the right. Is this possible?
I have pos in the same way, for example in the code
if (controlList.get(pos).getImageUploads().size() > 9) { I add no more than 10 items to the list. But there is a snag, I want to always move the first position to the right. Is this possible?
When working with lists, never forget that element positions start from zero. Those. in order to call the first element of the list, you should call this: Object o = yourList.get(0);
perhaps, if you understood everything correctly, then like this:
public void addToFirst(YourType yourItem) { if (yourList.isEmpty()){ yourList.add(yourItem); } else { yourList.add(0, yourItem); } } Source: https://ru.stackoverflow.com/questions/577084/
All Articles