欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

Android Studio時(shí)間選擇器的創(chuàng)建方法

 更新時(shí)間:2017年10月13日 08:56:10   作者:龍魂學(xué)者  
這篇文章主要為大家詳細(xì)介紹了Android Studio時(shí)間選擇器的創(chuàng)建方法,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下

本文實(shí)例為大家分享了Android九宮格圖片展示的具體代碼,供大家參考,具體內(nèi)容如下

效果顯示:

這里寫圖片描述

這里寫圖片描述

1、創(chuàng)建xml頁面(我的項(xiàng)目扣下來的,有的地方會報(bào)錯(cuò)要改)

<TextView
  android:id="@+id/consultation_tv_birthdate"
  android:layout_width="wrap_content"
  android:layout_height="wrap_content"
  android:layout_alignLeft="@+id/consultation_tv_sex"
  android:layout_alignStart="@+id/consultation_tv_sex"
  android:layout_alignTop="@+id/consultation_et_birthdate"
  android:layout_marginTop="9dp"
  android:text="出生日期:"
  android:textColor="@color/black"
  android:textSize="18sp"
  android:textStyle="bold" />

<EditText
  android:id="@+id/consultation_et_birthdate"
  android:layout_width="260dp"
  android:layout_height="40dp"
  android:layout_alignLeft="@+id/consultation_et_sex"
  android:layout_alignStart="@+id/consultation_et_sex"
  android:layout_below="@+id/consultation_et_sex"
  android:layout_marginTop="22dp"
  android:background="@drawable/input_bg"
  android:focusable="false"
  android:ems="10"
  android:inputType="textPersonName"
  android:paddingLeft="15dp"
  android:paddingRight="15dp" />

<ImageView
  android:id="@+id/consultation_iv_birthdate"
  android:layout_width="wrap_content"
  android:layout_height="wrap_content"
  android:layout_above="@+id/consultation_et_id_card"
  android:layout_alignEnd="@+id/consultation_et_birthdate"
  android:layout_alignRight="@+id/consultation_et_birthdate"
  android:layout_marginBottom="5dp"
  android:layout_marginRight="10dp"
  app:srcCompat="@android:drawable/ic_menu_today" />


2、創(chuàng)建參數(shù)

EditText consultation_et_birthdate;//出生日期:
ImageView consultation_iv_birthdate;//出生日期點(diǎn)擊

3、獲取控件

consultation_et_birthdate = (EditText) findViewById(R.id.consultation_et_birthdate);
consultation_iv_birthdate = (ImageView) findViewById(R.id.consultation_iv_birthdate);

4、創(chuàng)建點(diǎn)擊事件

consultation_iv_birthdate.setOnClickListener(new View.OnClickListener() {
  @Override
  public void onClick(View v) {
    showDialog(DATE_DIALOG);
  }
});


5、創(chuàng)建時(shí)間控件并獲取數(shù)據(jù)

final Calendar ca = Calendar.getInstance();
mYear = ca.get(Calendar.YEAR);//年
mMonth = ca.get(Calendar.MONTH);//月
mDay = ca.get(Calendar.DAY_OF_MONTH);//日

6、獲取點(diǎn)擊確定事件

@Override
protected Dialog onCreateDialog(int id) {
  switch (id) {
    case DATE_DIALOG:
      return new DatePickerDialog(this, mdateListener, mYear, mMonth, mDay);
  }
  return null;
}


7、綁定數(shù)據(jù)

/**
 * 設(shè)置日期 綁定時(shí)間
 */
private DatePickerDialog.OnDateSetListener mdateListener = new DatePickerDialog.OnDateSetListener() {
  @Override
  public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
    mYear = year;
    mMonth = monthOfYear;
    mDay = dayOfMonth;
    consultation_et_birthdate.setText(new StringBuffer().append(mYear).append("-").append(mMonth + 1).append("-").append(mDay).append(" "));
  }
};

有什么問題請留言。

以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

最新評論