首页 > 其他分享 >显示日期对话框

显示日期对话框

时间:2022-12-12 13:22:53浏览次数:38  
标签:datePicker 显示 String 对话框 findViewById 日期 viewById id

        <DatePicker
        android:id="@+id/dp"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:calendarViewShown="false"
        android:datePickerMode="spinner"
        />
final DatePicker datePicker = findViewById(R.id.dp);
        datePicker.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                String desc = String.format("你选择的日期是%d年%d月%d日",datePicker.getYear(),datePicker.getMonth() + 1,datePicker.getDayOfMonth());
                TextView viewById = findViewById(R.id.tv_date);
                viewById.setText(desc);
            }
        });

标签:datePicker,显示,String,对话框,findViewById,日期,viewById,id
From: https://www.cnblogs.com/loulan/p/16975788.html

相关文章