//长按事件
list.setOnItemLongClickListener(new OnItemLongClickListener() {
@Override
public boolean onItemLongClick(AdapterView<?> parent, View view,
final int position, long id) {
//listerner方法
android.content.DialogInterface.OnClickListener listener=new
android.content.DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
// TODO Auto-generated method stub
list.remove(position);
notifyAll();
}
};
//长按item时弹出对话框
Builder builder=new Builder(MusicList.this);
builder.setTitle("确定要删除吗?");
builder.setPositiveButton("确定",listener);
builder.setNegativeButton("取消",null);
builder.show();
return false;
}
});
}
相关分类