コード例 #1
0
 /** 显示选择宝贝生日的弹窗 */
 private void showBirthdayDialog() {
   if (mBirthdayDialog == null) {
     mBirthdayDialog = new BaseDialog(this);
     mBirthdayDialog.setWindow(R.style.alpha_animation, 0.3f);
     mBirthdayDialog.setContentView(R.layout.dialog_select_birthday);
     mDatePicker = (DatePicker) mBirthdayDialog.findViewById(R.id.date_picker);
     Calendar cal = Calendar.getInstance();
     cal.setTimeInMillis(System.currentTimeMillis());
     mDatePicker.init(
         cal.get(Calendar.YEAR), cal.get(Calendar.MONTH), cal.get(Calendar.DAY_OF_MONTH), null);
     mBirthdayDialog
         .findViewById(R.id.btn_ok)
         .setOnClickListener(
             new View.OnClickListener() {
               @Override
               public void onClick(View v) {
                 if (mDatePicker != null) {
                   String birthday =
                       String.format(
                           "%d年%02d月%02d日",
                           mDatePicker.getYear(),
                           mDatePicker.getMonth() + 1,
                           mDatePicker.getDayOfMonth());
                   mTvBabyBirthday.setText(birthday);
                 }
                 if (mBirthdayDialog != null) {
                   mBirthdayDialog.dismiss();
                 }
               }
             });
   }
   mBirthdayDialog.show();
 }
コード例 #2
0
  /** 显示选择性别的弹窗 */
  private void showSexDialog() {
    if (mSexDialog == null) {
      mSexDialog = new BaseDialog(this);
      mSexDialog.setWindow(R.style.alpha_animation, 0.3f);
      mSexDialog.setContentView(R.layout.dialog_select_sex);
      mBtnSexMale = (Button) mSexDialog.findViewById(R.id.btn_male);
      mBtnSexFemale = (Button) mSexDialog.findViewById(R.id.btn_female);
      mBtnSexMale.setOnClickListener(
          new View.OnClickListener() {
            @Override
            public void onClick(View v) {
              mTvBabySex.setText(R.string.male);
              if (mSexDialog != null) {
                mSexDialog.dismiss();
              }
            }
          });

      mBtnSexFemale.setOnClickListener(
          new View.OnClickListener() {
            @Override
            public void onClick(View v) {
              mTvBabySex.setText(R.string.female);
              if (mSexDialog != null) {
                mSexDialog.dismiss();
              }
            }
          });
    }
    if (TextUtils.equals(mTvBabySex.getText().toString(), getString(R.string.male))) {
      mBtnSexMale.setSelected(true);
      mBtnSexFemale.setSelected(false);
    } else if (TextUtils.equals(mTvBabySex.getText().toString(), getString(R.string.female))) {
      mBtnSexMale.setSelected(false);
      mBtnSexFemale.setSelected(true);
    } else {
      mBtnSexMale.setSelected(false);
      mBtnSexFemale.setSelected(false);
    }
    mSexDialog.show();
  }
コード例 #3
0
 /** 显示编辑宝贝昵称的弹窗 */
 private void showNameDialog() {
   if (mNameDialog == null) {
     mNameDialog = new BaseDialog(this);
     mNameDialog.setWindow(R.style.alpha_animation, 0.3f);
     mNameDialog.setContentView(R.layout.dialog_edit_baby_nikename);
     mEvBabyNickName = (ImageEditText) mNameDialog.findViewById(R.id.ev_baby_nickname);
     mNameDialog
         .findViewById(R.id.btn_ok)
         .setOnClickListener(
             new View.OnClickListener() {
               @Override
               public void onClick(View v) {
                 if (TextUtils.isEmpty(mEvBabyNickName.getText())) {
                   ToastUtil.show(R.string.baby_nickname_edit_hint);
                 } else {
                   mTvBabyName.setText(mEvBabyNickName.getText());
                   if (mNameDialog != null) {
                     mNameDialog.dismiss();
                   }
                 }
               }
             });
     mNameDialog
         .findViewById(R.id.btn_cancel)
         .setOnClickListener(
             new View.OnClickListener() {
               @Override
               public void onClick(View v) {
                 if (mNameDialog != null) {
                   mNameDialog.dismiss();
                 }
               }
             });
   }
   if (!TextUtils.isEmpty(mTvBabyName.getText())) {
     mEvBabyNickName.setText(mTvBabyName.getText());
     mEvBabyNickName.setSelection(mEvBabyNickName.getText().length());
   }
   CommonUtil.showSoftInput(this);
   mNameDialog.show();
 }
コード例 #4
0
 /** 显示选择鞋子尺码的弹窗 */
 private void showShoeSizeDialog() {
   if (mShoeSizeDialog == null) {
     mShoeSizeDialog = new BaseDialog(this);
     mShoeSizeDialog.setWindow(R.style.alpha_animation, 0.3f);
     mShoeSizeDialog.setContentView(R.layout.dialog_select_shoe_size);
     ListView lv = (ListView) mShoeSizeDialog.findViewById(R.id.lv_shoe_size);
     lv.setAdapter(new ShoeSizeAdapter(this, getShoeSizeList()));
     lv.setOnItemClickListener(
         new AdapterView.OnItemClickListener() {
           @Override
           public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
             mTvShoeSize.setText((String) parent.getAdapter().getItem(position));
             if (mShoeSizeDialog != null && mShoeSizeDialog.isShowing()) {
               mShoeSizeDialog.dismiss();
             }
           }
         });
   }
   mShoeSizeDialog.show();
 }