zoukankan      html  css  js  c++  java
  • android 调用系统自带的设置时间日期对话框

    package com.nico;  
      
    import android.app.Activity;  
    import android.app.DatePickerDialog;  
    //import android.app.TimePickerDialog;  
    import android.app.Dialog;  
      
    import android.os.Bundle;  
    import android.util.Log;  
    import android.view.View;  
    import android.view.View.OnClickListener;  
      
    import android.widget.Button;  
    import android.widget.DatePicker;  
    //import android.widget.TimePicker;  
      
    public class timePicker extends Activity {  
        /** Called when the activity is first created. */  
        private Button ShowDataPickerButton = null;  
        private static final int DATA_PICKER_ID = 1;  
      
        @Override  
        public void onCreate(Bundle savedInstanceState) {  
            super.onCreate(savedInstanceState);  
            setContentView(R.layout.data);  
            ShowDataPickerButton = (Button) findViewById(R.id.ShowDataPickerButton);  
            ShowDataPickerButton.setOnClickListener(new ShowClickListener());  
        }  
      
        private class ShowClickListener implements OnClickListener {  
      
            @Override  
            public void onClick(View arg0) {  
                // TODO Auto-generated method stub  
                showDialog(DATA_PICKER_ID);  
            }  
      
        }  
      
        DatePickerDialog.OnDateSetListener onDateSetListener = new DatePickerDialog.OnDateSetListener() {  
      
            @Override  
            public void onDateSet(DatePicker view, int year, int monthOfYear,  
                    int dayOfMonth) {  
      
                Log.v("Test", "-------------?"+year);  
                System.out.print(year + " " + monthOfYear + "  " + dayOfMonth);  
            }  
        };  
    //  TimePickerDialog.OnTimeSetListener onTimeSetListener = new TimePickerDialog.OnTimeSetListener() {  
    //  
    //      @Override  
    //      public void onTimeSet(TimePicker view, int hourOfDay, int minute) {  
    //          // TODO Auto-generated method stub  
    //          System.out.println(hourOfDay + "-" + minute);  
    //      }  
    //  
    //  };  
      
        @Override  
        protected Dialog onCreateDialog(int id) {  
            // TODO Auto-generated method stub  
            switch (id) {  
            case DATA_PICKER_ID:  
                Log.v("Test", "--------start---------->");  
                return new DatePickerDialog(this, onDateSetListener, 2011, 01, 01);  
                // return new TimePickerDialog(this,onTimeSetListener,22,3, true);  
            }  
            return super.onCreateDialog(id);  
        }  
      
    }  
    <?xml version="1.0" encoding="utf-8"?>    
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"    
        android:orientation="vertical"    
        android:layout_width="fill_parent"    
        android:layout_height="fill_parent"    
        >    
    <TextView      
        android:layout_width="fill_parent"     
        android:layout_height="wrap_content"     
        android:text="@string/hello"    
        />    
            
     <Button    
           android:id="@+id/ShowDataPickerButton"    
           android:layout_width="fill_parent"    
            android:layout_height="wrap_content"    
          />        
             
     </LinearLayout>  

    出处:http://hellorheaven.iteye.com/blog/1089834

  • 相关阅读:
    asp.net MVC 3/4 equivalent to a response.filter
    Asp.net MVC Request Life Cycle
    无法完成你的itunes store 请求发生未知错误50
    苹果Mac OS X系统十三年视觉变化发展史
    authentication not supported Connect to TFS Git from Xamarin Studio (non-hosted, locally installed TFS 2013)
    iOS开发者帐号申请指南
    Apple Developer Registration and DUNS Number Not Accepted
    apple developer D-U-N-S® Number
    苹果企业开发者账号申请记录
    D-U-N-S申请流程
  • 原文地址:https://www.cnblogs.com/gzggyy/p/2516766.html
Copyright © 2011-2022 走看看