示例#1
0
  public void showUpdateDialog() {
    final Dialog dialog = new Dialog(getActivity());
    dialog.setContentView(R.layout.edit_user_info);
    dialog.setCancelable(true);

    updateProfileTV = (TextView) dialog.findViewById(R.id.udpateProfileTV);
    phoneNumberUpd = (TextView) dialog.findViewById(R.id.phoneNumberUpd);
    errorTxtUpt = (TextView) dialog.findViewById(R.id.errorTxtUpt);
    nameUpd = (EditText) dialog.findViewById(R.id.nameUpd);
    eMailUpd = (EditText) dialog.findViewById(R.id.eMailUpd);
    addressETUpd = (EditText) dialog.findViewById(R.id.addressETUpd);
    save = (Button) dialog.findViewById(R.id.saveUpt);

    phoneNumberUpd.setText(databaseHandler.getUser(1).getMsisdn());
    nameUpd.setText(databaseHandler.getUser(1).getName());
    eMailUpd.setText(databaseHandler.getUser(1).getEmail());
    addressETUpd.setText(databaseHandler.getRegister(1).getAddress());
    save.setOnClickListener(
        new OnClickListener() {

          @Override
          public void onClick(View v) {
            // TODO Hit here to update
            if (carFunctions.isConnectingToInternet()) {
              new UpdateProfile(
                      databaseHandler.getUser(1).getMsisdn(),
                      eMailUpd.getText().toString(),
                      nameUpd.getText().toString(),
                      addressETUpd.getText().toString())
                  .execute();
              // getActivity().finish();
              // Intent intent = new Intent(getActivity(), getActivity()
              // .getClass());
              // intent.putExtra("fragNum", "0");
              // getActivity().startActivity(intent);
            } else {
              Toast.makeText(getActivity(), "Check your internet connection", Toast.LENGTH_LONG)
                  .show();
            }
            dialog.dismiss();
          }
        });

    if (setting.getDuration() == 1) {
      dialog.setTitle(getResources().getString(R.string.update_profile_ar));
      updateProfileTV.setText(getResources().getString(R.string.update_profile_ar));
      save.setText(getResources().getString(R.string.save_ar));
    } else {
      dialog.setTitle(getResources().getString(R.string.update_profile_en));
      updateProfileTV.setText(getResources().getString(R.string.update_profile_en));
    }

    dialog.show();
  }