【问题标题】:Randomly placing bitmaps in a grid on a custom view canvas?在自定义视图画布上的网格中随机放置位图?
【发布时间】:2017-02-16 22:20:50
【问题描述】:

我正在尝试从 ArrayList 中获取位图图像并随机生成它们的网格以用于 netwalk 游戏。我在与我的 GameView 类分开的另一个类中有这个方法:

public int getGridElem(int x, int y) {
    if (x < 0 || y < 0 || x >= mColumns || y >= mRows) {
        throw new IndexOutOfBoundsException("The coordinates (" + x + ", " + y + ") are not valid.");
    }
    return mGrid[gridPos(x, y)];
}

我正在努力研究如何使用这个类来显示 ArrayList 中图像的随机网格?

【问题讨论】:

    标签: android android-canvas android-custom-view android-bitmap


    【解决方案1】:

    如果你洗牌你的 ArrayList 然后创建你的网格呢?!

    Collections.shuffle(arrayList);

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-11-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-12-11
      • 2014-10-10
      • 2014-10-06
      • 1970-01-01
      相关资源
      最近更新 更多