public void onClick(View v) {
   if (v == btnCancel) {
     this.dismiss();
   } else if (v == btnSave) {
     //			save to SharedPreferences
     SharedPreferences pref =
         activity.getSharedPreferences(
             SettingActivity.PREFERENCES_FILE, Context.MODE_WORLD_READABLE);
     SharedPreferences.Editor myEditor = pref.edit();
     myEditor.putString("name", edt_name.getText().toString());
     myEditor.commit();
     this.dismiss();
   }
 }
  private void findViews() {
    btnCancel = (Button) contentView.findViewById(R.id.setting_name_btncancel);
    btnCancel.setOnClickListener(this);
    btnSave = (Button) contentView.findViewById(R.id.setting_name_btnsave);
    btnSave.setOnClickListener(this);
    edt_name = (ClearableEditText) contentView.findViewById(R.id.setting_name_value);

    edt_name.setOnFocusChangeListener(
        new View.OnFocusChangeListener() {

          public void onFocusChange(View v, boolean hasFocus) {
            if (hasFocus && edt_name.getText().toString().length() != 0) {
              edt_name.setCompoundDrawablesWithIntrinsicBounds(0, 0, R.drawable.btn_clear, 0);
            } else {
              edt_name.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, 0);
            }
          }
        });
  }