转自:http://www.cnblogs.com/nuistlr/archive/2012/09/07/2675649.html
首先要继承OnItemLongClickListener
public class Set_Music extends ListActivity implements OnItemLongClickListener{
然后设置权限:
getListView().setOnItemLongClickListener(this);
重写方法
public boolean onItemLongClick(AdapterView<?> arg0, View arg1, int arg2,
long arg3) {
String str = list.get(arg2).get("name");
删掉长按的item
list.remove(arg2);
动态更新listview
adapter.notifyDataSetChanged();
时间: 2024-11-03 17:06:25