ListView的点击事件和长按事件

listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {        //点击事件
                @Override
                public void onItemClick(AdapterView parent, View view, int position, long id) {
                   
                }
            });

            listView.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {       //长按事件
                @Override
                public boolean onItemLongClick(AdapterView parent, View view, int position, long id) {
                    
                    return true;
                }
            });

解决点击和长按事件的冲突:将长按事件的返回改为true

你可能感兴趣的:(ListView的点击事件和长按事件)