笔记

listView.setOnItemLongClickListener(new OnItemLongClickListener()  //listView里的item长按事件
		{
			public boolean onItemLongClick(AdapterView<?> parent, View view,
					int position, long id)
			{
				TableLayout dialog = (TableLayout) getLayoutInflater()
						.inflate(R.layout.dialog, null);
				final EditText et_course = (EditText) dialog.findViewById(R.id.editText1);
				final EditText et_place = (EditText) dialog.findViewById(R.id.editText2);
				final int p = position;
				new AlertDialog.Builder(MainActivity.this)
			//		.setTitle("dd")  设置dialog标题
					.setView(dialog)
					.setPositiveButton("确定", new DialogInterface.OnClickListener()
					{
						public void onClick(DialogInterface dialog, int which)
						{
							//更新表数据
							dao.write(flag, et_course.getText().toString(), et_place.getText().toString(), p);
						
							//刷新listview显示内容
							setAdapter();
							simpleAdapter.notifyDataSetChanged();
						}
					})
					.setNegativeButton("取消", new DialogInterface.OnClickListener()
					{
						public void onClick(DialogInterface dialog, int which)
						{
							// TODO 自动生成的方法存根
							
						}
					})
					.create()
					.show();
			
				return false;
			}
		});


你可能感兴趣的:(笔记)