Android - 是否有可能让onItemLongClick触发器本身?

时间:2016-03-09 22:46:30

标签: android

我试图让onItemLongClick再次执行自己。但没有说明如何做到这一点。我正在寻找像performItemClick这样的东西,而不是LongClick。

lv.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
                @Override
                public boolean onItemLongClick(AdapterView<?> arg0, View arg1,
                                               int pos, long id) {

                    if (counter == 0) {
                        counter++;
                        // code to let the longclick method to run again
                        return true;
                    }

                     // logic TODO

                    return true;
                }
            });

1 个答案:

答案 0 :(得分:1)

肯定会递归调用它:

lv.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
            @Override
            public boolean onItemLongClick(AdapterView<?> arg0, View arg1,
                                           int pos, long id) {

                if (counter == 0) {
                    counter++;
                    // code to let the longclick method to run again
                    return onItemLongClick(parent, view, position, id);
                }

                 // logic TODO

                return true;
            }
        });