Article article = null;
Article article2 = null;
Article article3 = null;
if (position == 0)
{
article = getItem(0);
article2 = getItem(1);
article3 = getItem(2);
}
else if (position == 1)
{
article = getItem(3);
article2 = getItem(4);
article3 = getItem(5);
}
else if (position == 2)
{
article = getItem(6);
article2 = getItem(7);
article3 = getItem(8);
}
我需要像这样获取我的项目列表,但直到第 90 个项目(位置)我才能做到这一点。 我怎样才能无限次地编写这些代码。
最佳答案
I need to get my item list like this, but i can't do that until 90th item(position). How can i write these codes for infinite times.
你可以这样做:
article = getItem((position * 3));
article2 = getItem((position * 3) + 1);
article3 = getItem((position * 3) + 2);
这是一个简单的解决方案,并且会给你带来好处。
关于java - 我怎样才能为我的结构获得无限数量的项目,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22991725/