与ListView相关的LongClick事件

时间:2019-02-28 04:04:22

标签: android listview events click

在按住一个项目的同时,您想要在屏幕上隐藏该项目。

public static void InstanceAceesBarListEvent()
{
    _IA_List.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {

            switch (position)
            {
                case 0 :
                    _LongKey_Handler.removeCallbacks(_LongKey_Runnable);
                    break;
        }
    });
}

public static void InstanceAceesBarListLongEvent()
{
    _IA_List.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
        @Override
        public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {

            switch(position)
            {
                case 0 :
                    _LongKey_Handler.post(_LongKey_Runnable);

                    return false;

            }
            return true;
        }
    });
}


public static Handler _LongKey_Handler = new Handler();
public static Runnable _LongKey_Runnable = new Runnable() {
    @Override
    public void run() {
        Log.d("LongKeyHandler", LongKey Event:ok");
        _LongKey_Handler.postDelayed(this, 0);
    }
};

我这样做了,但是它将在几秒钟内运行。 我能立即做到这一点吗?

换句话说,从您按下按钮的那一刻起,我希望在我按住点击时一直发生此事件。

0 个答案:

没有答案