当前位置: 代码迷 >> Android >> android4.x与andriod2.x的datepicker差别比较大(图)
  详细解决方案

android4.x与andriod2.x的datepicker差别比较大(图)

热度:38   发布时间:2016-05-01 10:45:10.0
android4.x与andriod2.x的datepicker差异比较大(图)

最近刚学习android开发,准备使用时间下拉选择空间,使用了datepicker空间,结果发现,在android4.X下面和在android2.x下面差距太大,去overstack找了下资料,看来只能考虑使用datepickerdialog了

?

?4.X版本下的截图



?

2.X版本下的截图

?

?

?

Is there a way to make the datepicker in android 4.0 look like the easy one on 2.x devices? I don't really wanna to use a button with a dialog, but that is absolutely enormous, i don't want the "calendar" thing. Thanks in advance

?

?

1、在apk》=11之后的版本中,有一个方法,调用可以部分解决,但是想完全解决是没有办法,因为都是平台提供的。

picker.setCalendarViewShown(false);

?

System components look depends on the platform. You may be able (or not) to influence things like colors, but not functionality (unless you implement your own logic or layout). So in general, answer to your question is "No".

?

?

1 楼 jiaoronggui 2013-04-18  
不能直接用setCalendarViewShown(false);,如果那样的话,在2.x版本下会出错,需要判断下
sdk的版本号,如下
	private DatePicker dp;		dp = (DatePicker) findViewById(R.id.datePicker1);		if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {			dp.setCalendarViewShown(false);	    }
  相关解决方案