安卓 日常问题 工作日志19

android中Dialog(对话框)插件的使用 很重要 很多地方需要   
 public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) { 这个是长按触发对话框 

final String name =fileNames.get(position);
MyAlertDialog myAlertDialog = new MyAlertDialog(this).builder()
.setTitle("确认吗?")
.setMsg("删除内容")
.setPositiveButton("确认", new View.OnClickListener() {
@Override
public void onClick(View v) {

for(int i = 0; i < areas.size(); i++){
if(areas.get(i).getArea_name()==name){
//此時到了相對應的集合 解析json字符串 并且 回显 线段
// lines.get(i).getLine_coordinate(); //这个是个字符串
long id =areas.get(i).getId();
if(areas.get(i)instanceof MeasureAreas){

mSession = ((MyApplication) getApplication()).getSession();
mSession.getMeasureAreasDao().deleteByKey(id); //根据id去删除数据 数据库删除

//列表 视图删除
areasNew = mSession.getMeasureAreasDao().loadAll();
fileNamesNew = new ArrayList<String>();
//将 线列表的名称 遍历到 fileNames中
for (int n = 0; n< areasNew.size(); n++) {
//这里 将得到的
fileNamesNew.add(areasNew.get(n).getArea_name());

}
adapterNew = new NewProjectFilesAdapter(ViewAreaListActivity.this,fileNamesNew);
areaList.setAdapter(adapterNew);
//刪除forldoverly中的 面
Intent data = new Intent();
data.putExtra(LISTAREAID,id);//返回 被删除的 面的 id 利用 id 去删除 fordoverly中的 对应的面
setResult(144,data);
finish();

}
}
}

}
}).setNegativeButton("取消", new View.OnClickListener() {
@Override
public void onClick(View v) {

}
});
myAlertDialog.show();



return true; //当有长按触发事件时 返回true 说明 不触发 点击事件 只触发长按事件 返回false时 则触发长按事件后 还要触发点击事件




原文地址:https://www.cnblogs.com/dushutai/p/12659285.html