Android Datepicker显示日历而不是年份

时间:2013-01-23 00:52:07

标签: android android-layout

遇到Datepicker的问题 - 不确定我是否误解了应该如何使用它。在图形布局编辑器中,我添加了一个Datepicker,并将该布局添加到我的活动中。当我运行应用程序时,月份和日期显示正常,但不是一年,我看到一个日历,我不知道为什么。有什么想法吗?

click for screenshot of the issue

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >

    <DatePicker
        android:id="@+id/datePicker1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" />

</LinearLayout>



public class BirthdayActivity extends Activity {    
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_birthday);
    }

}

1 个答案:

答案 0 :(得分:4)

默认显示。您可以将其设置为false:

setCalendarViewShown(boolean shown)

docs的第一行:

  

此类是用于选择日期的小部件。可以选择日期   按年,月,日旋转器或CalendarView。   还有一个相关的post