本文實例為大家分享了android使用datepicker計算年齡的具體代碼,供大家參考,具體內(nèi)容如下
界面如下,湊合看吧
點擊選擇年齡的按鈕時彈出datepicker日歷選擇器
在日歷選擇器上選中您的年齡點擊完成
activity_main.xml的代碼如下:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingBottom="@dimen/activity_vertical_margin" android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin" android:paddingTop="@dimen/activity_vertical_margin" tools:context="com.example.datepicker.MainActivity" > <TextView android:id="@+id/editText" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerHorizontal="true" android:layout_centerVertical="true" android:hint="選擇你的出生年月" /> <Button android:id="@+id/select" android:onClick="SelectAge" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignBaseline="@+id/editText" android:layout_alignBottom="@+id/editText" android:layout_alignParentLeft="true" android:text="選擇年齡" /> </RelativeLayout>
網(wǎng)頁題目:android使用datepicker計算年齡-創(chuàng)新互聯(lián)
網(wǎng)站地址:http://www.rwnh.cn/article10/cephdo.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供微信公眾號、定制網(wǎng)站、網(wǎng)站制作、全網(wǎng)營銷推廣、軟件開發(fā)、動態(tài)網(wǎng)站
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)
猜你還喜歡下面的內(nèi)容