コード例 #1
0
  @Override
  protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);

    if (resultCode == RESULT_OK) {
      PayWayElement e =
          (PayWayElement) data.getSerializableExtra(PayWayShowOrCreateActivity.PAYWAY_DATA);
      if (CHANGE_PAYWAY == requestCode) {
        mAdapter.changeElement(e);
      } else if (CREATE_NEW_PAYWAY == requestCode) {
        mAdapter.addElement(e);
      }
    } else if (resultCode == PayWayShowOrCreateActivity.PAYWAY_DELETE) { // 仅在CHANGE_PAYWAY时发生
      PayWayElement e =
          (PayWayElement) data.getSerializableExtra(PayWayShowOrCreateActivity.PAYWAY_DATA);
      mAdapter.deleteElement(e.mPosition);
    }
  }
コード例 #2
0
 @Override
 public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
   Intent intent = new Intent();
   intent.setClass(this, PayWayShowOrCreateActivity.class);
   intent.putExtra(PayWayShowOrCreateActivity.CHANGE_OR_ADD, true);
   Bundle bundle = new Bundle();
   bundle.putSerializable(
       PayWayShowOrCreateActivity.PAYWAY_DATA, (PayWayElement) mAdapter.getItem(position));
   intent.putExtras(bundle);
   startActivityForResult(intent, CHANGE_PAYWAY);
 }