如何以mm/yyyy
格式显示日期选择器对话框,该格式不允许前几年和几个月。即,从当前日期开始显示android
中的单词。
答案 0 :(得分:1)
您可以这样创建:
datePickerDialog = new DatePickerDialog(getActivity(), null,
calendar.get(Calendar.YEAR),
calendar.get(Calendar.MONTH),
calendar.get(Calendar.DAY_OF_MONTH))
{
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
int year = getContext().getResources()
.getIdentifier("android:id/day", null, null);
if(year != 0){
View yearPicker = findViewById(year);
if(yearPicker != null){
yearPicker.setVisibility(View.GONE);
}
}
}
};
然后你可以打电话:
datePickerDialog.show();
答案 1 :(得分:0)
DatePickerDialog datePickerDialog=new DatePickerDialog(this, listener, year, month, day);
DatePicker datepicker=datePickerDialog.getDatePicker();
//datep.removeViewAt(0);
LinearLayout v1=(LinearLayout)datepicker.getChildAt(0);
LinearLayout v2=(LinearLayout)v1.getChildAt(0);
View v3=v2.getChildAt(1);
v3.setVisibility(View.GONE);
Toast.makeText(this, ""+v3.getClass().getName()+"\ncount "+v2.getChildCount(), 1).show();
datePickerDialog.show();
使用此代码