自定義時間選擇器


點擊打開鏈接寫作背景:就兩天的事情由於項目上需要用到時間選擇器,系統的又無法滿足,無奈之下自定義了一個,由於時間緊急未做優化。


詳情請看Github地址,文章底部有鏈接

日期選擇對話框效果:


月份選擇效果:


年份選擇效果:



依賴
compile 'com.android.support:appcompat-v7:25.0.0'
compile 'com.android.support:recyclerview-v7:25.0.0'

使用方法
實現接口: implements MTimeOnClickListener
實例化: MTimeDialog mTimeDialog = new MTimeDialog(this);
設置監聽: mTimeDialog.setMTimeOnClickListener(this);

方法調用

日期選擇: mTimeDialog.showDayTime();
月份選擇: mTimeDialog.showMonthTime();
年份選擇: mTimeDialog.showYearTime();

回調接口:

@Override
public void getYear(int year) {//year對話框點擊確定時調用
    tv_time.setText(year + "年");
}

@Override
public void getYear_Month(int year, int month) {//month對話框點擊確定時調用
    tv_time.setText(year + "年" + month + "月");
}

@Override
public void getYear_Month_Day(int year, int month, int day) {//日期對話框點擊確定時調用
    tv_time.setText(year + "年" + month + "月" + day + "日");

}



Github地址:https://git.oschina.net/yrmao/YrMTimeDialog.git


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章