lv.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
@Override
public boolean onItemLongClick(AdapterView<?> adapterView, View view, final int i, long l) {
AlertDialog.Builder builder = new AlertDialog.Builder(Main2Activity.this);
builder.setTitle("提示");
builder.setMessage("请选择按钮");
builder.setPositiveButton("修改", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int a) {
Intent intent = new Intent(Main2Activity.this, Main3Activity.class);
intent.putExtra("name", i);
startActivityForResult(intent, 1);
}
});
builder.setNegativeButton("删除", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int ii) {
//1.点击当前的条目数
DatasBean datasBean = smalldata.get(i);
//2.删除数据库中的数据
App.getApp().getSession().getDatasBeanDao().delete(datasBean);
//3,删除集合里面的数据
smalldata.remove(datasBean);
//4.适配器进行刷新
adapter.notifyDataSetChanged();
}
});
builder.create();
builder.show();
return false;
}
});