-2

我在数组列表中有需要检查匹配项的项目。

数组列表中的匹配项是按顺序排列的,因为它们应该由用户调用。

例如.. 红色、绿色、橙色。都在一个数组列表中,按照用户应该匹配的顺序排列。

问题是我无法弄清楚如何让用户按照它们出现的顺序调用它们。

现在这就是我试图做到这一点无济于事..

//Here i try to check to see the order being clicked matches 1 item less than the array list size.
if(this.getUserData() == Manager.getInstance().currentList.get(size-1)){

                //Here we produce the ingredient since it matches an item in the list.
                produceSquare();
                activity.runOnUiThread(new Runnable(){
                    @Override
                    public void run() {
                        Toast.makeText(activity, "Match", Toast.LENGTH_LONG).show();
                    }
                });

                //if the order matches an item in the array list, we remove that item.
            Manager.getInstance().currentList.remove(size-1);

这不起作用。现在,如果我有 2 个项目需要匹配,则必须在第一个项目之前单击第二个项目..我希望它是相反的。意味着列表中的第一项必须在最后一项之前调用。

有任何想法吗?

4

1 回答 1

0

似乎您损坏的代码使用户以相反的顺序单击。你需要改变

currentList.get(size-1)

currentList.remove(size-1)

currentList.get(0)

currentList.remove(0)

让用户按顺序点击。

于 2013-05-19T06:38:36.920 回答