@Override public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) { // TODO Auto-generated method stub Items item = itemadapter.getItem(position); showItemDialog(item, position); return false; }
@Override public void onClick(View v) { // TODO Auto-generated method stub Log.d(TAG, "add......"); mDate = mEdtDate.getText().toString(); mItem = mEdtItem.getText().toString(); try { mDateStamp = toDateStamp(mDate); } catch (ParseException e) { // TODO Auto-generated catch block e.printStackTrace(); } String costS = mEdtCost.getText().toString(); if (!costS.matches("")) { mCost = Integer.parseInt(costS); Items it = new Items(); it.setDate(mDate); it.setItem(mItem); it.setCost(mCost); it.setDateStamp(mDateStamp); ItemsHelper.addItems(getContentResolver(), it); // money_items.add(0, it); //******************************************** money_items = ItemsHelper.listItems(MainActivity.this); itemadapter = new ItemAdapter2(MainActivity.this, money_items); money_list.setAdapter(itemadapter); itemadapter.notifyDataSetChanged(); resetForm(); } else { Toast.makeText(getApplicationContext(), "Cost 為必填欄位", Toast.LENGTH_SHORT).show(); } }