让用户在ArrayList中选择第一项

时间:2013-05-19 05:32:59

标签: java android

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

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

例如..红色,绿色,橙色。所有都在数组列表中按顺序排列,因为用户应该匹配。

问题是我无法弄清楚如何让用户在出现时按顺序调用项目。

现在,我正试图这样做无济于事。

//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个需要匹配的项目,则必须在第一个项目之前点击第二个项目。我希望它是另一种方式。意味着必须在最后一项之前调用列表中的第一项。

有什么想法吗?

1 个答案:

答案 0 :(得分:0)

似乎您的代码损坏会让用户点击反向顺序。你需要改变

currentList.get(size-1)

currentList.remove(size-1)

currentList.get(0)

currentList.remove(0)

让用户按顺序点击。

相关问题