`
rensanning
  • 浏览: 3553352 次
  • 性别: Icon_minigender_1
  • 来自: 大连
博客专栏
Efef1dba-f7dd-3931-8a61-8e1c76c3e39f
使用Titanium Mo...
浏览量:38235
Bbab2146-6e1d-3c50-acd6-c8bae29e307d
Cordova 3.x入门...
浏览量:607654
C08766e7-8a33-3f9b-9155-654af05c3484
常用Java开源Libra...
浏览量:682844
77063fb3-0ee7-3bfa-9c72-2a0234ebf83e
搭建 CentOS 6 服...
浏览量:89571
E40e5e76-1f3b-398e-b6a6-dc9cfbb38156
Spring Boot 入...
浏览量:402165
Abe39461-b089-344f-99fa-cdfbddea0e18
基于Spring Secu...
浏览量:69772
66a41a70-fdf0-3dc9-aa31-19b7e8b24672
MQTT入门
浏览量:91866
社区版块
存档分类
最新评论

Android UI日期时间选择之DateTimePicker

 
阅读更多
这个DateTimePicker提供了Google Agenda app的日期时间选择器,非常漂亮。

https://github.com/flavienlaurent/datetimepicker

***依赖于NineOldAndroids https://github.com/JakeWharton/NineOldAndroids

import com.fourmob.datetimepicker.date.DatePickerDialog;
import com.fourmob.datetimepicker.date.DatePickerDialog.OnDateSetListener;
import com.sleepbot.datetimepicker.time.RadialPickerLayout;
import com.sleepbot.datetimepicker.time.TimePickerDialog;

public class MainActivity extends FragmentActivity implements OnDateSetListener, TimePickerDialog.OnTimeSetListener {
    
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_date_time_picker_sample);

        final Calendar calendar = Calendar.getInstance();
        final DatePickerDialog datePickerDialog = DatePickerDialog.newInstance(this, calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH), calendar.get(Calendar.DAY_OF_MONTH), false);
        final TimePickerDialog timePickerDialog = TimePickerDialog.newInstance(this, calendar.get(Calendar.HOUR_OF_DAY) ,calendar.get(Calendar.MINUTE), false, false);

        findViewById(R.id.button_date).setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                datePickerDialog.show(getSupportFragmentManager(), "datepicker");
            }
        });
        
        findViewById(R.id.button_time).setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
            	 timePickerDialog.show(getSupportFragmentManager(), "timepicker");
            }
        });
    }

    @Override
    public void onDateSet(DatePickerDialog datePickerDialog, int year, int month, int day) {
        ((TextView) findViewById(R.id.date_text)).setText(year + "/" + (month + 1) + "/" + day);
    }

	@Override
	public void onTimeSet(RadialPickerLayout view, int hourOfDay, int minute) {
		((TextView) findViewById(R.id.time_text)).setText(hourOfDay + ":" + minute);
	}

}


日期选择:


选择小时:


选择分钟:
  • 大小: 39.7 KB
  • 大小: 34.6 KB
  • 大小: 37.9 KB
分享到:
评论
4 楼 ai_min 2016-11-01  
大牛牛 , 能不能把demo发一下呢? 842477204@qq.com
3 楼 天馒 2015-02-03  
这个地址有包: https://github.com/flavienlaurent/datetimepicker
2 楼 xuebenzhihoulu 2014-08-25  
请问为什么没有这些呢
import com.fourmob.datetimepicker.date.DatePickerDialog;
import com.fourmob.datetimepicker.date.DatePickerDialog.OnDateSetListener;
import com.sleepbot.datetimepicker.time.RadialPickerLayout;
import com.sleepbot.datetimepicker.time.TimePickerDialog;
求指导 ,谢谢了~~
1 楼 花曉夢飛蝶 2014-08-22  
导进去了NineOldAndroids  运行不了

相关推荐

Global site tag (gtag.js) - Google Analytics