您的位置:首页 > 移动开发 > Android开发

Android开发之日期选择器的使用

2013-12-30 20:37 253 查看




 
<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"
 
  tools:context=".MainActivity"
>

 
  <TextView
 
     
android:id="@+id/mytext1"
 
     
android:layout_width="fill_parent"
 
     
android:layout_height="wrap_content"
 
     
android:layout_marginTop="10px"
 
     
android:text="日期选择器" />
<DatePicker 
  
 android:id="@+id/dp1"
 
     
android:layout_width="fill_parent"
 
     
android:layout_height="wrap_content"
 
     
android:layout_marginTop="40px"/>
</RelativeLayout>

public
class MainActivity extends Activity {
private
DatePicker dp=null;
protected void
onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
this.dp=(DatePicker)super.findViewById(R.id.dp1);
//更新日期
this.dp.updateDate(1990, 8,
16);
}

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: