【问题标题】:How can i get infinite number of item for my structure我怎样才能为我的结构获得无限数量的项目
【发布时间】:2014-04-10 14:58:49
【问题描述】:
  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 个项目(位置)我才能这样做。 我怎样才能无限次编写这些代码。

【问题讨论】:

  • ArticleX = getItem(位置*3 + X)
  • 您使用什么作为数据容器?一个数组列表?
  • @JejeDoudou 是的,类似于arraylist。
  • @Vladimir 谢谢它解决了我的问题 :)

标签: java android list android-listview


【解决方案1】:

我需要像这样获取我的项目列表,但直到 90 日我才能这样做 项目(位置)。我怎样才能无限次编写这些代码。

你可以这样做:

article = getItem((position * 3));
article2 = getItem((position * 3) + 1);
article3 = getItem((position * 3) + 2);

这是一个简单的解决方案,会为您带来一招。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-12-12
    • 1970-01-01
    • 1970-01-01
    • 2017-05-25
    • 2011-06-04
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多