android筛选年月,Android DatePickerDialog 只选择年月
//选择日期private OnTouchListener selectDateTouchListener = newOnTouchListener(){@Overridepublic booleanonTouch(View v, MotionEvent event) {if(event.getAction()==MotionEvent.ACTION_UP){final Calendar cd=C
//选择日期
private OnTouchListener selectDateTouchListener = newOnTouchListener(){
@Overridepublic booleanonTouch(View v, MotionEvent event) {if(event.getAction()==MotionEvent.ACTION_UP){final Calendar cd=Calendar.getInstance();
Date date=newDate();
cd.setTime(date);
DatePickerDialog dp= new DatePickerDialog(getActivity(), newOnDateSetListener(){public void onDateSet(DatePicker view, int year,int monthOfYear, intdayOfMonth) {
String dateStr= year+"-"+StrUtil.adjustMonthDay(monthOfYear+1);//当用户选择完年月之后,进行查询操作
if(PhoneInfo.isConnectInternet(getActivity())){
etSscxNssbDate.setText(dateStr);
doNssbQkSelect();
}else{
UIUtil.raDialog(getActivity(), WR.NET_NOT_CONN);
}
}
},
cd.get(Calendar.YEAR),
cd.get(Calendar.MONTH),
cd.get(Calendar.DAY_OF_MONTH));
dp.show();//隐藏天数
if (dp != null) {int SDKVersion =PhoneInfo.getSDKVersionNumber();if (SDKVersion < 11) {
((ViewGroup) dp.getDatePicker().getChildAt(0)).getChildAt(2).setVisibility(View.GONE);
}else if (SDKVersion > 14) {
((ViewGroup) ((ViewGroup) dp.getDatePicker().getChildAt(0)).getChildAt(0)).getChildAt(2).setVisibility(View.GONE);
}
}
etSscxNssbDate.setInputType(InputType.TYPE_NULL);
}return false;
}
};
更多推荐
所有评论(0)