如何处理长按上ListView项

如何处理长按上ListView项

本文介绍了如何处理长按上ListView项?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

我怎么能赶上这样的活动吗? onCreateContextMenu 相当similiar,但我不需要的菜单。

How can I catch such event? onCreateContextMenu is quite similiar, but I don't need menu.

推荐答案

这是很难知道你需要什么来实现的。但我的猜测是,你想通过接收长按该项目执行一些acion。对于这一点,你有两个选择:

It's hard to know what you need to achieve. But my guess is that you want to perform some acion over the item that receives the long click. For that, you have two options:

  • 添加AdapterView.OnItemLongClickListener.请参阅setOnItemLongClickListener.
  • add an AdapterView.OnItemLongClickListener. See setOnItemLongClickListener.
listView.setOnItemLongClickListener (new OnItemLongClickListener() {
  public boolean onItemLongClick(AdapterView parent, View view, int position, long id) {
    //do your stuff here
  }
});

  • 如果您要创建一个自定义的适配器,添加一个View.OnLongClickListener创建视图的方法Adapter#getView(...)
    • if you are creating a custom adapter, add a View.OnLongClickListener when creating the View in the method Adapter#getView(...)
    • 这篇关于如何处理长按上ListView项?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

      1403页,肝出来的..

09-06 22:14